@nocobase/plugin-auth 1.0.1-alpha.1 → 1.0.1-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/client/index.js
CHANGED
|
@@ -28,4 +28,4 @@
|
|
|
28
28
|
} else {
|
|
29
29
|
return /^[^@.<>"'/]{1,50}$/.test(value) || t("Please enter a valid username");
|
|
30
30
|
}
|
|
31
|
-
}}}`,"x-decorator":"FormItem","x-component-props":{placeholder:'{{t("Username/Email")}}',style:{}}},password:{type:"string","x-component":"Password",required:!0,"x-decorator":"FormItem","x-component-props":{placeholder:'{{t("Password")}}',style:{}}},actions:{type:"void","x-component":"div",properties:{submit:{title:'{{t("Sign in")}}',type:"void","x-component":"Action","x-component-props":{htmlType:"submit",block:!0,type:"primary",useAction:"{{ useBasicSignIn }}",style:{width:"100%"}}}}},signUp:{type:"void","x-component":"Link","x-component-props":{to:"{{ signUpLink }}"},"x-content":'{{t("Create an account")}}',"x-visible":"{{ allowSignUp }}"}}},G=e=>{const{t:n}=A(),o=e.authenticator,{authType:r,name:s,options:c}=o,m=!!(N()[r]&&(c!=null&&c.allowSignUp)),ae=`/signup?name=${s}`,pe=()=>$(s);return a.jsx(t.SchemaComponent,{schema:W,scope:{useBasicSignIn:pe,allowSignUp:m,signUpLink:ae,t:n}})},H=e=>{const n=h.useNavigate(),o=x.useForm(),r=t.useAPIClient(),{t:s}=g.useTranslation();return{run(){return v(this,null,function*(){var p;yield o.submit(),yield r.auth.signUp(o.values,e==null?void 0:e.authenticator),d.message.success(((p=e==null?void 0:e.message)==null?void 0:p.success)||s("Sign up successfully, and automatically jump to the sign in page")),setTimeout(()=>{n("/signin")},2e3)})}}},J={type:"object",name:U.uid(),"x-component":"FormV2",properties:{username:{type:"string",required:!0,"x-component":"Input","x-validator":{username:!0},"x-decorator":"FormItem","x-component-props":{placeholder:'{{t("Username")}}',style:{}}},password:{type:"string",required:!0,"x-component":"Password","x-decorator":"FormItem","x-component-props":{placeholder:'{{t("Password")}}',checkStrength:!0,style:{}},"x-reactions":[{dependencies:[".confirm_password"],fulfill:{state:{selfErrors:'{{$deps[0] && $self.value && $self.value !== $deps[0] ? t("Password mismatch") : ""}}'}}}]},confirm_password:{type:"string",required:!0,"x-component":"Password","x-decorator":"FormItem","x-component-props":{placeholder:'{{t("Confirm password")}}',style:{}},"x-reactions":[{dependencies:[".password"],fulfill:{state:{selfErrors:'{{$deps[0] && $self.value && $self.value !== $deps[0] ? t("Password mismatch") : ""}}'}}}]},actions:{type:"void","x-component":"div",properties:{submit:{title:'{{t("Sign up")}}',type:"void","x-component":"Action","x-component-props":{block:!0,type:"primary",htmlType:"submit",useAction:"{{ useBasicSignUp }}",style:{width:"100%"}}}}},link:{type:"void","x-component":"div",properties:{link:{type:"void","x-component":"Link","x-component-props":{to:"/signin"},"x-content":'{{t("Log in with an existing account")}}'}}}}},Q=({authenticatorName:e})=>{const{t:n}=A(),o=()=>H({authenticator:e}),r=F(e),{options:s}=r;return s!=null&&s.allowSignUp?a.jsx(t.SchemaComponent,{schema:J,scope:{useBasicSignUp:o,t:n}}):a.jsx(h.Navigate,{to:"/not-found",replace:!0})},X=()=>{const{t:e}=A();return a.jsx(t.SchemaComponent,{scope:{t:e},components:{Alert:d.Alert},schema:{type:"object",properties:{public:{type:"object",properties:{allowSignUp:{"x-decorator":"FormItem",type:"boolean",title:'{{t("Allow to sign up")}}',"x-component":"Checkbox",default:!0}}},notice:{type:"void","x-component":"Alert","x-component-props":{showIcon:!0,message:'{{t("The authentication allows users to sign in via username or email.")}}'}}}}})},w=l.createContext({type:""});w.displayName="AuthTypeContext";const P=l.createContext({types:[]});P.displayName="AuthTypesContext";const Y=()=>{const{types:e}=l.useContext(P);return e},E={name:"authenticators",sortable:!0,fields:[{name:"id",type:"string",interface:"id"},{interface:"input",type:"string",name:"name",uiSchema:{type:"string",title:'{{t("Auth UID")}}',"x-component":"Input","x-validator":e=>/^[a-zA-Z0-9_-]+$/.test(e)?"":t.i18n.t("a-z, A-Z, 0-9, _, -"),required:!0}},{interface:"input",type:"string",name:"authType",uiSchema:{type:"string",title:'{{t("Auth Type")}}',"x-component":"Select",dataSource:"{{ types }}",required:!0}},{interface:"input",type:"string",name:"title",uiSchema:{type:"string",title:'{{t("Title")}}',"x-component":"Input"}},{interface:"textarea",type:"string",name:"description",uiSchema:{type:"string",title:'{{t("Description")}}',"x-component":"Input"}},{type:"boolean",name:"enabled",uiSchema:{type:"boolean",title:'{{t("Enabled")}}',"x-component":"Checkbox"}}]},R={type:"object",properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues(e){const n=t.useActionContext(),{type:o}=l.useContext(w);return t.useRequest(()=>Promise.resolve({data:{name:`s_${U.uid()}`,authType:o}}),T(C({},e),{refreshDeps:[n.visible]}))}},title:'{{t("Add new")}}',properties:{name:{"x-component":"CollectionField","x-decorator":"FormItem"},authType:{"x-component":"CollectionField","x-decorator":"FormItem","x-component-props":{options:"{{ types }}"}},title:{"x-component":"CollectionField","x-decorator":"FormItem"},description:{"x-component":"CollectionField","x-decorator":"FormItem"},enabled:{"x-component":"CollectionField","x-decorator":"FormItem"},options:{type:"object","x-component":"Options"},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useCreateAction }}"}}}}}}}},ee={type:"void",name:"authenticators","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:E,resourceName:"authenticators",dragSort:!0,request:{resource:"authenticators",action:"list",params:{pageSize:50,sort:"sort",appends:[]}}},"x-component":"CollectionProvider_deprecated","x-component-props":{collection:E},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{delete:{type:"void",title:'{{t("Delete")}}',"x-component":"Action","x-component-props":{icon:"DeleteOutlined",useAction:"{{ cm.useBulkDestroyAction }}",confirm:{title:"{{t('Delete')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},create:{type:"void",title:'{{t("Add new")}}',"x-component":"AddNew","x-component-props":{type:"primary"}}}},table:{type:"void","x-uid":"input","x-component":"Table.Void","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}",useAction(){const e=t.useAPIClient(),{t:n}=g.useTranslation();return{move(r,s){return v(this,null,function*(){yield e.resource("authenticators").move({sourceId:r.id,targetId:s.id}),d.message.success(n("Saved successfully"),.2)})}}}},properties:{id:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{id:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},name:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{name:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},authType:{title:'{{t("Auth Type")}}',type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{authType:{type:"string","x-component":"Select","x-read-pretty":!0,enum:"{{ types }}"}}},title:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{title:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},description:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{description:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0}}},enabled:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{enabled:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{t("Actions")}}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{update:{type:"void",title:'{{t("Configure")}}',"x-component":"Action.Link","x-component-props":{type:"primary"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues:"{{ cm.useValuesFromRecord }}"},title:'{{t("Configure")}}',properties:{name:{"x-component":"CollectionField","x-decorator":"FormItem"},authType:{"x-component":"CollectionField","x-decorator":"FormItem","x-component-props":{options:"{{ types }}"}},title:{"x-component":"CollectionField","x-decorator":"FormItem"},description:{"x-component":"CollectionField","x-decorator":"FormItem"},enabled:{"x-component":"CollectionField","x-decorator":"FormItem"},options:{type:"object","x-component":"Options"},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useUpdateAction }}"}}}}}}}},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action.Link","x-component-props":{confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"},useAction:"{{cm.useDestroyAction}}"},"x-disabled":"{{ useCanNotDelete() }}"}}}}}}}}},te=e=>{const n=t.useRecord(),o=t.useRequest(()=>Promise.resolve({data:C({},n.options)}),T(C({},e),{manual:!0})),{run:r}=o,s=t.useActionContext();return l.useEffect(()=>{s.visible&&r()},[s.visible,r]),o},oe=e=>{var r;const o=t.usePlugin(f).authTypes.get(e);return(r=o==null?void 0:o.components)==null?void 0:r.AdminSettingsForm},ne=x.observer(()=>{const e=x.useForm(),n=t.useRecord(),o=oe(e.values.authType||n.authType);return o?a.jsx(o,{}):null},{displayName:"Options"}),se=()=>{const{setVisible:e}=t.useActionContext();return{run(){return v(this,null,function*(){e(!1)})}}},re=()=>{const{t:e}=g.useTranslation(),[n,o]=l.useState(!1),[r,s]=l.useState(""),c=Y(),p=c.map(m=>T(C({},m),{onClick:()=>{o(!0),s(m.value)}}));return a.jsx(t.ActionContextProvider,{value:{visible:n,setVisible:o},children:a.jsxs(w.Provider,{value:{type:r},children:[a.jsx(d.Dropdown,{menu:{items:p},children:a.jsxs(d.Button,{icon:a.jsx(k.PlusOutlined,{}),type:"primary",children:[e("Add new")," ",a.jsx(k.DownOutlined,{})]})}),a.jsx(t.SchemaComponent,{scope:{useCloseAction:se,types:c,setType:s},schema:R})]})})},ie=()=>(t.useAsyncData(),!1),ce=()=>{const{t:e}=A(),[n,o]=l.useState([]),r=t.useAPIClient();return t.useRequest(()=>r.resource("authenticators").listTypes().then(s=>{var p;return(((p=s==null?void 0:s.data)==null?void 0:p.data)||[]).map(m=>({key:m.name,label:e(m.title||m.name),value:m.name}))}),{onSuccess:s=>{o(s)}}),a.jsx(d.Card,{bordered:!1,children:a.jsx(P.Provider,{value:{types:n},children:a.jsx(t.SchemaComponent,{schema:ee,components:{AddNew:re,Options:ne},scope:{types:n,useValuesFromOptions:te,useCanNotDelete:ie,t:e}})})})};class f extends t.Plugin{constructor(){super(...arguments);j(this,"authTypes",new u.Registry)}registerType(o,r){this.authTypes.register(o,r)}load(){return v(this,null,function*(){this.app.pluginSettingsManager.add(b,{icon:"LoginOutlined",title:`{{t("Authentication", { ns: "${b}" })}}`,Component:ce,aclSnippet:"pm.auth.authenticators"}),this.router.add("auth",{Component:"AuthLayout"}),this.router.add("auth.signin",{path:"/signin",Component:"SignInPage"}),this.router.add("auth.signup",{path:"/signup",Component:"SignUpPage"}),this.app.addComponents({AuthLayout:D,SignInPage:M,SignUpPage:Z}),this.app.providers.unshift([O,{}]),this.registerType(B,{components:{SignInForm:G,SignUpForm:Q,AdminSettingsForm:X}})})}}i.AuthLayout=D,i.AuthenticatorsContext=S,i.AuthenticatorsContextProvider=q,i.PluginAuthClient=f,i.default=f,i.useAuthenticator=F,i.useSignIn=$,Object.defineProperties(i,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
31
|
+
}}}`,"x-decorator":"FormItem","x-component-props":{placeholder:'{{t("Username/Email")}}',style:{}}},password:{type:"string","x-component":"Password",required:!0,"x-decorator":"FormItem","x-component-props":{placeholder:'{{t("Password")}}',style:{}}},actions:{type:"void","x-component":"div",properties:{submit:{title:'{{t("Sign in")}}',type:"void","x-component":"Action","x-component-props":{htmlType:"submit",block:!0,type:"primary",useAction:"{{ useBasicSignIn }}",style:{width:"100%"}}}}},signUp:{type:"void","x-component":"Link","x-component-props":{to:"{{ signUpLink }}"},"x-content":'{{t("Create an account")}}',"x-visible":"{{ allowSignUp }}"}}},G=e=>{const{t:n}=A(),o=e.authenticator,{authType:r,name:s,options:c}=o,m=!!(N()[r]&&(c!=null&&c.allowSignUp)),ae=`/signup?name=${s}`,pe=()=>$(s);return a.jsx(t.SchemaComponent,{schema:W,scope:{useBasicSignIn:pe,allowSignUp:m,signUpLink:ae,t:n}})},H=e=>{const n=h.useNavigate(),o=x.useForm(),r=t.useAPIClient(),{t:s}=g.useTranslation();return{run(){return v(this,null,function*(){var p;yield o.submit(),yield r.auth.signUp(o.values,e==null?void 0:e.authenticator),d.message.success(((p=e==null?void 0:e.message)==null?void 0:p.success)||s("Sign up successfully, and automatically jump to the sign in page")),setTimeout(()=>{n("/signin")},2e3)})}}},J={type:"object",name:U.uid(),"x-component":"FormV2",properties:{username:{type:"string",required:!0,"x-component":"Input","x-validator":{username:!0},"x-decorator":"FormItem","x-component-props":{placeholder:'{{t("Username")}}',style:{}}},password:{type:"string",required:!0,"x-component":"Password","x-decorator":"FormItem","x-component-props":{placeholder:'{{t("Password")}}',checkStrength:!0,style:{}},"x-reactions":[{dependencies:[".confirm_password"],fulfill:{state:{selfErrors:'{{$deps[0] && $self.value && $self.value !== $deps[0] ? t("Password mismatch") : ""}}'}}}]},confirm_password:{type:"string",required:!0,"x-component":"Password","x-decorator":"FormItem","x-component-props":{placeholder:'{{t("Confirm password")}}',style:{}},"x-reactions":[{dependencies:[".password"],fulfill:{state:{selfErrors:'{{$deps[0] && $self.value && $self.value !== $deps[0] ? t("Password mismatch") : ""}}'}}}]},actions:{type:"void","x-component":"div",properties:{submit:{title:'{{t("Sign up")}}',type:"void","x-component":"Action","x-component-props":{block:!0,type:"primary",htmlType:"submit",useAction:"{{ useBasicSignUp }}",style:{width:"100%"}}}}},link:{type:"void","x-component":"div",properties:{link:{type:"void","x-component":"Link","x-component-props":{to:"/signin"},"x-content":'{{t("Log in with an existing account")}}'}}}}},Q=({authenticatorName:e})=>{const{t:n}=A(),o=()=>H({authenticator:e}),r=F(e),{options:s}=r;return s!=null&&s.allowSignUp?a.jsx(t.SchemaComponent,{schema:J,scope:{useBasicSignUp:o,t:n}}):a.jsx(h.Navigate,{to:"/not-found",replace:!0})},X=()=>{const{t:e}=A();return a.jsx(t.SchemaComponent,{scope:{t:e},components:{Alert:d.Alert},schema:{type:"object",properties:{public:{type:"object",properties:{allowSignUp:{"x-decorator":"FormItem",type:"boolean",title:'{{t("Allow to sign up")}}',"x-component":"Checkbox",default:!0}}},notice:{type:"void","x-component":"Alert","x-component-props":{showIcon:!0,message:'{{t("The authentication allows users to sign in via username or email.")}}'}}}}})},w=l.createContext({type:""});w.displayName="AuthTypeContext";const P=l.createContext({types:[]});P.displayName="AuthTypesContext";const Y=()=>{const{types:e}=l.useContext(P);return e},E={name:"authenticators",sortable:!0,fields:[{name:"id",type:"string",interface:"id"},{interface:"input",type:"string",name:"name",uiSchema:{type:"string",title:'{{t("Auth UID")}}',"x-component":"Input","x-validator":e=>/^[a-zA-Z0-9_-]+$/.test(e)?"":t.i18n.t("a-z, A-Z, 0-9, _, -"),required:!0}},{interface:"input",type:"string",name:"authType",uiSchema:{type:"string",title:'{{t("Auth Type")}}',"x-component":"Select",dataSource:"{{ types }}",required:!0}},{interface:"input",type:"string",name:"title",uiSchema:{type:"string",title:'{{t("Title")}}',"x-component":"Input"}},{interface:"textarea",type:"string",name:"description",uiSchema:{type:"string",title:'{{t("Description")}}',"x-component":"Input"}},{type:"boolean",name:"enabled",uiSchema:{type:"boolean",title:'{{t("Enabled")}}',"x-component":"Checkbox"}}]},R={type:"object",properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues(e){const n=t.useActionContext(),{type:o}=l.useContext(w);return t.useRequest(()=>Promise.resolve({data:{name:`s_${U.uid()}`,authType:o}}),T(C({},e),{refreshDeps:[n.visible]}))}},title:'{{t("Add new")}}',properties:{name:{"x-component":"CollectionField","x-decorator":"FormItem"},authType:{"x-component":"CollectionField","x-decorator":"FormItem","x-component-props":{options:"{{ types }}"}},title:{"x-component":"CollectionField","x-decorator":"FormItem"},description:{"x-component":"CollectionField","x-decorator":"FormItem"},enabled:{"x-component":"CollectionField","x-decorator":"FormItem"},options:{type:"object","x-component":"Options"},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useCreateAction }}"}}}}}}}},ee={type:"void",name:"authenticators","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:E,resourceName:"authenticators",dragSort:!0,request:{resource:"authenticators",action:"list",params:{pageSize:50,sort:"sort",appends:[]}}},"x-component":"CollectionProvider_deprecated","x-component-props":{collection:E},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{delete:{type:"void",title:'{{t("Delete")}}',"x-component":"Action","x-component-props":{icon:"DeleteOutlined",useAction:"{{ cm.useBulkDestroyAction }}",confirm:{title:"{{t('Delete')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},create:{type:"void",title:'{{t("Add new")}}',"x-component":"AddNew","x-component-props":{type:"primary"}}}},table:{type:"void","x-uid":"input","x-component":"Table.Void","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}",useAction(){const e=t.useAPIClient(),{t:n}=g.useTranslation();return{move(r,s){return v(this,null,function*(){yield e.resource("authenticators").move({sourceId:r.id,targetId:s.id}),d.message.success(n("Saved successfully"),.2)})}}}},properties:{id:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{id:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},name:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{name:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},authType:{title:'{{t("Auth Type")}}',type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{authType:{type:"string","x-component":"Select","x-read-pretty":!0,enum:"{{ types }}"}}},title:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{title:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},description:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{description:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0}}},enabled:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{enabled:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{t("Actions")}}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{update:{type:"void",title:'{{t("Configure")}}',"x-component":"Action.Link","x-component-props":{type:"primary"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues:"{{ cm.useValuesFromRecord }}"},title:'{{t("Configure")}}',properties:{name:{"x-component":"CollectionField","x-decorator":"FormItem"},authType:{"x-component":"CollectionField","x-decorator":"FormItem","x-component-props":{options:"{{ types }}"}},title:{"x-component":"CollectionField","x-decorator":"FormItem"},description:{"x-component":"CollectionField","x-decorator":"FormItem"},enabled:{"x-component":"CollectionField","x-decorator":"FormItem"},options:{type:"object","x-component":"Options"},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useUpdateAction }}"}}}}}}}},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action.Link","x-component-props":{confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"},useAction:"{{cm.useDestroyAction}}"},"x-disabled":"{{ useCanNotDelete() }}"}}}}}}}}},te=e=>{const n=t.useRecord(),o=t.useRequest(()=>Promise.resolve({data:C({},n.options)}),T(C({},e),{manual:!0})),{run:r}=o,s=t.useActionContext();return l.useEffect(()=>{s.visible&&r()},[s.visible,r]),o},oe=e=>{var r;const o=t.usePlugin(f).authTypes.get(e);return(r=o==null?void 0:o.components)==null?void 0:r.AdminSettingsForm},ne=x.observer(()=>{const e=x.useForm(),n=t.useRecord(),o=oe(e.values.authType||n.authType);return o?a.jsx(o,{}):null},{displayName:"Options"}),se=()=>{const{setVisible:e}=t.useActionContext();return{run(){return v(this,null,function*(){e(!1)})}}},re=()=>{const{t:e}=g.useTranslation(),[n,o]=l.useState(!1),[r,s]=l.useState(""),c=Y(),p=c.map(m=>T(C({},m),{onClick:()=>{o(!0),s(m.value)}}));return a.jsx(t.ActionContextProvider,{value:{visible:n,setVisible:o},children:a.jsxs(w.Provider,{value:{type:r},children:[a.jsx(d.Dropdown,{menu:{items:p},children:a.jsxs(d.Button,{icon:a.jsx(k.PlusOutlined,{}),type:"primary",children:[e("Add new")," ",a.jsx(k.DownOutlined,{})]})}),a.jsx(t.SchemaComponent,{scope:{useCloseAction:se,types:c,setType:s},schema:R})]})})},ie=()=>(t.useAsyncData(),!1),ce=()=>{const{t:e}=A(),[n,o]=l.useState([]),r=t.useAPIClient();return t.useRequest(()=>r.resource("authenticators").listTypes().then(s=>{var p;return(((p=s==null?void 0:s.data)==null?void 0:p.data)||[]).map(m=>({key:m.name,label:x.Schema.compile(m.title||m.name,{t:e}),value:m.name}))}),{onSuccess:s=>{o(s)}}),a.jsx(d.Card,{bordered:!1,children:a.jsx(P.Provider,{value:{types:n},children:a.jsx(t.SchemaComponent,{schema:ee,components:{AddNew:re,Options:ne},scope:{types:n,useValuesFromOptions:te,useCanNotDelete:ie,t:e}})})})};class f extends t.Plugin{constructor(){super(...arguments);j(this,"authTypes",new u.Registry)}registerType(o,r){this.authTypes.register(o,r)}load(){return v(this,null,function*(){this.app.pluginSettingsManager.add(b,{icon:"LoginOutlined",title:`{{t("Authentication", { ns: "${b}" })}}`,Component:ce,aclSnippet:"pm.auth.authenticators"}),this.router.add("auth",{Component:"AuthLayout"}),this.router.add("auth.signin",{path:"/signin",Component:"SignInPage"}),this.router.add("auth.signup",{path:"/signup",Component:"SignUpPage"}),this.app.addComponents({AuthLayout:D,SignInPage:M,SignUpPage:Z}),this.app.providers.unshift([O,{}]),this.registerType(B,{components:{SignInForm:G,SignUpForm:Q,AdminSettingsForm:X}})})}}i.AuthLayout=D,i.AuthenticatorsContext=S,i.AuthenticatorsContextProvider=q,i.PluginAuthClient=f,i.default=f,i.useAuthenticator=F,i.useSignIn=$,Object.defineProperties(i,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/dist/externalVersion.js
CHANGED
|
@@ -8,20 +8,20 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
module.exports = {
|
|
11
|
-
"@nocobase/client": "1.0.1-alpha.
|
|
11
|
+
"@nocobase/client": "1.0.1-alpha.2",
|
|
12
12
|
"react": "18.2.0",
|
|
13
13
|
"react-router-dom": "6.21.0",
|
|
14
|
-
"@nocobase/utils": "1.0.1-alpha.
|
|
15
|
-
"@nocobase/auth": "1.0.1-alpha.
|
|
16
|
-
"@nocobase/database": "1.0.1-alpha.
|
|
17
|
-
"@nocobase/cache": "1.0.1-alpha.
|
|
18
|
-
"@nocobase/server": "1.0.1-alpha.
|
|
19
|
-
"@nocobase/test": "1.0.1-alpha.
|
|
14
|
+
"@nocobase/utils": "1.0.1-alpha.2",
|
|
15
|
+
"@nocobase/auth": "1.0.1-alpha.2",
|
|
16
|
+
"@nocobase/database": "1.0.1-alpha.2",
|
|
17
|
+
"@nocobase/cache": "1.0.1-alpha.2",
|
|
18
|
+
"@nocobase/server": "1.0.1-alpha.2",
|
|
19
|
+
"@nocobase/test": "1.0.1-alpha.2",
|
|
20
20
|
"antd": "5.12.8",
|
|
21
21
|
"@formily/react": "2.3.0",
|
|
22
22
|
"@formily/shared": "2.3.0",
|
|
23
23
|
"react-i18next": "11.18.6",
|
|
24
24
|
"@emotion/css": "11.11.2",
|
|
25
25
|
"@ant-design/icons": "5.2.6",
|
|
26
|
-
"@nocobase/actions": "1.0.1-alpha.
|
|
26
|
+
"@nocobase/actions": "1.0.1-alpha.2"
|
|
27
27
|
};
|
package/dist/locale/en-US.json
CHANGED
|
@@ -17,11 +17,11 @@
|
|
|
17
17
|
"Please enter a valid email": "Please enter a valid email",
|
|
18
18
|
"Please enter your username or email": "Please enter your username or email",
|
|
19
19
|
"Please enter a password": "Please enter a password",
|
|
20
|
-
"SMS": "SMS",
|
|
21
20
|
"Username/Email": "Username/Email",
|
|
22
21
|
"Auth UID": "Auth UID",
|
|
23
22
|
"The authentication allows users to sign in via username or email.": "The authentication allows users to sign in via username or email.",
|
|
24
23
|
"No authentication methods available.": "No authentication methods available.",
|
|
25
24
|
"The password is inconsistent, please re-enter": "The password is inconsistent, please re-enter",
|
|
26
|
-
"Sign-in": "Sign-in"
|
|
25
|
+
"Sign-in": "Sign-in",
|
|
26
|
+
"Password": "Password"
|
|
27
27
|
}
|
package/dist/locale/zh-CN.json
CHANGED
|
@@ -17,11 +17,11 @@
|
|
|
17
17
|
"Please enter a valid email": "请输入有效的邮箱",
|
|
18
18
|
"Please enter your username or email": "请输入用户名或邮箱",
|
|
19
19
|
"Please enter a password": "请输入密码",
|
|
20
|
-
"SMS": "短信",
|
|
21
20
|
"Username/Email": "用户名/邮箱",
|
|
22
21
|
"Auth UID": "认证标识",
|
|
23
22
|
"The authentication allows users to sign in via username or email.": "该认证方式支持用户通过用户名或邮箱登录。",
|
|
24
23
|
"No authentication methods available.": "没有可用的认证方式。",
|
|
25
24
|
"The password is inconsistent, please re-enter": "密码不一致,请重新输入",
|
|
26
|
-
"Sign-in": "登录"
|
|
25
|
+
"Sign-in": "登录",
|
|
26
|
+
"Password": "密码"
|
|
27
27
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"cron","description":"Cron jobs for your node","version":"2.4.4","author":"Nick Campbell <nicholas.j.campbell@gmail.com> (https://github.com/ncb000gt)","bugs":{"url":"https://github.com/kelektiv/node-cron/issues"},"repository":{"type":"git","url":"https://github.com/kelektiv/node-cron.git"},"main":"lib/cron","scripts":{"lint":"eslint {lib,tests}/*.js","test":"jest --coverage","test:watch":"jest --watch --coverage","test:types":"tsd","prepare":"husky install","release":"semantic-release"},"types":"types/index.d.ts","dependencies":{"@types/luxon":"~3.3.0","luxon":"~3.3.0"},"devDependencies":{"@commitlint/cli":"~17.6.6","@insurgentlab/commitlint-config":"^18.1.0","@insurgentlab/conventional-changelog-preset":"~6.0.3","@semantic-release/changelog":"~6.0.x","@semantic-release/commit-analyzer":"~9.0.x","@semantic-release/git":"~10.0.x","@semantic-release/github":"~8.1.x","@semantic-release/npm":"~10.0.x","@semantic-release/release-notes-generator":"~11.0.x","chai":"~4.2.x","eslint":"~8.36.x","eslint-config-prettier":"^8.7.x","eslint-config-standard":"~17.0.x","eslint-plugin-import":"~2.27.x","eslint-plugin-jest":"~27.2.x","eslint-plugin-n":"~15.6.x","eslint-plugin-prettier":"~4.2.x","eslint-plugin-promise":"~6.1.x","husky":"^8.0.3","jest":"~29.5.x","prettier":"~2.8.x","semantic-release":"~21.0.x","sinon":"^15.0.x","tsd":"^0.28.1"},"keywords":["cron","node cron","node-cron","schedule","scheduler","cronjob","cron job"],"license":"MIT","contributors":["Brandon der Blätter <https://interlucid.com/contact/> (https://github.com/intcreator)","Romain Beauxis <toots@rastageeks.org> (https://github.com/toots)","James Padolsey <> (https://github.com/jamespadolsey)","Finn Herpich <fh@three-heads.de> (https://github.com/ErrorProne)","Clifton Cunningham <clifton.cunningham@gmail.com> (https://github.com/cliftonc)","Eric Abouaf <eric.abouaf@gmail.com> (https://github.com/neyric)","humanchimp <morphcham@gmail.com> (https://github.com/humanchimp)","Craig Condon <craig@spiceapps.com> (https://github.com/spiceapps)","Dan Bear <daniel@hulu.com> (https://github.com/danhbear)","Vadim Baryshev <vadimbaryshev@gmail.com> (https://github.com/baryshev)","Leandro Ferrari <lfthomaz@gmail.com> (https://github.com/lfthomaz)","Gregg Zigler <greggzigler@gmail.com> (https://github.com/greggzigler)","Jordan Abderrachid <jabderrachid@gmail.com> (https://github.com/jordanabderrachid)","Masakazu Matsushita <matsukaz@gmail.com> (matsukaz)","Christopher Lunt <me@kirisu.co.uk> (https://github.com/kirisu)"],"jest":{"collectCoverage":true,"collectCoverageFrom":["lib/*.js"],"coverageThreshold":{"global":{"statements":80,"branches":80,"functions":70,"lines":80}}},"files":["lib","types","CHANGELOG.md","LICENSE","README.md"],"_lastModified":"2024-06-
|
|
1
|
+
{"name":"cron","description":"Cron jobs for your node","version":"2.4.4","author":"Nick Campbell <nicholas.j.campbell@gmail.com> (https://github.com/ncb000gt)","bugs":{"url":"https://github.com/kelektiv/node-cron/issues"},"repository":{"type":"git","url":"https://github.com/kelektiv/node-cron.git"},"main":"lib/cron","scripts":{"lint":"eslint {lib,tests}/*.js","test":"jest --coverage","test:watch":"jest --watch --coverage","test:types":"tsd","prepare":"husky install","release":"semantic-release"},"types":"types/index.d.ts","dependencies":{"@types/luxon":"~3.3.0","luxon":"~3.3.0"},"devDependencies":{"@commitlint/cli":"~17.6.6","@insurgentlab/commitlint-config":"^18.1.0","@insurgentlab/conventional-changelog-preset":"~6.0.3","@semantic-release/changelog":"~6.0.x","@semantic-release/commit-analyzer":"~9.0.x","@semantic-release/git":"~10.0.x","@semantic-release/github":"~8.1.x","@semantic-release/npm":"~10.0.x","@semantic-release/release-notes-generator":"~11.0.x","chai":"~4.2.x","eslint":"~8.36.x","eslint-config-prettier":"^8.7.x","eslint-config-standard":"~17.0.x","eslint-plugin-import":"~2.27.x","eslint-plugin-jest":"~27.2.x","eslint-plugin-n":"~15.6.x","eslint-plugin-prettier":"~4.2.x","eslint-plugin-promise":"~6.1.x","husky":"^8.0.3","jest":"~29.5.x","prettier":"~2.8.x","semantic-release":"~21.0.x","sinon":"^15.0.x","tsd":"^0.28.1"},"keywords":["cron","node cron","node-cron","schedule","scheduler","cronjob","cron job"],"license":"MIT","contributors":["Brandon der Blätter <https://interlucid.com/contact/> (https://github.com/intcreator)","Romain Beauxis <toots@rastageeks.org> (https://github.com/toots)","James Padolsey <> (https://github.com/jamespadolsey)","Finn Herpich <fh@three-heads.de> (https://github.com/ErrorProne)","Clifton Cunningham <clifton.cunningham@gmail.com> (https://github.com/cliftonc)","Eric Abouaf <eric.abouaf@gmail.com> (https://github.com/neyric)","humanchimp <morphcham@gmail.com> (https://github.com/humanchimp)","Craig Condon <craig@spiceapps.com> (https://github.com/spiceapps)","Dan Bear <daniel@hulu.com> (https://github.com/danhbear)","Vadim Baryshev <vadimbaryshev@gmail.com> (https://github.com/baryshev)","Leandro Ferrari <lfthomaz@gmail.com> (https://github.com/lfthomaz)","Gregg Zigler <greggzigler@gmail.com> (https://github.com/greggzigler)","Jordan Abderrachid <jabderrachid@gmail.com> (https://github.com/jordanabderrachid)","Masakazu Matsushita <matsukaz@gmail.com> (matsukaz)","Christopher Lunt <me@kirisu.co.uk> (https://github.com/kirisu)"],"jest":{"collectCoverage":true,"collectCoverageFrom":["lib/*.js"],"coverageThreshold":{"global":{"statements":80,"branches":80,"functions":70,"lines":80}}},"files":["lib","types","CHANGELOG.md","LICENSE","README.md"],"_lastModified":"2024-06-11T12:22:11.610Z"}
|
package/dist/server/plugin.js
CHANGED
|
@@ -46,17 +46,15 @@ var import_preset = require("../preset");
|
|
|
46
46
|
var import_auth = __toESM(require("./actions/auth"));
|
|
47
47
|
var import_authenticators = __toESM(require("./actions/authenticators"));
|
|
48
48
|
var import_basic_auth = require("./basic-auth");
|
|
49
|
-
var import_locale = require("./locale");
|
|
50
49
|
var import_authenticator = require("./model/authenticator");
|
|
51
50
|
var import_storer = require("./storer");
|
|
52
51
|
var import_token_blacklist = require("./token-blacklist");
|
|
52
|
+
var import_utils = require("@nocobase/utils");
|
|
53
53
|
class PluginAuthServer extends import_server.Plugin {
|
|
54
54
|
cache;
|
|
55
55
|
afterAdd() {
|
|
56
56
|
}
|
|
57
57
|
async beforeLoad() {
|
|
58
|
-
this.app.i18n.addResources("zh-CN", import_preset.namespace, import_locale.zhCN);
|
|
59
|
-
this.app.i18n.addResources("en-US", import_preset.namespace, import_locale.enUS);
|
|
60
58
|
this.app.db.registerModels({ AuthModel: import_authenticator.AuthModel });
|
|
61
59
|
}
|
|
62
60
|
async load() {
|
|
@@ -83,7 +81,7 @@ class PluginAuthServer extends import_server.Plugin {
|
|
|
83
81
|
}
|
|
84
82
|
this.app.authManager.registerTypes(import_preset.presetAuthType, {
|
|
85
83
|
auth: import_basic_auth.BasicAuth,
|
|
86
|
-
title: "Password"
|
|
84
|
+
title: (0, import_utils.tval)("Password", { ns: import_preset.namespace })
|
|
87
85
|
});
|
|
88
86
|
Object.entries(import_auth.default).forEach(
|
|
89
87
|
([action, handler]) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-auth",
|
|
3
|
-
"version": "1.0.1-alpha.
|
|
3
|
+
"version": "1.0.1-alpha.2",
|
|
4
4
|
"main": "./dist/server/index.js",
|
|
5
5
|
"homepage": "https://docs.nocobase.com/handbook/auth",
|
|
6
6
|
"homepage.zh-CN": "https://docs-cn.nocobase.com/handbook/auth",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"displayName.zh-CN": "用户认证",
|
|
27
27
|
"description": "User authentication management, including password, SMS, and support for Single Sign-On (SSO) protocols, with extensibility.",
|
|
28
28
|
"description.zh-CN": "用户认证管理,包括基础的密码认证、短信认证、SSO 协议的认证等,可扩展。",
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "fc5a8e3c812516f787cb22d3d198f058f45b1963",
|
|
30
30
|
"keywords": [
|
|
31
31
|
"Authentication"
|
|
32
32
|
]
|