@nocobase/plugin-auth 1.4.0-alpha.0 → 1.4.0-alpha.10

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/README.md CHANGED
@@ -1,117 +1,30 @@
1
- # Auth
1
+ # NocoBase
2
2
 
3
- 提供基础认证功能和扩展认证器管理功能。
3
+ <video width="100%" controls>
4
+ <source src="https://static-docs.nocobase.com/NocoBase0510.mp4" type="video/mp4">
5
+ </video>
4
6
 
5
- ## 使用方法
6
7
 
7
- ### 认证器管理
8
- 页面:系统设置 - 认证
8
+ ## What is NocoBase
9
9
 
10
+ NocoBase is a scalability-first, open-source no-code development platform.
11
+ Instead of investing years of time and millions of dollars in research and development, deploy NocoBase in a few minutes and you'll have a private, controllable, and extremely scalable no-code development platform!
10
12
 
11
- <img src="https://s2.loli.net/2023/05/15/NdriQZvBuE6hGRS.png" width="800px" />
13
+ Homepage:
14
+ https://www.nocobase.com/
12
15
 
13
- #### 内置认证器
14
- - 名称:basic
15
- - 认证类型:邮箱密码登录
16
+ Online Demo:
17
+ https://demo.nocobase.com/new
16
18
 
17
- <img src="https://s2.loli.net/2023/05/15/HC4gtx9fQPrqvac.png" width="300px" />
19
+ Documents:
20
+ https://docs.nocobase.com/
18
21
 
19
- <img src="https://s2.loli.net/2023/05/15/fcLqypdhOxnksbg.png" width="300px" />
22
+ Commericial license & plugins:
23
+ https://www.nocobase.com/en/commercial
20
24
 
21
- #### 增加认证器
22
- Add new - 选择认证类型
25
+ License agreement:
26
+ https://www.nocobase.com/en/agreement
23
27
 
24
- <img src="https://s2.loli.net/2023/05/15/CR7UTDt2WzbEfgs.png" width="300px" />
25
28
 
26
- #### 启用/禁用
27
- Actions - Edit - 勾选/取消Enabled
28
-
29
- <img src="https://s2.loli.net/2023/05/15/2utpSHly9fzCKX5.png" width="400px" />
30
-
31
- #### 配置认证器
32
- Actions - Edit
33
-
34
- ## 开发一个登录插件
35
- ### 接口
36
- Nocobase内核提供了扩展登录方式的接入和管理。扩展登录插件的核心逻辑处理,需要继承内核的`Auth`类,并对相应的标准接口进行实现。
37
- 参考`core/auth/auth.ts`
38
-
39
- ```TypeScript
40
- import { Auth } from '@nocobase/auth';
41
-
42
- class CustomAuth extends Auth {
43
- set user(user) {}
44
- get user() {}
45
-
46
- async check() {}
47
- async signIn() {}
48
- }
49
- ```
50
-
51
- 多数情况下,扩展的用户登录方式也将沿用现有的jwt逻辑来生成用户访问API的凭证,插件也可以继承`BaseAuth`类以便复用部分逻辑代码,如`check`, `signIn`接口。
52
-
53
- ```TypeScript
54
- import { BaseAuth } from '@nocobase/auth';
55
-
56
- class CustomAuth extends BaseAuth {
57
- constructor(config: AuthConfig) {
58
- const userCollection = config.ctx.db.getCollection('users');
59
- super({ ...config, userCollection });
60
- }
61
-
62
- async validate() {}
63
- }
64
- ```
65
-
66
- ### 用户数据
67
-
68
- `@nocobase/plugin-auth`插件提供了`usersAuthenticators`表来建立users和authenticators,即用户和认证方式的关联。
69
- 通常情况下,扩展登录方式用`users`和`usersAuthenticators`来存储相应的用户数据即可,特殊情况下才需要自己新增Collection.
70
- `users`存储的是最基础的用户数据,邮箱、昵称和密码。
71
- `usersAuthenticators`存储扩展登录方式数据
72
- - uuid: 该种认证方式的用户唯一标识,如手机号、微信openid等
73
- - meta: JSON字段,其他需要保存的信息
74
- - userId: 用户id
75
- - authenticator:认证器名字
76
-
77
- 对于用户操作,`Authenticator`模型也提供了几个封装的方法,可以在`CustomAuth`类中通过`this.authenticator[方法名]`使用:
78
- - `findUser(uuid: string): UserModel` - 查询用户
79
- - `newUser(uuid: string, values?: any): UserModel` - 创建新用户
80
- - `findOrCreateUser(uuid: string, userValues?: any): UserModel` - 查找或创建新用户
81
-
82
- ### 注册
83
- 扩展的登录方式需要向内核注册。
84
- ```TypeScript
85
- async load() {
86
- this.app.authManager.registerTypes('custom-auth-type', {
87
- auth: CustomAuth,
88
- });
89
- }
90
- ```
91
-
92
- ### 客户端API
93
- #### OptionsComponentProvider
94
- 可供用户配置的认证器配置项
95
- - authType 认证方式
96
- - component 配置组件
97
- ```TypeScript
98
- <OptionsComponentProvider authType="custom-auth-type" component={Options} />
99
- ```
100
-
101
- `Options`组件使用的值是`authenticator`的`options`字段,如果有需要暴露在前端的配置,应该放在`options.public`字段中。`authenticators:publicList`接口会返回`options.public`字段的值。
102
-
103
- #### SigninPageProvider
104
- 自定义登录页界面
105
- - authType 认证方式
106
- - tabTitle 登录页tab标题
107
- - component 登录页组件
108
-
109
- #### SignupPageProvider
110
- 自定义注册页界面
111
- - authType 认证方式
112
- - component 注册页组件
113
-
114
- #### SigninPageExtensionProvider
115
- 自定义登录页下方的扩展内容
116
- - authType 认证方式
117
- - component 扩展组件
29
+ ## Contact Us:
30
+ hello@nocobase.com
@@ -7,25 +7,4 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
- (function(a,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("@nocobase/client"),require("@nocobase/utils/client"),require("react/jsx-runtime"),require("react"),require("react-i18next"),require("react-router-dom"),require("@formily/react"),require("@emotion/css"),require("antd"),require("@formily/shared"),require("@ant-design/icons")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","@nocobase/utils/client","react/jsx-runtime","react","react-i18next","react-router-dom","@formily/react","@emotion/css","antd","@formily/shared","@ant-design/icons"],e):(a=typeof globalThis!="undefined"?globalThis:a||self,e(a["@nocobase/plugin-auth"]={},a["@nocobase/client"],a["@nocobase/utils"],a.jsxRuntime,a.react,a["react-i18next"],a["react-router-dom"],a["@formily/react"],a["@emotion/css"],a.antd,a["@formily/shared"],a["@ant-design/icons"]))})(this,function(a,e,u,i,l,g,x,h,y,d,U,k){"use strict";var ue=Object.defineProperty,le=Object.defineProperties;var me=Object.getOwnPropertyDescriptors;var L=Object.getOwnPropertySymbols;var de=Object.prototype.hasOwnProperty,ye=Object.prototype.propertyIsEnumerable;var I=(a,e,u)=>e in a?ue(a,e,{enumerable:!0,configurable:!0,writable:!0,value:u}):a[e]=u,C=(a,e)=>{for(var u in e||(e={}))de.call(e,u)&&I(a,u,e[u]);if(L)for(var u of L(e))ye.call(e,u)&&I(a,u,e[u]);return a},T=(a,e)=>le(a,me(e));var j=(a,e,u)=>(I(a,typeof e!="symbol"?e+"":e,u),u);var v=(a,e,u)=>new Promise((i,l)=>{var g=y=>{try{h(u.next(y))}catch(d){l(d)}},x=y=>{try{h(u.throw(y))}catch(d){l(d)}},h=y=>y.done?i(y.value):Promise.resolve(y.value).then(g,x);h((u=u.apply(a,e)).next())});const B="Email/Password",O=t=>{const n=e.useLocationSearch(),o=e.useApp();return l.useEffect(()=>{const r=new URLSearchParams(n),s=r.get("authenticator"),c=r.get("token");c&&(o.apiClient.auth.setToken(c),o.apiClient.auth.setAuthenticator(s))}),i.jsx(i.Fragment,{children:t.children})},b="auth";function A(){return g.useTranslation([b,"client"],{nsMode:"fallback"})}const S=l.createContext([]);S.displayName="AuthenticatorsContext";const F=t=>l.useContext(S).find(o=>o.name===t),D=({children:t})=>{const n=e.useAPIClient(),{data:o=[],error:r,loading:s}=e.useRequest(()=>n.resource("authenticators").publicList().then(c=>{var p;return((p=c==null?void 0:c.data)==null?void 0:p.data)||[]}));if(s)return i.jsx("div",{style:{textAlign:"center",marginTop:20},children:i.jsx(d.Spin,{})});if(r)throw r;return i.jsx(S.Provider,{value:o,children:t})};function q(){var n;const{data:t}=e.useSystemSettings();return i.jsxs("div",{style:{maxWidth:320,margin:"0 auto",paddingTop:"20vh"},children:[i.jsx("div",{style:{position:"fixed",top:"2em",right:"2em"},children:i.jsx(e.SwitchLanguage,{})}),i.jsx("h1",{style:{textAlign:"center"},children:i.jsx(e.ReadPretty.TextArea,{value:(n=t==null?void 0:t.data)==null?void 0:n.title})}),i.jsx(D,{children:i.jsx(x.Outlet,{})}),i.jsx("div",{className:y.css`
11
- position: absolute;
12
- bottom: 24px;
13
- width: 100%;
14
- left: 0;
15
- text-align: center;
16
- `,children:i.jsx(e.PoweredBy,{})})]})}const V=()=>{var r;const n=e.usePlugin(f).authTypes.getEntities(),o={};for(const[s,c]of n)(r=c.components)!=null&&r.SignInForm&&(o[s]=c.components.SignInForm);return o},_=(t=[])=>{var c;const o=e.usePlugin(f).authTypes.getEntities(),r={};for(const[p,m]of o)(c=m.components)!=null&&c.SignInButton&&(r[p]=m.components.SignInButton);const s=Object.keys(r);return t.filter(p=>s.includes(p.authType)).map((p,m)=>l.createElement(r[p.authType],{key:m,authenticator:p}))},M=()=>{const{t}=A();e.useCurrentDocumentTitle("Signin"),e.useViewport();const n=V(),o=l.useContext(S),r=_(o);if(!o.length)return i.jsx("div",{style:{color:"#ccc"},children:t("No authentication methods available.")});const s=o.map(c=>{const p=n[c.authType];if(!p)return;const m=`${t("Sign-in")} (${h.Schema.compile(c.authTypeTitle||c.authType,{t})})`;return C({component:l.createElement(p,{authenticator:c}),tabTitle:c.title||m},c)}).filter(c=>c);return i.jsxs(d.Space,{direction:"vertical",className:y.css`
17
- display: flex;
18
- `,children:[s.length>1?i.jsx(d.Tabs,{items:s.map(c=>({label:c.tabTitle,key:c.name,children:c.component}))}):s.length?i.jsx("div",{children:s[0].component}):i.jsx(i.Fragment,{}),i.jsx(d.Space,{direction:"vertical",className:y.css`
19
- display: flex;
20
- `,children:r})]})},z=l.createContext({});z.displayName="SignupPageContext";const N=()=>{var r;const n=e.usePlugin(f).authTypes.getEntities(),o={};for(const[s,c]of n)(r=c.components)!=null&&r.SignUpForm&&(o[s]=c.components.SignUpForm);return o},Z=()=>{e.useViewport(),e.useCurrentDocumentTitle("Signup");const t=N(),[n]=x.useSearchParams(),o=n.get("name"),r=F(o),{authType:s}=r||{};return t[s]?l.createElement(t[s],{authenticatorName:o}):i.jsx(x.Navigate,{to:"/not-found",replace:!0})};function K(t="/admin"){const n=x.useNavigate(),[o]=x.useSearchParams();return l.useCallback(()=>{n(o.get("redirect")||"/admin",{replace:!0})},[n,o])}const $=t=>{const n=h.useForm(),o=e.useAPIClient(),r=K(),{refreshAsync:s}=e.useCurrentUserContext();return{run(){return v(this,null,function*(){yield n.submit(),yield o.auth.signIn(n.values,t),yield s(),r()})}}},W={type:"object",name:"passwordForm","x-component":"FormV2",properties:{account:{type:"string","x-component":"Input","x-validator":`{{(value) => {
21
- if (!value) {
22
- return t("Please enter your username or email");
23
- }
24
- if (value.includes('@')) {
25
- if (!/^[\\w-]+(\\.[\\w-]+)*@[\\w-]+(\\.[\\w-]+)+$/.test(value)) {
26
- return t("Please enter a valid email");
27
- }
28
- } else {
29
- return /^[^@.<>"'/]{1,50}$/.test(value) || t("Please enter a valid username");
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=t=>{const{t:n}=A(),o=t.authenticator,{authType:r,name:s,options:c}=o,m=!!(N()[r]&&(c!=null&&c.allowSignUp)),ce=`/signup?name=${s}`,pe=()=>$(s);return i.jsx(e.SchemaComponent,{schema:W,scope:{useBasicSignIn:pe,allowSignUp:m,signUpLink:ce,t:n}})},H=t=>{const n=x.useNavigate(),o=h.useForm(),r=e.useAPIClient(),{t:s}=g.useTranslation();return{run(){return v(this,null,function*(){var p;yield o.submit(),yield r.auth.signUp(o.values,t==null?void 0:t.authenticator),d.message.success(((p=t==null?void 0:t.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:t})=>{const{t:n}=A(),o=()=>H({authenticator:t}),r=F(t),{options:s}=r;return s!=null&&s.allowSignUp?i.jsx(e.SchemaComponent,{schema:J,scope:{useBasicSignUp:o,t:n}}):i.jsx(x.Navigate,{to:"/not-found",replace:!0})},X=()=>{const{t}=A();return i.jsx(e.SchemaComponent,{scope:{t},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:t}=l.useContext(P);return t},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":t=>/^[a-zA-Z0-9_-]+$/.test(t)?"":e.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(t){const n=e.useActionContext(),{type:o}=l.useContext(w);return e.useRequest(()=>Promise.resolve({data:{name:`s_${U.uid()}`,authType:o}}),T(C({},t),{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 t=e.useAPIClient(),{t:n}=g.useTranslation();return{move(r,s){return v(this,null,function*(){yield t.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=t=>{const n=e.useRecord(),o=e.useRequest(()=>Promise.resolve({data:C({},n.options)}),T(C({},t),{manual:!0})),{run:r}=o,s=e.useActionContext();return l.useEffect(()=>{s.visible&&r()},[s.visible,r]),o},oe=t=>{var r;const o=e.usePlugin(f).authTypes.get(t);return(r=o==null?void 0:o.components)==null?void 0:r.AdminSettingsForm},ne=h.observer(()=>{const t=h.useForm(),n=e.useRecord(),o=oe(t.values.authType||n.authType);return o?i.jsx(o,{}):null},{displayName:"Options"}),se=()=>{const{setVisible:t}=e.useActionContext();return{run(){return v(this,null,function*(){t(!1)})}}},re=()=>{const{t}=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 i.jsx(e.ActionContextProvider,{value:{visible:n,setVisible:o},children:i.jsxs(w.Provider,{value:{type:r},children:[i.jsx(d.Dropdown,{menu:{items:p},children:i.jsxs(d.Button,{icon:i.jsx(k.PlusOutlined,{}),type:"primary",children:[t("Add new")," ",i.jsx(k.DownOutlined,{})]})}),i.jsx(e.SchemaComponent,{scope:{useCloseAction:se,types:c,setType:s},schema:R})]})})},ie=()=>(e.useAsyncData(),!1),ae=()=>{const{t}=A(),[n,o]=l.useState([]),r=e.useAPIClient();return e.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:h.Schema.compile(m.title||m.name,{t}),value:m.name}))}),{onSuccess:s=>{o(s)}}),i.jsx(d.Card,{bordered:!1,children:i.jsx(P.Provider,{value:{types:n},children:i.jsx(e.SchemaComponent,{schema:ee,components:{AddNew:re,Options:ne},scope:{types:n,useValuesFromOptions:te,useCanNotDelete:ie,t}})})})};class f extends e.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:ae,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:q,SignInPage:M,SignUpPage:Z}),this.app.providers.unshift([O,{}]),this.registerType(B,{components:{SignInForm:G,SignUpForm:Q,AdminSettingsForm:X}})})}}a.AuthLayout=q,a.AuthenticatorsContext=S,a.AuthenticatorsContextProvider=D,a.PluginAuthClient=f,a.default=f,a.useAuthenticator=F,a.useSignIn=$,Object.defineProperties(a,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
10
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@nocobase/client"),require("@ant-design/icons"),require("@formily/react"),require("@nocobase/utils"),require("@formily/antd-v5"),require("@emotion/css"),require("react-i18next"),require("react"),require("@formily/shared"),require("antd"),require("react-router-dom")):"function"==typeof define&&define.amd?define("@nocobase/plugin-auth",["@nocobase/client","@ant-design/icons","@formily/react","@nocobase/utils","@formily/antd-v5","@emotion/css","react-i18next","react","@formily/shared","antd","react-router-dom"],t):"object"==typeof exports?exports["@nocobase/plugin-auth"]=t(require("@nocobase/client"),require("@ant-design/icons"),require("@formily/react"),require("@nocobase/utils"),require("@formily/antd-v5"),require("@emotion/css"),require("react-i18next"),require("react"),require("@formily/shared"),require("antd"),require("react-router-dom")):e["@nocobase/plugin-auth"]=t(e["@nocobase/client"],e["@ant-design/icons"],e["@formily/react"],e["@nocobase/utils"],e["@formily/antd-v5"],e["@emotion/css"],e["react-i18next"],e.react,e["@formily/shared"],e.antd,e["react-router-dom"])}(self,function(e,t,n,r,o,i,a,c,u,l,s){return function(){"use strict";var p={482:function(e){e.exports=t},964:function(e){e.exports=i},632:function(e){e.exports=o},505:function(e){e.exports=n},875:function(e){e.exports=u},772:function(t){t.exports=e},473:function(e){e.exports=r},721:function(e){e.exports=l},156:function(e){e.exports=c},238:function(e){e.exports=a},128:function(e){e.exports=s}},f={};function m(e){var t=f[e];if(void 0!==t)return t.exports;var n=f[e]={exports:{}};return p[e](n,n.exports,m),n.exports}m.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return m.d(t,{a:t}),t},m.d=function(e,t){for(var n in t)m.o(t,n)&&!m.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},m.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},m.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var y={};m.r(y),m.d(y,{AuthLayout:function(){return k},useSignIn:function(){return H},PluginAuthClient:function(){return eE},AuthenticatorsContextProvider:function(){return I},default:function(){return eF},AuthenticatorsContext:function(){return T},useAuthenticator:function(){return E}});var d=m("772"),b=m("473"),v=m("156"),h=m.n(v),x=function(e){var t=(0,d.useLocationSearch)(),n=(0,d.useApp)();return(0,v.useEffect)(function(){var e=new URLSearchParams(t),r=e.get("authenticator"),o=e.get("token");o&&(n.apiClient.auth.setToken(o),n.apiClient.auth.setAuthenticator(r))}),h().createElement(h().Fragment,null,e.children)},g=m("238"),w="auth";function O(){return(0,g.useTranslation)([w,"client"],{nsMode:"fallback"})}function S(e){return d.i18n.t(e,{ns:[w,"client"],nsMode:"fallback"})}var P=m("128"),A=m("505"),j=m("964"),C=m("721"),T=(0,v.createContext)([]);T.displayName="AuthenticatorsContext";var E=function(e){return(0,v.useContext)(T).find(function(t){return t.name===e})};function F(){var e,t,n=(e=["\n position: absolute;\n bottom: 24px;\n width: 100%;\n left: 0;\n text-align: center;\n "],!t&&(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return F=function(){return n},n}var I=function(e){var t=e.children,n=(0,d.useAPIClient)(),r=(0,d.useRequest)(function(){return n.resource("authenticators").publicList().then(function(e){var t;return(null==e?void 0:null===(t=e.data)||void 0===t?void 0:t.data)||[]})}),o=r.data,i=r.error;if(r.loading)return h().createElement("div",{style:{textAlign:"center",marginTop:20}},h().createElement(C.Spin,null));if(i)throw i;return h().createElement(T.Provider,{value:void 0===o?[]:o},t)};function k(){var e,t=(0,d.useSystemSettings)().data;return h().createElement("div",{style:{maxWidth:320,margin:"0 auto",paddingTop:"20vh"}},h().createElement("div",{style:{position:"fixed",top:"2em",right:"2em"}},h().createElement(d.SwitchLanguage,null)),h().createElement("h1",{style:{textAlign:"center"}},h().createElement(d.ReadPretty.TextArea,{value:null==t?void 0:null===(e=t.data)||void 0===e?void 0:e.title})),h().createElement(I,null,h().createElement(P.Outlet,null)),h().createElement("div",{className:(0,j.css)(F())},h().createElement(d.PoweredBy,null)))}function D(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function q(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,c=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){c=!0,r=e}finally{try{!a&&null!=o.return&&o.return()}finally{if(c)throw r}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return D(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return D(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function U(e,t){return!t&&(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function N(){var e=U(["\n display: flex;\n "]);return N=function(){return e},e}function _(){var e=U(["\n display: flex;\n "]);return _=function(){return e},e}var R=function(){var e=(0,d.usePlugin)(eF).authTypes.getEntities(),t={},n=!0,r=!1,o=void 0;try{for(var i,a=e[Symbol.iterator]();!(n=(i=a.next()).done);n=!0){var c,u=q(i.value,2),l=u[0],s=u[1];(null===(c=s.components)||void 0===c?void 0:c.SignInForm)&&(t[l]=s.components.SignInForm)}}catch(e){r=!0,o=e}finally{try{!n&&null!=a.return&&a.return()}finally{if(r)throw o}}return t},L=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=(0,d.usePlugin)(eF).authTypes.getEntities(),n={},r=!0,o=!1,i=void 0;try{for(var a,c=t[Symbol.iterator]();!(r=(a=c.next()).done);r=!0){var u,l=q(a.value,2),s=l[0],p=l[1];(null===(u=p.components)||void 0===u?void 0:u.SignInButton)&&(n[s]=p.components.SignInButton)}}catch(e){o=!0,i=e}finally{try{!r&&null!=c.return&&c.return()}finally{if(o)throw i}}var f=Object.keys(n);return e.filter(function(e){return f.includes(e.authType)}).map(function(e,t){return h().createElement(n[e.authType],{key:t,authenticator:e})})},$=function(){var e=O().t;(0,d.useCurrentDocumentTitle)("Signin"),(0,d.useViewport)();var t=R(),n=(0,v.useContext)(T),r=L(n);if(!n.length)return h().createElement("div",{style:{color:"#ccc"}},e("No authentication methods available."));var o=n.map(function(n){var r=t[n.authType];if(!!r){var o="".concat(e("Sign-in")," (").concat(A.Schema.compile(n.authTypeTitle||n.authType,{t:e}),")");return function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r,o,i;r=e,o=t,i=n[t],o in r?Object.defineProperty(r,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[o]=i})}return e}({component:(0,v.createElement)(r,{authenticator:n}),tabTitle:n.title||o},n)}}).filter(function(e){return e});return h().createElement(C.Space,{direction:"vertical",className:(0,j.css)(N())},o.length>1?h().createElement(C.Tabs,{items:o.map(function(e){return{label:e.tabTitle,key:e.name,children:e.component}})}):o.length?h().createElement("div",null,o[0].component):h().createElement(h().Fragment,null),h().createElement(C.Space,{direction:"vertical",className:(0,j.css)(_())},r))};function B(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function M(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,c=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){c=!0,r=e}finally{try{!a&&null!=o.return&&o.return()}finally{if(c)throw r}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return B(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return B(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(0,v.createContext)({}).displayName="SignupPageContext";var V=function(){var e=(0,d.usePlugin)(eF).authTypes.getEntities(),t={},n=!0,r=!1,o=void 0;try{for(var i,a=e[Symbol.iterator]();!(n=(i=a.next()).done);n=!0){var c,u=M(i.value,2),l=u[0],s=u[1];(null===(c=s.components)||void 0===c?void 0:c.SignUpForm)&&(t[l]=s.components.SignUpForm)}}catch(e){r=!0,o=e}finally{try{!n&&null!=a.return&&a.return()}finally{if(r)throw o}}return t},z=function(){(0,d.useViewport)(),(0,d.useCurrentDocumentTitle)("Signup");var e=V(),t=M((0,P.useSearchParams)(),1)[0].get("name"),n=(E(t)||{}).authType;return e[n]?(0,v.createElement)(e[n],{authenticatorName:t}):h().createElement(P.Navigate,{to:"/not-found",replace:!0})};function G(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Z(e,t,n,r,o,i,a){try{var c=e[i](a),u=c.value}catch(e){n(e);return}c.done?t(u):Promise.resolve(u).then(r,o)}var H=function(e){var t=(0,A.useForm)(),n=(0,d.useAPIClient)(),r=function(){arguments.length>0&&void 0!==arguments[0]&&arguments[0];var e,t,n=(0,P.useNavigate)();var r=(e=(0,P.useSearchParams)(),t=1,function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,c=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){c=!0,r=e}finally{try{!a&&null!=o.return&&o.return()}finally{if(c)throw r}}return i}}(e,1)||function(e,t){if(e){if("string"==typeof e)return G(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return G(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0];return(0,v.useCallback)(function(){n(r.get("redirect")||"/admin",{replace:!0})},[n,r])}(),o=(0,d.useCurrentUserContext)().refreshAsync;return{run:function(){var i;return(i=function(){return function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}}(this,function(i){switch(i.label){case 0:return[4,t.submit()];case 1:return i.sent(),[4,n.auth.signIn(t.values,e)];case 2:return i.sent(),[4,o()];case 3:return i.sent(),r(),[2]}})},function(){var e=this,t=arguments;return new Promise(function(n,r){var o=i.apply(e,t);function a(e){Z(o,n,r,a,c,"next",e)}function c(e){Z(o,n,r,a,c,"throw",e)}a(void 0)})})()}}},K={type:"object",name:"passwordForm","x-component":"FormV2",properties:{account:{type:"string","x-component":"Input","x-validator":'{{(value) => {\n if (!value) {\n return t("Please enter your username or email");\n }\n if (value.includes(\'@\')) {\n if (!/^[\\w-]+(\\.[\\w-]+)*@[\\w-]+(\\.[\\w-]+)+$/.test(value)) {\n return t("Please enter a valid email");\n }\n } else {\n return /^[^@.<>"\'/]{1,50}$/.test(value) || t("Please enter a valid username");\n }\n }}}',"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 }}"}}},W=function(e){var t=O().t,n=e.authenticator,r=n.authType,o=n.name,i=n.options,a=!!V()[r]&&null!=i&&!!i.allowSignUp,c="/signup?name=".concat(o);return h().createElement(d.SchemaComponent,{schema:K,scope:{useBasicSignIn:function(){return H(o)},allowSignUp:a,signUpLink:c,t:t}})},J=m("875");function Q(e,t,n,r,o,i,a){try{var c=e[i](a),u=c.value}catch(e){n(e);return}c.done?t(u):Promise.resolve(u).then(r,o)}var X={username:{type:"string","x-component":"Input","x-validator":{username:!0},"x-decorator":"FormItem","x-component-props":{placeholder:'{{t("Username")}}',style:{}}},email:{type:"string","x-component":"Input","x-validator":"email","x-decorator":"FormItem","x-component-props":{placeholder:'{{t("Email")}}',style:{}}}},Y=function(e){var t=(0,P.useNavigate)(),n=(0,A.useForm)(),r=(0,d.useAPIClient)(),o=(0,g.useTranslation)().t;return{run:function(){var i;return(i=function(){var i;return function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}}(this,function(a){switch(a.label){case 0:return[4,n.submit()];case 1:return a.sent(),[4,r.auth.signUp(n.values,null==e?void 0:e.authenticator)];case 2:return a.sent(),C.message.success((null==e?void 0:null===(i=e.message)||void 0===i?void 0:i.success)||o("Sign up successfully, and automatically jump to the sign in page")),setTimeout(function(){t("/signin")},2e3),[2]}})},function(){var e=this,t=arguments;return new Promise(function(n,r){var o=i.apply(e,t);function a(e){Q(o,n,r,a,c,"next",e)}function c(e){Q(o,n,r,a,c,"throw",e)}a(void 0)})})()}}},ee=function(e){var t,n;return{type:"object",name:(0,J.uid)(),"x-component":"FormV2",properties:(t=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r,o,i;r=e,o=t,i=n[t],o in r?Object.defineProperty(r,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[o]=i})}return e}({},e),n=(n={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")}}'}}}},n),Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}),t)}},et=function(e){var t=e.authenticatorName,n=O().t,r=E(t).options,o=r.signupForm;!((null==o?void 0:o.length)&&o.some(function(e){return e.show&&e.required}))&&(o=[{field:"username",show:!0,required:!0}]);var i=(0,v.useMemo)(function(){return o.filter(function(e){return e.show}).reduce(function(e,t){var n=t.field;if(X[n])return e[n]=X[n],t.required&&(e[n].required=!0),e},{})},[o]);if(!(null==r?void 0:r.allowSignUp))return h().createElement(P.Navigate,{to:"/not-found",replace:!0});var a=ee(i);return h().createElement(d.SchemaComponent,{schema:a,scope:{useBasicSignUp:function(){return Y({authenticator:t})},t:n}})},en=m("632"),er=function(){var e=O().t;return h().createElement(d.SchemaComponent,{scope:{t:e},components:{Alert:C.Alert,FormTab:en.FormTab,ArrayTable:en.ArrayTable},schema:{type:"object",properties:{notice:{type:"void","x-decorator":"FormItem","x-component":"Alert","x-component-props":{showIcon:!0,message:'{{t("The authentication allows users to sign in via username or email.")}}'}},public:{type:"object",properties:{collapse:{type:"void","x-component":"FormTab",properties:{basic:{type:"void","x-component":"FormTab.TabPane","x-component-props":{tab:S("Sign up settings")},properties:{allowSignUp:{"x-decorator":"FormItem",type:"boolean",title:'{{t("Allow to sign up")}}',"x-component":"Checkbox",default:!0},signupForm:{title:'{{t("Sign up form")}}',type:"array","x-decorator":"FormItem","x-component":"ArrayTable","x-component-props":{bordered:!1},"x-validator":"{{ (value) => {\n const field = value?.filter((item) => item.show && item.required);\n if (!field?.length) {\n return t('At least one field is required');\n }\n} }}",default:[{field:"username",show:!0,required:!0},{field:"email",show:!1,required:!1}],items:{type:"object","x-decorator":"ArrayItems.Item",properties:{column0:{type:"void","x-component":"ArrayTable.Column","x-component-props":{width:20,align:"center"},properties:{sort:{type:"void","x-component":"ArrayTable.SortHandle"}}},column1:{type:"void","x-component":"ArrayTable.Column","x-component-props":{width:100,title:S("Field")},properties:{field:{type:"string","x-decorator":"FormItem","x-component":"Select",enum:[{label:S("Username"),value:"username"},{label:S("Email"),value:"email"}],"x-read-pretty":!0}}},column2:{type:"void","x-component":"ArrayTable.Column","x-component-props":{width:80,title:S("Show")},properties:{show:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox"}}},column3:{type:"void","x-component":"ArrayTable.Column","x-component-props":{width:80,title:S("Required")},properties:{required:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox"}}}}}}}}}}}}}}})},eo=(0,v.createContext)({type:""});eo.displayName="AuthTypeContext";var ei=(0,v.createContext)({types:[]});ei.displayName="AuthTypesContext";function ea(e,t,n,r,o,i,a){try{var c=e[i](a),u=c.value}catch(e){n(e);return}c.done?t(u):Promise.resolve(u).then(r,o)}var ec={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":function(e){return/^[a-zA-Z0-9_-]+$/.test(e)?"":d.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"}}]},eu={type:"object",properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues:function(e){var t,n,r=(0,d.useActionContext)(),o=(0,v.useContext)(eo).type;return(0,d.useRequest)(function(){return Promise.resolve({data:{name:"s_".concat((0,J.uid)()),authType:o}})},(t=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r,o,i;r=e,o=t,i=n[t],o in r?Object.defineProperty(r,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[o]=i})}return e}({},e),n=(n={refreshDeps:[r.visible]},n),Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}),t))}},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 }}"}}}}}}}},el={type:"void",name:"authenticators","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:ec,resourceName:"authenticators",dragSort:!0,request:{resource:"authenticators",action:"list",params:{pageSize:50,sort:"sort",appends:[]}}},"x-component":"CollectionProvider_deprecated","x-component-props":{collection:ec},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:function(){var e=(0,d.useAPIClient)(),t=(0,g.useTranslation)().t;return{move:function(n,r){var o;return(o=function(){return function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}}(this,function(o){switch(o.label){case 0:return[4,e.resource("authenticators").move({sourceId:n.id,targetId:r.id})];case 1:return o.sent(),C.message.success(t("Saved successfully"),.2),[2]}})},function(){var e=this,t=arguments;return new Promise(function(n,r){var i=o.apply(e,t);function a(e){ea(i,n,r,a,c,"next",e)}function c(e){ea(i,n,r,a,c,"throw",e)}a(void 0)})})()}}}},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() }}"}}}}}}}}},es=m("482");function ep(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r,o,i;r=e,o=t,i=n[t],o in r?Object.defineProperty(r,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[o]=i})}return e}var ef=function(e){var t,n,r=(0,d.useRecord)();var o=(0,d.useRequest)(function(){return Promise.resolve({data:ep({},r.options)})},(t=ep({},e),n=(n={manual:!0},n),Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}),t)),i=o.run,a=(0,d.useActionContext)();return(0,v.useEffect)(function(){a.visible&&i()},[a.visible,i]),o},em=function(e){var t,n=(0,d.usePlugin)(eF).authTypes.get(e);return null==n?void 0:null===(t=n.components)||void 0===t?void 0:t.AdminSettingsForm},ey=(0,A.observer)(function(){var e=(0,A.useForm)(),t=(0,d.useRecord)(),n=em(e.values.authType||t.authType);return n?h().createElement(n,null):null},{displayName:"Options"});function ed(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function eb(e,t,n,r,o,i,a){try{var c=e[i](a),u=c.value}catch(e){n(e);return}c.done?t(u):Promise.resolve(u).then(r,o)}function ev(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,c=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){c=!0,r=e}finally{try{!a&&null!=o.return&&o.return()}finally{if(c)throw r}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return ed(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ed(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var eh=function(){var e=(0,d.useActionContext)().setVisible;return{run:function(){var t;return(t=function(){return function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}}(this,function(t){return e(!1),[2]})},function(){var e=this,n=arguments;return new Promise(function(r,o){var i=t.apply(e,n);function a(e){eb(i,r,o,a,c,"next",e)}function c(e){eb(i,r,o,a,c,"throw",e)}a(void 0)})})()}}},ex=function(){var e=(0,g.useTranslation)().t,t=ev((0,v.useState)(!1),2),n=t[0],r=t[1],o=ev((0,v.useState)(""),2),i=o[0],a=o[1],c=(0,v.useContext)(ei).types,u=c.map(function(e){var t,n;return t=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r,o,i;r=e,o=t,i=n[t],o in r?Object.defineProperty(r,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[o]=i})}return e}({},e),n=(n={onClick:function(){r(!0),a(e.value)}},n),Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}),t});return h().createElement(d.ActionContextProvider,{value:{visible:n,setVisible:r}},h().createElement(eo.Provider,{value:{type:i}},h().createElement(C.Dropdown,{menu:{items:u}},h().createElement(C.Button,{icon:h().createElement(es.PlusOutlined,null),type:"primary"},e("Add new")," ",h().createElement(es.DownOutlined,null))),h().createElement(d.SchemaComponent,{scope:{useCloseAction:eh,types:c,setType:a},schema:eu})))},eg=function(){return(0,d.useAsyncData)().data,!1},ew=function(){var e=O().t,t=ev((0,v.useState)([]),2),n=t[0],r=t[1],o=(0,d.useAPIClient)();return(0,d.useRequest)(function(){return o.resource("authenticators").listTypes().then(function(t){var n;return((null==t?void 0:null===(n=t.data)||void 0===n?void 0:n.data)||[]).map(function(t){return{key:t.name,label:A.Schema.compile(t.title||t.name,{t:e}),value:t.name}})})},{onSuccess:function(e){r(e)}}),h().createElement(C.Card,{bordered:!1},h().createElement(ei.Provider,{value:{types:n}},h().createElement(d.SchemaComponent,{schema:el,components:{AddNew:ex,Options:ey},scope:{types:n,useValuesFromOptions:ef,useCanNotDelete:eg,t:e}})))};function eO(e,t,n,r,o,i,a){try{var c=e[i](a),u=c.value}catch(e){n(e);return}c.done?t(u):Promise.resolve(u).then(r,o)}function eS(e,t,n){return(eS=eT()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&ej(o,n.prototype),o}).apply(null,arguments)}function eP(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function eA(e){return(eA=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function ej(e,t){return(ej=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function eC(e){var t="function"==typeof Map?new Map:void 0;return(eC=function(e){var n;if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return eS(e,arguments,eA(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),ej(r,e)})(e)}function eT(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(eT=function(){return!!e})()}var eE=function(e){var t,n,r;function o(){var e,t,n,r,i,a,c;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,o),t=this,n=o,r=arguments,n=eA(n),i=e=function(e,t){return t&&("object"===function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t)||"function"==typeof t)?t:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(t,eT()?Reflect.construct(n,r||[],eA(t).constructor):n.apply(t,r)),a="authTypes",c=new b.Registry,a in i?Object.defineProperty(i,a,{value:c,enumerable:!0,configurable:!0,writable:!0}):i[a]=c,e}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&ej(e,t)}(o,e),t=o,n=[{key:"registerType",value:function(e,t){this.authTypes.register(e,t)}},{key:"load",value:function(){var e,t=this;return(e=function(){return function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}}(this,function(e){return t.app.pluginSettingsManager.add(w,{icon:"LoginOutlined",title:'{{t("Authentication", { ns: "'.concat(w,'" })}}'),Component:ew,aclSnippet:"pm.auth.authenticators"}),t.router.add("auth",{Component:"AuthLayout"}),t.router.add("auth.signin",{path:"/signin",Component:"SignInPage"}),t.router.add("auth.signup",{path:"/signup",Component:"SignUpPage"}),t.app.addComponents({AuthLayout:k,SignInPage:$,SignUpPage:z}),t.app.providers.unshift([x,{}]),t.registerType("Email/Password",{components:{SignInForm:W,SignUpForm:et,AdminSettingsForm:er}}),[2]})},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){eO(i,r,o,a,c,"next",e)}function c(e){eO(i,r,o,a,c,"throw",e)}a(void 0)})})()}}],eP(t.prototype,n),o}(eC(d.Plugin)),eF=eE;return y}()});
@@ -8,3 +8,4 @@
8
8
  */
9
9
  export declare const NAMESPACE = "auth";
10
10
  export declare function useAuthTranslation(): import("react-i18next").UseTranslationResponse<("auth" | "client")[], undefined>;
11
+ export declare function lang(key: string): string;
@@ -8,14 +8,15 @@
8
8
  */
9
9
 
10
10
  module.exports = {
11
- "@nocobase/client": "1.4.0-alpha.0",
11
+ "@nocobase/client": "1.4.0-alpha.10",
12
12
  "react": "18.2.0",
13
- "@nocobase/utils": "1.4.0-alpha.0",
14
- "@nocobase/auth": "1.4.0-alpha.0",
15
- "@nocobase/database": "1.4.0-alpha.0",
16
- "@nocobase/cache": "1.4.0-alpha.0",
17
- "@nocobase/server": "1.4.0-alpha.0",
18
- "@nocobase/test": "1.4.0-alpha.0",
13
+ "@nocobase/utils": "1.4.0-alpha.10",
14
+ "@nocobase/auth": "1.4.0-alpha.10",
15
+ "@nocobase/database": "1.4.0-alpha.10",
16
+ "@nocobase/cache": "1.4.0-alpha.10",
17
+ "@nocobase/server": "1.4.0-alpha.10",
18
+ "@nocobase/test": "1.4.0-alpha.10",
19
+ "@formily/antd-v5": "1.1.9",
19
20
  "antd": "5.12.8",
20
21
  "@formily/react": "2.3.0",
21
22
  "react-router-dom": "6.21.0",
@@ -23,5 +24,5 @@ module.exports = {
23
24
  "react-i18next": "11.18.6",
24
25
  "@emotion/css": "11.13.0",
25
26
  "@ant-design/icons": "5.2.6",
26
- "@nocobase/actions": "1.4.0-alpha.0"
27
+ "@nocobase/actions": "1.4.0-alpha.10"
27
28
  };
@@ -23,5 +23,10 @@
23
23
  "No authentication methods available.": "No authentication methods available.",
24
24
  "The password is inconsistent, please re-enter": "The password is inconsistent, please re-enter",
25
25
  "Sign-in": "Sign-in",
26
- "Password": "Password"
26
+ "Password": "Password",
27
+ "The username/email or password is incorrect, please re-enter": "The username/email or password is incorrect, please re-enter",
28
+ "Show": "Show",
29
+ "Sign up settings": "Sign up settings",
30
+ "Sign up form": "Sign up form",
31
+ "At least one field is required": "At least one field is required"
27
32
  }
@@ -23,5 +23,10 @@
23
23
  "No authentication methods available.": "没有可用的认证方式。",
24
24
  "The password is inconsistent, please re-enter": "密码不一致,请重新输入",
25
25
  "Sign-in": "登录",
26
- "Password": "密码"
26
+ "Password": "密码",
27
+ "The username/email or password is incorrect, please re-enter": "用户名/邮箱或密码有误,请重新输入",
28
+ "Show": "显示",
29
+ "Sign up settings": "注册设置",
30
+ "Sign up form": "注册表单",
31
+ "At least one field is required": "至少需要设置一个必填字段"
27
32
  }
@@ -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-11-06T06:24:58.091Z"}
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-11-14T13:58:57.451Z"}
@@ -8,9 +8,6 @@
8
8
  */
9
9
  import { Context, Next } from '@nocobase/actions';
10
10
  declare const _default: {
11
- lostPassword: (ctx: Context, next: Next) => Promise<void>;
12
- resetPassword: (ctx: Context, next: Next) => Promise<void>;
13
- getUserByResetToken: (ctx: Context, next: Next) => Promise<void>;
14
11
  changePassword: (ctx: Context, next: Next) => Promise<void>;
15
12
  };
16
13
  export default _default;
@@ -29,22 +29,51 @@ __export(auth_exports, {
29
29
  default: () => auth_default
30
30
  });
31
31
  module.exports = __toCommonJS(auth_exports);
32
+ var import_preset = require("../../preset");
32
33
  /* istanbul ignore file -- @preserve */
33
34
  var auth_default = {
34
- lostPassword: async (ctx, next) => {
35
- ctx.body = await ctx.auth.lostPassword();
36
- await next();
37
- },
38
- resetPassword: async (ctx, next) => {
39
- ctx.body = await ctx.auth.resetPassword();
40
- await next();
41
- },
42
- getUserByResetToken: async (ctx, next) => {
43
- ctx.body = await ctx.auth.getUserByResetToken();
44
- await next();
45
- },
35
+ // lostPassword: async (ctx: Context, next: Next) => {
36
+ // ctx.body = await ctx.auth.lostPassword();
37
+ // await next();
38
+ // },
39
+ // resetPassword: async (ctx: Context, next: Next) => {
40
+ // ctx.body = await ctx.auth.resetPassword();
41
+ // await next();
42
+ // },
43
+ // getUserByResetToken: async (ctx: Context, next: Next) => {
44
+ // ctx.body = await ctx.auth.getUserByResetToken();
45
+ // await next();
46
+ // },
46
47
  changePassword: async (ctx, next) => {
47
- ctx.body = await ctx.auth.changePassword();
48
+ const {
49
+ values: { oldPassword, newPassword, confirmPassword }
50
+ } = ctx.action.params;
51
+ if (newPassword !== confirmPassword) {
52
+ ctx.throw(400, ctx.t("The password is inconsistent, please re-enter", { ns: import_preset.namespace }));
53
+ }
54
+ const currentUser = ctx.auth.user;
55
+ if (!currentUser) {
56
+ ctx.throw(401);
57
+ }
58
+ let key;
59
+ if (currentUser.username) {
60
+ key = "username";
61
+ } else {
62
+ key = "email";
63
+ }
64
+ const user = await ctx.db.getRepository("users").findOne({
65
+ where: {
66
+ [key]: currentUser[key]
67
+ }
68
+ });
69
+ const pwd = ctx.db.getCollection("users").getField("password");
70
+ const isValid = await pwd.verify(oldPassword, user.password);
71
+ if (!isValid) {
72
+ ctx.throw(401, ctx.t("The password is incorrect, please re-enter", { ns: import_preset.namespace }));
73
+ }
74
+ user.password = newPassword;
75
+ await user.save();
76
+ ctx.body = currentUser;
48
77
  await next();
49
78
  }
50
79
  };
@@ -10,9 +10,9 @@ import { AuthConfig, BaseAuth } from '@nocobase/auth';
10
10
  export declare class BasicAuth extends BaseAuth {
11
11
  constructor(config: AuthConfig);
12
12
  validate(): Promise<any>;
13
+ private verfiySignupParams;
13
14
  signUp(): Promise<any>;
14
15
  lostPassword(): Promise<any>;
15
16
  resetPassword(): Promise<any>;
16
17
  getUserByResetToken(): Promise<any>;
17
- changePassword(): Promise<any>;
18
18
  }
@@ -66,15 +66,39 @@ class BasicAuth extends import_auth.BaseAuth {
66
66
  filter
67
67
  });
68
68
  if (!user) {
69
- ctx.throw(401, ctx.t("The username or email is incorrect, please re-enter", { ns: import_preset.namespace }));
69
+ ctx.throw(401, ctx.t("The username/email or password is incorrect, please re-enter", { ns: import_preset.namespace }));
70
70
  }
71
71
  const field = this.userCollection.getField("password");
72
72
  const valid = await field.verify(password, user.password);
73
73
  if (!valid) {
74
- ctx.throw(401, ctx.t("The password is incorrect, please re-enter", { ns: import_preset.namespace }));
74
+ ctx.throw(401, ctx.t("The username/email or password is incorrect, please re-enter", { ns: import_preset.namespace }));
75
75
  }
76
76
  return user;
77
77
  }
78
+ verfiySignupParams(values) {
79
+ var _a;
80
+ const options = ((_a = this.authenticator.options) == null ? void 0 : _a.public) || {};
81
+ let { signupForm } = options;
82
+ if (!((signupForm == null ? void 0 : signupForm.length) && signupForm.some((item) => item.show && item.required))) {
83
+ signupForm = [{ field: "username", show: true, required: true }];
84
+ }
85
+ const { username, email } = values;
86
+ const usernameSetting = signupForm.find((item) => item.field === "username");
87
+ if (usernameSetting && usernameSetting.show) {
88
+ if (username && !this.validateUsername(username) || usernameSetting.required && !username) {
89
+ throw new Error("Please enter a valid username");
90
+ }
91
+ }
92
+ const emailSetting = signupForm.find((item) => item.field === "email");
93
+ if (emailSetting && emailSetting.show) {
94
+ if (email && !/^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/.test(email)) {
95
+ throw new Error("Please enter a valid email address");
96
+ }
97
+ if (emailSetting.required && !email) {
98
+ throw new Error("Please enter a valid email address");
99
+ }
100
+ }
101
+ }
78
102
  async signUp() {
79
103
  var _a;
80
104
  const ctx = this.ctx;
@@ -84,9 +108,11 @@ class BasicAuth extends import_auth.BaseAuth {
84
108
  }
85
109
  const User = ctx.db.getRepository("users");
86
110
  const { values } = ctx.action.params;
87
- const { username, password, confirm_password } = values;
88
- if (!this.validateUsername(username)) {
89
- ctx.throw(400, ctx.t("Please enter a valid username", { ns: import_preset.namespace }));
111
+ const { username, email, password, confirm_password } = values;
112
+ try {
113
+ this.verfiySignupParams(values);
114
+ } catch (error) {
115
+ ctx.throw(400, this.ctx.t(error.message, { ns: import_preset.namespace }));
90
116
  }
91
117
  if (!password) {
92
118
  ctx.throw(400, ctx.t("Please enter a password", { ns: import_preset.namespace }));
@@ -94,7 +120,7 @@ class BasicAuth extends import_auth.BaseAuth {
94
120
  if (password !== confirm_password) {
95
121
  ctx.throw(400, ctx.t("The password is inconsistent, please re-enter", { ns: import_preset.namespace }));
96
122
  }
97
- const user = await User.create({ values: { username, password } });
123
+ const user = await User.create({ values: { username, email, password } });
98
124
  return user;
99
125
  }
100
126
  /* istanbul ignore next -- @preserve */
@@ -153,38 +179,6 @@ class BasicAuth extends import_auth.BaseAuth {
153
179
  }
154
180
  return user;
155
181
  }
156
- async changePassword() {
157
- const ctx = this.ctx;
158
- const {
159
- values: { oldPassword, newPassword, confirmPassword }
160
- } = ctx.action.params;
161
- if (newPassword !== confirmPassword) {
162
- ctx.throw(400, ctx.t("The password is inconsistent, please re-enter", { ns: import_preset.namespace }));
163
- }
164
- const currentUser = ctx.auth.user;
165
- if (!currentUser) {
166
- ctx.throw(401);
167
- }
168
- let key;
169
- if (currentUser.username) {
170
- key = "username";
171
- } else {
172
- key = "email";
173
- }
174
- const user = await this.userRepository.findOne({
175
- where: {
176
- [key]: currentUser[key]
177
- }
178
- });
179
- const pwd = this.userCollection.getField("password");
180
- const isValid = await pwd.verify(oldPassword, user.password);
181
- if (!isValid) {
182
- ctx.throw(401, ctx.t("The password is incorrect, please re-enter", { ns: import_preset.namespace }));
183
- }
184
- user.password = newPassword;
185
- await user.save();
186
- return currentUser;
187
- }
188
182
  }
189
183
  // Annotate the CommonJS export names for ESM import in node:
190
184
  0 && (module.exports = {
@@ -163,163 +163,6 @@ declare const _default: {
163
163
  };
164
164
  };
165
165
  };
166
- '/auth:lostPassword': {
167
- post: {
168
- description: string;
169
- tags: string[];
170
- security: any[];
171
- requestBody: {
172
- content: {
173
- 'application/json': {
174
- schema: {
175
- type: string;
176
- properties: {
177
- email: {
178
- type: string;
179
- description: string;
180
- };
181
- };
182
- };
183
- };
184
- };
185
- };
186
- responses: {
187
- 200: {
188
- description: string;
189
- content: {
190
- 'application/json': {
191
- schema: {
192
- allOf: ({
193
- $ref: string;
194
- type?: undefined;
195
- properties?: undefined;
196
- } | {
197
- type: string;
198
- properties: {
199
- resetToken: {
200
- type: string;
201
- description: string;
202
- };
203
- };
204
- $ref?: undefined;
205
- })[];
206
- };
207
- };
208
- };
209
- };
210
- 400: {
211
- description: string;
212
- content: {
213
- 'application/json': {
214
- schema: {
215
- $ref: string;
216
- };
217
- };
218
- };
219
- };
220
- 401: {
221
- description: string;
222
- content: {
223
- 'application/json': {
224
- schema: {
225
- $ref: string;
226
- };
227
- };
228
- };
229
- };
230
- };
231
- };
232
- };
233
- '/auth:resetPassword': {
234
- post: {
235
- description: string;
236
- tags: string[];
237
- security: any[];
238
- requestBody: {
239
- content: {
240
- 'application/json': {
241
- schema: {
242
- type: string;
243
- properties: {
244
- email: {
245
- type: string;
246
- description: string;
247
- };
248
- password: {
249
- type: string;
250
- description: string;
251
- };
252
- resetToken: {
253
- type: string;
254
- description: string;
255
- };
256
- };
257
- };
258
- };
259
- };
260
- };
261
- responses: {
262
- 200: {
263
- description: string;
264
- content: {
265
- 'application/json': {
266
- schema: {
267
- $ref: string;
268
- };
269
- };
270
- };
271
- };
272
- 404: {
273
- description: string;
274
- content: {
275
- 'application/json': {
276
- schema: {
277
- $ref: string;
278
- };
279
- };
280
- };
281
- };
282
- };
283
- };
284
- };
285
- '/auth:getUserByResetToken': {
286
- get: {
287
- description: string;
288
- tags: string[];
289
- security: any[];
290
- parameters: {
291
- name: string;
292
- in: string;
293
- description: string;
294
- required: boolean;
295
- schema: {
296
- type: string;
297
- };
298
- }[];
299
- responses: {
300
- 200: {
301
- description: string;
302
- content: {
303
- 'application/json': {
304
- schema: {
305
- $ref: string;
306
- };
307
- };
308
- };
309
- };
310
- 401: {
311
- description: string;
312
- content: {
313
- 'application/json': {
314
- schema: {
315
- $ref: string;
316
- };
317
- };
318
- };
319
- };
320
- };
321
- };
322
- };
323
166
  '/auth:changePassword': {
324
167
  post: {
325
168
  description: string;
@@ -190,165 +190,165 @@ var swagger_default = {
190
190
  }
191
191
  }
192
192
  },
193
- "/auth:lostPassword": {
194
- post: {
195
- description: "Lost password",
196
- tags: ["Basic auth"],
197
- security: [],
198
- requestBody: {
199
- content: {
200
- "application/json": {
201
- schema: {
202
- type: "object",
203
- properties: {
204
- email: {
205
- type: "string",
206
- description: "\u90AE\u7BB1"
207
- }
208
- }
209
- }
210
- }
211
- }
212
- },
213
- responses: {
214
- 200: {
215
- description: "successful operation",
216
- content: {
217
- "application/json": {
218
- schema: {
219
- allOf: [
220
- {
221
- $ref: "#/components/schemas/user"
222
- },
223
- {
224
- type: "object",
225
- properties: {
226
- resetToken: {
227
- type: "string",
228
- description: "\u91CD\u7F6E\u5BC6\u7801\u7684token"
229
- }
230
- }
231
- }
232
- ]
233
- }
234
- }
235
- }
236
- },
237
- 400: {
238
- description: "Please fill in your email address",
239
- content: {
240
- "application/json": {
241
- schema: {
242
- $ref: "#/components/schemas/error"
243
- }
244
- }
245
- }
246
- },
247
- 401: {
248
- description: "The email is incorrect, please re-enter",
249
- content: {
250
- "application/json": {
251
- schema: {
252
- $ref: "#/components/schemas/error"
253
- }
254
- }
255
- }
256
- }
257
- }
258
- }
259
- },
260
- "/auth:resetPassword": {
261
- post: {
262
- description: "Reset password",
263
- tags: ["Basic auth"],
264
- security: [],
265
- requestBody: {
266
- content: {
267
- "application/json": {
268
- schema: {
269
- type: "object",
270
- properties: {
271
- email: {
272
- type: "string",
273
- description: "\u90AE\u7BB1"
274
- },
275
- password: {
276
- type: "string",
277
- description: "\u5BC6\u7801"
278
- },
279
- resetToken: {
280
- type: "string",
281
- description: "\u91CD\u7F6E\u5BC6\u7801\u7684token"
282
- }
283
- }
284
- }
285
- }
286
- }
287
- },
288
- responses: {
289
- 200: {
290
- description: "successful operation",
291
- content: {
292
- "application/json": {
293
- schema: {
294
- $ref: "#/components/schemas/user"
295
- }
296
- }
297
- }
298
- },
299
- 404: {
300
- description: "User not found",
301
- content: {
302
- "application/json": {
303
- schema: {
304
- $ref: "#/components/schemas/error"
305
- }
306
- }
307
- }
308
- }
309
- }
310
- }
311
- },
312
- "/auth:getUserByResetToken": {
313
- get: {
314
- description: "Get user by reset token",
315
- tags: ["Basic auth"],
316
- security: [],
317
- parameters: [
318
- {
319
- name: "token",
320
- in: "query",
321
- description: "\u91CD\u7F6E\u5BC6\u7801\u7684token",
322
- required: true,
323
- schema: {
324
- type: "string"
325
- }
326
- }
327
- ],
328
- responses: {
329
- 200: {
330
- description: "ok",
331
- content: {
332
- "application/json": {
333
- schema: {
334
- $ref: "#/components/schemas/user"
335
- }
336
- }
337
- }
338
- },
339
- 401: {
340
- description: "Unauthorized",
341
- content: {
342
- "application/json": {
343
- schema: {
344
- $ref: "#/components/schemas/error"
345
- }
346
- }
347
- }
348
- }
349
- }
350
- }
351
- },
193
+ // '/auth:lostPassword': {
194
+ // post: {
195
+ // description: 'Lost password',
196
+ // tags: ['Basic auth'],
197
+ // security: [],
198
+ // requestBody: {
199
+ // content: {
200
+ // 'application/json': {
201
+ // schema: {
202
+ // type: 'object',
203
+ // properties: {
204
+ // email: {
205
+ // type: 'string',
206
+ // description: '邮箱',
207
+ // },
208
+ // },
209
+ // },
210
+ // },
211
+ // },
212
+ // },
213
+ // responses: {
214
+ // 200: {
215
+ // description: 'successful operation',
216
+ // content: {
217
+ // 'application/json': {
218
+ // schema: {
219
+ // allOf: [
220
+ // {
221
+ // $ref: '#/components/schemas/user',
222
+ // },
223
+ // {
224
+ // type: 'object',
225
+ // properties: {
226
+ // resetToken: {
227
+ // type: 'string',
228
+ // description: '重置密码的token',
229
+ // },
230
+ // },
231
+ // },
232
+ // ],
233
+ // },
234
+ // },
235
+ // },
236
+ // },
237
+ // 400: {
238
+ // description: 'Please fill in your email address',
239
+ // content: {
240
+ // 'application/json': {
241
+ // schema: {
242
+ // $ref: '#/components/schemas/error',
243
+ // },
244
+ // },
245
+ // },
246
+ // },
247
+ // 401: {
248
+ // description: 'The email is incorrect, please re-enter',
249
+ // content: {
250
+ // 'application/json': {
251
+ // schema: {
252
+ // $ref: '#/components/schemas/error',
253
+ // },
254
+ // },
255
+ // },
256
+ // },
257
+ // },
258
+ // },
259
+ // },
260
+ // '/auth:resetPassword': {
261
+ // post: {
262
+ // description: 'Reset password',
263
+ // tags: ['Basic auth'],
264
+ // security: [],
265
+ // requestBody: {
266
+ // content: {
267
+ // 'application/json': {
268
+ // schema: {
269
+ // type: 'object',
270
+ // properties: {
271
+ // email: {
272
+ // type: 'string',
273
+ // description: '邮箱',
274
+ // },
275
+ // password: {
276
+ // type: 'string',
277
+ // description: '密码',
278
+ // },
279
+ // resetToken: {
280
+ // type: 'string',
281
+ // description: '重置密码的token',
282
+ // },
283
+ // },
284
+ // },
285
+ // },
286
+ // },
287
+ // },
288
+ // responses: {
289
+ // 200: {
290
+ // description: 'successful operation',
291
+ // content: {
292
+ // 'application/json': {
293
+ // schema: {
294
+ // $ref: '#/components/schemas/user',
295
+ // },
296
+ // },
297
+ // },
298
+ // },
299
+ // 404: {
300
+ // description: 'User not found',
301
+ // content: {
302
+ // 'application/json': {
303
+ // schema: {
304
+ // $ref: '#/components/schemas/error',
305
+ // },
306
+ // },
307
+ // },
308
+ // },
309
+ // },
310
+ // },
311
+ // },
312
+ // '/auth:getUserByResetToken': {
313
+ // get: {
314
+ // description: 'Get user by reset token',
315
+ // tags: ['Basic auth'],
316
+ // security: [],
317
+ // parameters: [
318
+ // {
319
+ // name: 'token',
320
+ // in: 'query',
321
+ // description: '重置密码的token',
322
+ // required: true,
323
+ // schema: {
324
+ // type: 'string',
325
+ // },
326
+ // },
327
+ // ],
328
+ // responses: {
329
+ // 200: {
330
+ // description: 'ok',
331
+ // content: {
332
+ // 'application/json': {
333
+ // schema: {
334
+ // $ref: '#/components/schemas/user',
335
+ // },
336
+ // },
337
+ // },
338
+ // },
339
+ // 401: {
340
+ // description: 'Unauthorized',
341
+ // content: {
342
+ // 'application/json': {
343
+ // schema: {
344
+ // $ref: '#/components/schemas/error',
345
+ // },
346
+ // },
347
+ // },
348
+ // },
349
+ // },
350
+ // },
351
+ // },
352
352
  "/auth:changePassword": {
353
353
  post: {
354
354
  description: "Change password",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/plugin-auth",
3
- "version": "1.4.0-alpha.0",
3
+ "version": "1.4.0-alpha.10",
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": "8ffa7b54bbaf720c0c9857da4b19a99110dffc4b",
29
+ "gitHead": "74c99c0f2d84690d7e3db62c7a913e6aca97c762",
30
30
  "keywords": [
31
31
  "Authentication"
32
32
  ]