@nocobase/plugin-auth 2.3.0-beta.3 → 3.0.0-alpha.11
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-v2/217.1510705562d97555.js +10 -0
- package/dist/client-v2/795.8e4b138118e322ab.js +10 -0
- package/dist/client-v2/841.9fafcb7049bfe687.js +10 -0
- package/dist/client-v2/authRoutePaths.d.ts +26 -0
- package/dist/client-v2/index.js +1 -1
- package/dist/client-v2/plugin.d.ts +11 -0
- package/dist/externalVersion.js +11 -11
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -0
- package/dist/node_modules/cron/package.json +1 -1
- package/dist/node_modules/ms/package.json +1 -1
- package/dist/server/index.d.ts +2 -0
- package/dist/server/index.js +5 -0
- package/dist/server/utils/authRedirect.d.ts +30 -0
- package/dist/server/utils/authRedirect.js +93 -0
- package/dist/server/utils/buildRedirectPath.js +19 -0
- package/package.json +2 -2
- package/dist/client-v2/217.09744ff679406aff.js +0 -10
- package/dist/client-v2/795.b26178560fd03daa.js +0 -10
- package/dist/client-v2/841.ac9bfbb0615510e5.js +0 -10
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
"use strict";(self.webpackChunk_nocobase_plugin_auth_client_v2=self.webpackChunk_nocobase_plugin_auth_client_v2||[]).push([["217"],{264:function(e,t,n){n.r(t),n.d(t,{default:function(){return g}});var r=n(485),a=n(694),l=n(6),i=n(59),o=n(155),u=n.n(o),s=n(442),c=n(488);function m(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 f(e,t,n,r,a,l,i){try{var o=e[l](i),u=o.value}catch(e){n(e);return}o.done?t(u):Promise.resolve(u).then(r,a)}function d(e,t){if(e){if("string"==typeof e)return m(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 m(e,t)}}var p=["$env"];function h(e){var t,n=(0,c.dE)().t,s=(0,c.kj)(),f=(t=(0,a.useFlowContext)(),(0,o.useMemo)(function(){var e,n,r,a,l=null==(r=t.dataSourceManager)||null==(n=r.getCollection)?void 0:n.call(r,"main","users");return(null!=(e=null==l||null==(a=l.getFields)?void 0:a.call(l))?e:[]).filter(function(e){var t,n;return e&&!(null==(t=e.options)?void 0:t.hidden)&&!e.target&&e.interface&&!(null==(n=e.uiSchema)?void 0:n["x-read-pretty"])})},[t])),p=(0,o.useMemo)(function(){var t;return null!=(t=e.value)?t:[]},[e.value]),h=(0,o.useMemo)(function(){var e=new Set(f.map(function(e){return e.name})),t=p.filter(function(t){return e.has(t.field)}),n=new Set(t.map(function(e){return e.field})),r=!0,a=!1,l=void 0;try{for(var i,o=f[Symbol.iterator]();!(r=(i=o.next()).done);r=!0){var u=i.value;n.has(u.name)||t.push({field:u.name,show:"username"===u.name,required:"username"===u.name})}}catch(e){a=!0,l=e}finally{try{r||null==o.return||o.return()}finally{if(a)throw l}}return t},[f,p]);u().useEffect(function(){var t;p.length===h.length&&p.every(function(e,t){return e.field===h[t].field&&!!e.show==!!h[t].show&&!!e.required==!!h[t].required})||null==(t=e.onChange)||t.call(e,h)},[h]);var y=(0,l.useMemoizedFn)(function(t,n){var r,a=h.map(function(e){if(e.field!==t)return e;var r=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;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},e,n);return r.required&&(r.show=!0),r.show||(r.required=!1),r});null==(r=e.onChange)||r.call(e,a)}),b=(0,l.useMemoizedFn)(function(e){var t,n,r=f.find(function(t){return t.name===e});return s((null==r||null==(t=r.uiSchema)?void 0:t.title)||(null==r||null==(n=r.options)?void 0:n.title)||e)}),g=(0,o.useMemo)(function(){return[{title:n("Field"),dataIndex:"field",width:200,render:function(e){return u().createElement(i.Tag,null,b(e))}},{title:n("Show"),dataIndex:"show",width:80,align:"center",render:function(e,t){return u().createElement(i.Checkbox,{checked:!!t.show,onChange:function(e){return y(t.field,{show:e.target.checked})}})}},{title:n("Required"),dataIndex:"required",width:80,align:"center",render:function(e,t){return u().createElement(i.Checkbox,{checked:!!t.required,onChange:function(e){return y(t.field,{required:e.target.checked})}})}},{title:"",dataIndex:"_filler",render:function(){return null}}]},[b,n,y]),v=(0,l.useMemoizedFn)(function(t,n){var r,a=h.findIndex(function(e){return e.field===t.field}),l=h.findIndex(function(e){return e.field===n.field});if(!(a<0)&&!(l<0)&&a!==l){var i,o=function(e){if(Array.isArray(e))return m(e)}(h)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(h)||d(h)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),u=(function(e){if(Array.isArray(e))return e}(i=o.splice(a,1))||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var a=[],l=!0,i=!1;try{for(r=r.call(e);!(l=(t=r.next()).done)&&(a.push(t.value),1!==a.length);l=!0);}catch(e){i=!0,n=e}finally{try{l||null==r.return||r.return()}finally{if(i)throw n}}return a}}(i)||d(i,1)||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];o.splice(l,0,u),null==(r=e.onChange)||r.call(e,o)}});return u().createElement(r.Table,{rowKey:"field",pagination:!1,columns:g,dataSource:h,isDraggable:!0,onSortEnd:v,sortHandleColumnWidth:32,showIndex:!1})}function y(){var e=(0,c.dE)().t;return u().createElement(u().Fragment,null,u().createElement(i.Form.Item,{name:["options","public","allowSignUp"],label:e("Allow to sign up"),valuePropName:"checked",initialValue:!0},u().createElement(i.Checkbox,null)),u().createElement(i.Form.Item,{label:e("Sign up form"),name:["options","public","signupForm"],validateFirst:!0},u().createElement(h,null)))}function b(){var e,t,n,m=(0,c.dE)().t,d=(0,a.useFlowContext)(),h=i.Form.useFormInstance(),y=i.Form.useWatch(["options","public","enableResetPassword"],h),b=i.Form.useWatch(["options","emailContentType"],h)||"html",g=(e=(0,c.dE)().t,(0,o.useMemo)(function(){return[{name:"$user",title:e("Current user"),type:"object",paths:["$user"],children:[{name:"username",title:e("Username"),type:"string",paths:["$user","username"]},{name:"nickname",title:e("Nickname"),type:"string",paths:["$user","nickname"]},{name:"email",title:e("Email"),type:"string",paths:["$user","email"]}]},{name:"$systemSettings",title:e("System settings"),type:"object",paths:["$systemSettings"],children:[{name:"title",title:e("System title"),type:"string",paths:["$systemSettings","title"]},{name:"logo",title:e("System logo"),type:"string",paths:["$systemSettings","logo"]}]},{name:"$resetLink",title:e("Reset password link"),type:"string",paths:["$resetLink"]},{name:"$resetLinkExpiration",title:e("Reset link expiration (minutes)"),type:"string",paths:["$resetLinkExpiration"]}]},[e])),v=(t=!!y,n=(0,a.useFlowContext)(),(0,l.useRequest)(function(){var e;return(e=function(){var e,t,r,a;return function(e,t){var n,r,a,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),o=Object.defineProperty;return o(i,"next",{value:u(0)}),o(i,"throw",{value:u(1)}),o(i,"return",{value:u(2)}),"function"==typeof Symbol&&o(i,Symbol.iterator,{value:function(){return this}}),i;function u(o){return function(u){var s=[o,u];if(n)throw TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(l=0)),l;)try{if(n=1,r&&(a=2&s[0]?r.return:s[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,s[1])).done)return a;switch(r=0,a&&(s=[2&s[0],a.value]),s[0]){case 0:case 1:a=s;break;case 4:return l.label++,{value:s[1],done:!1};case 5:l.label++,r=s[1],s=[0];continue;case 7:s=l.ops.pop(),l.trys.pop();continue;default:if(!(a=(a=l.trys).length>0&&a[a.length-1])&&(6===s[0]||2===s[0])){l=0;continue}if(3===s[0]&&(!a||s[1]>a[0]&&s[1]<a[3])){l.label=s[1];break}if(6===s[0]&&l.label<a[1]){l.label=a[1],a=s;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(s);break}a[2]&&l.ops.pop(),l.trys.pop();continue}s=t.call(e,l)}catch(e){s=[6,e],r=0}finally{n=a=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}}(this,function(l){switch(l.label){case 0:return[4,n.api.resource("notificationChannels").list({filter:{notificationType:"email"},pageSize:50})];case 1:return[2,Array.isArray(a=null!=(e=null==(r=l.sent())||null==(t=r.data)?void 0:t.data)?e:null==r?void 0:r.data)?a:[]]}})},function(){var t=this,n=arguments;return new Promise(function(r,a){var l=e.apply(t,n);function i(e){f(l,r,a,i,o,"next",e)}function o(e){f(l,r,a,i,o,"throw",e)}i(void 0)})})()},{ready:t,cacheKey:"@nocobase/plugin-auth:notificationChannels:email",refreshDeps:[t]})),w=v.data,E=v.loading,S=(0,o.useMemo)(function(){return(w||[]).map(function(e){return{label:e.title,value:e.name}})},[w]);return u().createElement(u().Fragment,null,u().createElement(i.Form.Item,{name:["options","public","enableResetPassword"],label:m("Enable forget password"),valuePropName:"checked",initialValue:!1},u().createElement(i.Checkbox,null)),y?u().createElement(u().Fragment,null,u().createElement(i.Typography.Title,{level:5,style:{marginTop:0}},m("1. Select notification channel")),u().createElement(i.Form.Item,{name:["options","notificationChannel"],label:m("Notification channel (Email)"),extra:m("The notification channel used to send the reset password email, only support email channel"),rules:[{required:!0,message:m("Please select a notification channel")}]},u().createElement(i.Select,{loading:E,options:S,placeholder:m("Select"),notFoundContent:u().createElement("span",null,m("No notification channels found. Please "),u().createElement(s.Link,{to:d.app.pluginSettingsManager.getRoutePath("notification-manager.channels")},m("add one first")),".")})),u().createElement(i.Typography.Title,{level:5},m("2. Configure reset email")),u().createElement(i.Form.Item,{name:["options","emailSubject"],label:m("Subject"),rules:[{required:!0,message:m("Please enter the email subject")}],initialValue:m("defaultResetPasswordEmailSubject")},u().createElement(r.VariableInput,{namespaces:p,extraNodes:g})),u().createElement(i.Form.Item,{name:["options","emailContentType"],label:m("Content type"),initialValue:"html",rules:[{required:!0}]},u().createElement(i.Radio.Group,{options:[{label:"HTML",value:"html"},{label:m("Plain text"),value:"text"}]})),"html"===b?u().createElement(i.Form.Item,{key:"html",name:["options","emailContentHTML"],label:m("Content"),rules:[{required:!0,message:m("Please enter the email content")}],initialValue:m("defaultResetPasswordEmailContentHTML")},u().createElement(r.VariableTextArea,{namespaces:p,extraNodes:g,placeholder:"Hi,",rows:10})):u().createElement(i.Form.Item,{key:"text",name:["options","emailContentText"],label:m("Content"),rules:[{required:!0,message:m("Please enter the email content")}],initialValue:m("defaultResetPasswordEmailContentText")},u().createElement(r.VariableTextArea,{namespaces:p,extraNodes:g,rows:10})),u().createElement(i.Form.Item,{name:["options","resetTokenExpiresIn"],label:m("Reset link expiration"),initialValue:120,rules:[{required:!0,message:m("Please enter the expiration in minutes")}]},u().createElement(i.InputNumber,{min:1,addonAfter:m("Minutes"),style:{width:"100%"}}))):null)}function g(){var e=(0,c.dE)().t;return u().createElement("div",null,u().createElement(i.Alert,{style:{marginBottom:16},type:"info",showIcon:!0,message:e("The authentication allows users to sign in via username or email.")}),u().createElement(i.Tabs,{items:[{key:"signup",label:e("Sign up settings"),forceRender:!0,children:u().createElement(y,null)},{key:"forgot",label:e("Forgot password"),forceRender:!0,children:u().createElement(b,null)}]}))}}}]);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
"use strict";(self.webpackChunk_nocobase_plugin_auth_client_v2=self.webpackChunk_nocobase_plugin_auth_client_v2||[]).push([["795"],{918:function(e,t,r){r.r(t),r.d(t,{default:function(){return d}});var n=r(59),a=r(485),o=r(155),l=r.n(o),u=r(442),s=r(488),i=r(824),c=r(927),m=r(434);function p(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function f(e,t,r,n,a,o,l){try{var u=e[o](l),s=u.value}catch(e){r(e);return}u.done?t(s):Promise.resolve(s).then(n,a)}function h(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,a=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var o=[],l=!0,u=!1;try{for(a=a.call(e);!(l=(r=a.next()).done)&&(o.push(r.value),!t||o.length!==t);l=!0);}catch(e){u=!0,n=e}finally{try{l||null==a.return||a.return()}finally{if(u)throw n}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return p(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return p(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 d(e){var t,r,p=e.authenticator,d=(0,a.useApp)(),y=(0,a.usePlugin)(m.A),v=(0,u.useLocation)(),b=(0,s.dE)().t,g=h(n.Form.useForm(),1)[0],w=h((0,o.useState)(""),2),P=w[0],S=w[1],E=h((0,o.useState)(!1),2),k=E[0],A=E[1],I=(0,i.go)(p.name),_=!!(null==p||null==(t=p.options)?void 0:t.allowSignUp),j=!!(null==p||null==(r=p.options)?void 0:r.enableResetPassword),F=y.getAuthRoutePath(v.pathname,"auth.signup"),C=(0,c.f1)(d,"auth.forgotPassword"),x=new URLSearchParams({name:p.name}),L=y.isScopedAuthRoute(v.pathname)?new URLSearchParams(v.search).get("redirect"):null;return null!==L&&x.set("redirect",L),l().createElement(n.Form,{form:g,layout:"vertical",onFinish:function(e){var t;return(t=function(){var t,r,n,a,o;return function(e,t){var r,n,a,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},l=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(l,"next",{value:s(0)}),u(l,"throw",{value:s(1)}),u(l,"return",{value:s(2)}),"function"==typeof Symbol&&u(l,Symbol.iterator,{value:function(){return this}}),l;function s(u){return function(s){var i=[u,s];if(r)throw TypeError("Generator is already executing.");for(;l&&(l=0,i[0]&&(o=0)),o;)try{if(r=1,n&&(a=2&i[0]?n.return:i[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,i[1])).done)return a;switch(n=0,a&&(i=[2&i[0],a.value]),i[0]){case 0:case 1:a=i;break;case 4:return o.label++,{value:i[1],done:!1};case 5:o.label++,n=i[1],i=[0];continue;case 7:i=o.ops.pop(),o.trys.pop();continue;default:if(!(a=(a=o.trys).length>0&&a[a.length-1])&&(6===i[0]||2===i[0])){o=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]<a[3])){o.label=i[1];break}if(6===i[0]&&o.label<a[1]){o.label=a[1],a=i;break}if(a&&o.label<a[2]){o.label=a[2],o.ops.push(i);break}a[2]&&o.ops.pop(),o.trys.pop();continue}i=t.call(e,o)}catch(e){i=[6,e],n=0}finally{r=a=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}}}(this,function(l){switch(l.label){case 0:S(""),A(!0),l.label=1;case 1:return l.trys.push([1,3,4,5]),[4,I.run(e)];case 2:return l.sent(),[3,5];case 3:return S((null==(t=l.sent())||null==(o=t.response)||null==(a=o.data)||null==(n=a.errors)||null==(r=n[0])?void 0:r.message)||(null==t?void 0:t.message)||String(t)),[3,5];case 4:return A(!1),[7];case 5:return[2]}})},function(){var e=this,r=arguments;return new Promise(function(n,a){var o=t.apply(e,r);function l(e){f(o,n,a,l,u,"next",e)}function u(e){f(o,n,a,l,u,"throw",e)}l(void 0)})})()}},P?l().createElement(n.Alert,{style:{marginBottom:16},type:"error",showIcon:!0,message:P}):null,l().createElement(n.Form.Item,{name:"account",rules:[{required:!0,message:b("Please enter your username or email")},{validator:function(e,t){return t?String(t).includes("@")?/^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/.test(String(t))?Promise.resolve():Promise.reject(Error(b("Please enter a valid email"))):/^[^@<>"'/]{1,50}$/.test(String(t))?Promise.resolve():Promise.reject(Error(b("Please enter a valid username"))):Promise.resolve()}}]},l().createElement(n.Input,{autoComplete:"username",placeholder:b("Username/Email")})),l().createElement(n.Form.Item,{name:"password",rules:[{required:!0,message:b("Please enter a password")}]},l().createElement(n.Input.Password,{autoComplete:"current-password",placeholder:b("Password")})),l().createElement(n.Form.Item,{style:{marginBottom:12}},l().createElement(n.Button,{loading:k,htmlType:"submit",type:"primary",block:!0},b("Sign in"))),l().createElement("div",{style:{display:"flex",justifyContent:"space-between",gap:12}},_?l().createElement(u.Link,{to:"".concat(F,"?").concat(x)},b("Create an account")):null,j?l().createElement(u.Link,{to:"".concat(C,"?name=").concat(p.name)},b("Forgot password")):null))}}}]);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
"use strict";(self.webpackChunk_nocobase_plugin_auth_client_v2=self.webpackChunk_nocobase_plugin_auth_client_v2||[]).push([["841"],{720:function(e,t,r){r.r(t),r.d(t,{default:function(){return v}});var n=r(59),a=r(155),o=r.n(a),l=r(442),u=r(230),i=r(953),s=r(485),c=r(488),m=r(295),p=r(434);function f(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function d(e,t,r,n,a,o,l){try{var u=e[o](l),i=u.value}catch(e){r(e);return}u.done?t(i):Promise.resolve(i).then(n,a)}function h(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,a=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var o=[],l=!0,u=!1;try{for(a=a.call(e);!(l=(r=a.next()).done)&&(o.push(r.value),!t||o.length!==t);l=!0);}catch(e){u=!0,n=e}finally{try{l||null==a.return||a.return()}finally{if(u)throw n}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return f(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return f(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 v(e){var t,r=e.authenticatorName,f=(0,s.useApp)(),v=(0,s.usePlugin)(p.A),y=(0,l.useLocation)(),b=(0,l.useNavigate)(),g=(0,c.dE)().t,w=(0,i.useTranslation)("lm-collections").t,E=(0,m.p)(r),S=h(n.Form.useForm(),1)[0],I=h((0,a.useState)(!1),2),P=I[0],k=I[1],A=h((0,a.useState)(""),2),x=A[0],C=A[1],_=v.getAuthRoutePath(y.pathname,"auth.signin"),F=v.isScopedAuthRoute(y.pathname)?new URLSearchParams(y.search).get("redirect"):null,T={pathname:_,search:null===F?"":"?redirect=".concat(encodeURIComponent(F))},j=(0,a.useMemo)(function(){var e;return((null==E||null==(e=E.options)?void 0:e.signupForm)||[]).filter(function(e){return null==e?void 0:e.show})},[E]);return(null==E||null==(t=E.options)?void 0:t.allowSignUp)?o().createElement(n.Form,{form:S,layout:"vertical",onFinish:function(e){var t;return(t=function(){var t,a,o,l,u;return function(e,t){var r,n,a,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},l=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(l,"next",{value:i(0)}),u(l,"throw",{value:i(1)}),u(l,"return",{value:i(2)}),"function"==typeof Symbol&&u(l,Symbol.iterator,{value:function(){return this}}),l;function i(u){return function(i){var s=[u,i];if(r)throw TypeError("Generator is already executing.");for(;l&&(l=0,s[0]&&(o=0)),o;)try{if(r=1,n&&(a=2&s[0]?n.return:s[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,s[1])).done)return a;switch(n=0,a&&(s=[2&s[0],a.value]),s[0]){case 0:case 1:a=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(a=(a=o.trys).length>0&&a[a.length-1])&&(6===s[0]||2===s[0])){o=0;continue}if(3===s[0]&&(!a||s[1]>a[0]&&s[1]<a[3])){o.label=s[1];break}if(6===s[0]&&o.label<a[1]){o.label=a[1],a=s;break}if(a&&o.label<a[2]){o.label=a[2],o.ops.push(s);break}a[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],n=0}finally{r=a=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}}(this,function(i){switch(i.label){case 0:C(""),k(!0),i.label=1;case 1:return i.trys.push([1,3,4,5]),[4,f.apiClient.auth.signUp(e,r)];case 2:return i.sent(),n.message.success(g("Sign up successfully, and automatically jump to the sign in page")),window.setTimeout(function(){b(T,{replace:!0})},2e3),[3,5];case 3:return C((null==(t=i.sent())||null==(u=t.response)||null==(l=u.data)||null==(o=l.errors)||null==(a=o[0])?void 0:a.message)||(null==t?void 0:t.message)||String(t)),[3,5];case 4:return k(!1),[7];case 5:return[2]}})},function(){var e=this,r=arguments;return new Promise(function(n,a){var o=t.apply(e,r);function l(e){d(o,n,a,l,u,"next",e)}function u(e){d(o,n,a,l,u,"throw",e)}l(void 0)})})()}},x?o().createElement(n.Alert,{style:{marginBottom:16},type:"error",showIcon:!0,message:x}):null,j.map(function(e){var t,r,a,l,i,s;return a=(r=(null==e?void 0:e.uiSchema)||{})["x-component"],l=r.title?w(u.Schema.compile(r.title,{t:g})):e.field,i=[],e.required&&i.push({required:!0,message:g("Please enter ".concat(e.field))}),"email"===e.field&&i.push({type:"email",message:g("Please enter a valid email address")}),s=o().createElement(n.Input,null),(null==(t=r.enum)?void 0:t.length)?s=o().createElement(n.Select,{options:r.enum.map(function(e){return{label:e.label||e.value,value:e.value}})}):"Checkbox"===a?s=o().createElement(n.Checkbox,null):("Input.TextArea"===a||"TextArea"===a)&&(s=o().createElement(n.Input.TextArea,{rows:4})),o().createElement(n.Form.Item,{key:e.field,name:e.field,label:l,valuePropName:"Checkbox"===a?"checked":"value",rules:i},s)}),o().createElement(n.Form.Item,{label:g("Password"),name:"password",rules:[{required:!0,message:g("Please enter a password")}]},o().createElement(n.Input.Password,{autoComplete:"new-password"})),o().createElement(n.Form.Item,{label:g("Confirm password"),name:"confirm_password",dependencies:["password"],rules:[{required:!0,message:g("Please enter the same password again")},function(e){var t=e.getFieldValue;return{validator:function(e,r){return r&&t("password")!==r?Promise.reject(Error(g("The passwords entered twice are inconsistent"))):Promise.resolve()}}}]},o().createElement(n.Input.Password,{autoComplete:"new-password"})),o().createElement(n.Form.Item,{style:{marginBottom:12}},o().createElement(n.Button,{loading:P,htmlType:"submit",type:"primary",block:!0},g("Sign up"))),o().createElement(l.Link,{to:T},g("Log in with an existing account"))):o().createElement(l.Navigate,{to:"/not-found",replace:!0})}}}]);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
export type AuthRouteName = 'auth.signin' | 'auth.signup' | 'auth.forgotPassword' | 'auth.resetPassword';
|
|
10
|
+
type PluginSettingsRouteApplication = {
|
|
11
|
+
pluginSettingsManager: {
|
|
12
|
+
getRouteName: (name: string) => string;
|
|
13
|
+
getRoutePath: (name: string) => string;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
type AuthRouteApplication = PluginSettingsRouteApplication & {
|
|
17
|
+
router: {
|
|
18
|
+
get: (name: string) => {
|
|
19
|
+
path?: string;
|
|
20
|
+
} | undefined;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export declare function getAuthRoutePath(app: AuthRouteApplication, name: AuthRouteName): string;
|
|
24
|
+
export declare function isStandaloneSettingsApplication(app: PluginSettingsRouteApplication): boolean;
|
|
25
|
+
export declare function getDefaultAuthRedirectPath(app: PluginSettingsRouteApplication): string;
|
|
26
|
+
export {};
|
package/dist/client-v2/index.js
CHANGED
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react-i18next"),require("react-router-dom"),require("@formily/react"),require("@ant-design/icons"),require("@nocobase/flow-engine"),require("ahooks"),require("@nocobase/client-v2"),require("react"),require("antd"),require("@nocobase/utils/client"),require("lodash")):"function"==typeof define&&define.amd?define("@nocobase/plugin-auth/client-v2",["react-i18next","react-router-dom","@formily/react","@ant-design/icons","@nocobase/flow-engine","ahooks","@nocobase/client-v2","react","antd","@nocobase/utils/client","lodash"],t):"object"==typeof exports?exports["@nocobase/plugin-auth/client-v2"]=t(require("react-i18next"),require("react-router-dom"),require("@formily/react"),require("@ant-design/icons"),require("@nocobase/flow-engine"),require("ahooks"),require("@nocobase/client-v2"),require("react"),require("antd"),require("@nocobase/utils/client"),require("lodash")):e["@nocobase/plugin-auth/client-v2"]=t(e["react-i18next"],e["react-router-dom"],e["@formily/react"],e["@ant-design/icons"],e["@nocobase/flow-engine"],e.ahooks,e["@nocobase/client-v2"],e.react,e.antd,e["@nocobase/utils/client"],e.lodash)}(self,function(e,t,n,r,o,i,a,u,l,c,s){return function(){var f,p,d,h={432:function(e,t,n){e.exports=n(36).Symbol},77:function(e,t,n){var r=n(432),o=n(444),i=n(371),a=r?r.toStringTag:void 0;e.exports=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":a&&a in Object(e)?o(e):i(e)}},625:function(e,t,n){var r=n(531),o=/^\s+/;e.exports=function(e){return e?e.slice(0,r(e)+1).replace(o,""):e}},565:function(e,t,n){e.exports="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g},444:function(e,t,n){var r=n(432),o=Object.prototype,i=o.hasOwnProperty,a=o.toString,u=r?r.toStringTag:void 0;e.exports=function(e){var t=i.call(e,u),n=e[u];try{e[u]=void 0;var r=!0}catch(e){}var o=a.call(e);return r&&(t?e[u]=n:delete e[u]),o}},371:function(e){var t=Object.prototype.toString;e.exports=function(e){return t.call(e)}},36:function(e,t,n){var r=n(565),o="object"==typeof self&&self&&self.Object===Object&&self;e.exports=r||o||Function("return this")()},531:function(e){var t=/\s/;e.exports=function(e){for(var n=e.length;n--&&t.test(e.charAt(n)););return n}},738:function(e,t,n){var r=n(130),o=n(593),i=n(909),a=Math.max,u=Math.min;e.exports=function(e,t,n){var l,c,s,f,p,d,h=0,m=!1,y=!1,v=!0;if("function"!=typeof e)throw TypeError("Expected a function");function b(t){var n=l,r=c;return l=c=void 0,h=t,f=e.apply(r,n)}function g(e){var n=e-d,r=e-h;return void 0===d||n>=t||n<0||y&&r>=s}function w(){var e,n,r,i=o();if(g(i))return E(i);p=setTimeout(w,(e=i-d,n=i-h,r=t-e,y?u(r,s-n):r))}function E(e){return(p=void 0,v&&l)?b(e):(l=c=void 0,f)}function S(){var e,n=o(),r=g(n);if(l=arguments,c=this,d=n,r){if(void 0===p)return h=e=d,p=setTimeout(w,t),m?b(e):f;if(y)return clearTimeout(p),p=setTimeout(w,t),b(d)}return void 0===p&&(p=setTimeout(w,t)),f}return t=i(t)||0,r(n)&&(m=!!n.leading,s=(y="maxWait"in n)?a(i(n.maxWait)||0,t):s,v="trailing"in n?!!n.trailing:v),S.cancel=function(){void 0!==p&&clearTimeout(p),h=0,l=d=c=p=void 0},S.flush=function(){return void 0===p?f:E(o())},S}},130:function(e){e.exports=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}},189:function(e){e.exports=function(e){return null!=e&&"object"==typeof e}},733:function(e,t,n){var r=n(77),o=n(189);e.exports=function(e){return"symbol"==typeof e||o(e)&&"[object Symbol]"==r(e)}},593:function(e,t,n){var r=n(36);e.exports=function(){return r.Date.now()}},909:function(e,t,n){var r=n(625),o=n(130),i=n(733),a=0/0,u=/^[-+]0x[0-9a-f]+$/i,l=/^0b[01]+$/i,c=/^0o[0-7]+$/i,s=parseInt;e.exports=function(e){if("number"==typeof e)return e;if(i(e))return a;if(o(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=o(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=r(e);var n=l.test(e);return n||c.test(e)?s(e.slice(2),n?2:8):u.test(e)?a:+e}},829:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return s}});var r=n(59),o=n(155),i=n.n(o),a=n(442),u=n(953),l=n(485),c=n(89);function s(){var e,t=r.theme.useToken().token,n=((0,l.useSystemSettings)()||{}).data,o=(0,u.useTranslation)("lm-collections").t;return i().createElement("div",{style:{maxWidth:320,margin:"0 auto",paddingTop:"20vh",paddingBottom:"20vh"}},i().createElement("div",{style:{position:"fixed",top:t.paddingLG,right:t.paddingLG,color:t.colorText}},i().createElement(l.SwitchLanguage,null)),i().createElement("h1",{style:{textAlign:"center"}},o(null==n||null==(e=n.data)?void 0:e.title)),i().createElement(c.A,null,i().createElement(a.Outlet,null)),i().createElement("div",{style:{position:"absolute",bottom:0,left:0,width:"100%",paddingBottom:t.paddingLG,textAlign:"center",backgroundColor:t.colorBgContainer}},i().createElement(l.PoweredBy,null)))}},826:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return h}});var r=n(59),o=n(155),i=n.n(o),a=n(442),u=n(485),l=n(295),c=n(488),s=n(824);function f(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 p(e,t,n,r,o,i,a){try{var u=e[i](a),l=u.value}catch(e){n(e);return}u.done?t(l):Promise.resolve(l).then(r,o)}function d(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,u=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){u=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(u)throw r}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return f(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 f(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 h(){var e,t=(0,u.useApp)(),n=(0,c.dE)().t,f=d((0,a.useSearchParams)(),1)[0].get("name"),h=(0,l.p)(f),m=d(r.Form.useForm(),1)[0],y=d((0,o.useState)(!1),2),v=y[0],b=y[1],g=d((0,o.useState)(""),2),w=g[0],E=g[1];return((0,s.rN)(n("Reset password")),null==h||null==(e=h.options)?void 0:e.enableResetPassword)?i().createElement(r.Form,{form:m,layout:"vertical",onFinish:function(e){var o;return(o=function(){var o,i,a,u,l;return function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(a,"next",{value:l(0)}),u(a,"throw",{value:l(1)}),u(a,"return",{value:l(2)}),"function"==typeof Symbol&&u(a,Symbol.iterator,{value:function(){return this}}),a;function l(u){return function(l){var c=[u,l];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}(this,function(c){switch(c.label){case 0:E(""),b(!0),c.label=1;case 1:return c.trys.push([1,3,4,5]),[4,t.apiClient.auth.lostPassword(e)];case 2:return c.sent(),r.message.success(n("Reset email sent successfully")),m.resetFields(),[3,5];case 3:return E((null==(o=c.sent())||null==(l=o.response)||null==(u=l.data)||null==(a=u.errors)||null==(i=a[0])?void 0:i.message)||(null==o?void 0:o.message)||String(o)),[3,5];case 4:return b(!1),[7];case 5:return[2]}})},function(){var e=this,t=arguments;return new Promise(function(n,r){var i=o.apply(e,t);function a(e){p(i,n,r,a,u,"next",e)}function u(e){p(i,n,r,a,u,"throw",e)}a(void 0)})})()}},w?i().createElement(r.Alert,{style:{marginBottom:16},type:"error",showIcon:!0,message:w}):null,i().createElement(r.Form.Item,{label:n("Reset password"),name:"email",rules:[{required:!0,message:n("Please fill in your email address")},{type:"email",message:n("Please enter a valid email")}]},i().createElement(r.Input,{placeholder:n("Please enter your email")})),i().createElement(r.Form.Item,{style:{marginBottom:12}},i().createElement(r.Button,{loading:v,htmlType:"submit",type:"primary",block:!0},n("Send reset email"))),i().createElement(a.Link,{to:"/signin"},n("Back to login"))):i().createElement(a.Navigate,{to:"/signin",replace:!0})}},622:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return h}});var r=n(59),o=n(155),i=n.n(o),a=n(442),u=n(485),l=n(295),c=n(488),s=n(824);function f(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 p(e,t,n,r,o,i,a){try{var u=e[i](a),l=u.value}catch(e){n(e);return}u.done?t(l):Promise.resolve(l).then(r,o)}function d(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,u=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){u=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(u)throw r}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return f(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 f(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 h(){var e,t=(0,u.useApp)(),n=(0,c.dE)().t,f=(0,a.useNavigate)(),h=d((0,a.useSearchParams)(),1)[0],m=h.get("resetToken"),y=h.get("name"),v=(0,l.p)(y),b=d(r.Form.useForm(),1)[0],g=d((0,o.useState)(!1),2),w=g[0],E=g[1],S=d((0,o.useState)(!0),2),O=S[0],P=S[1],k=d((0,o.useState)(!1),2),A=k[0],x=k[1],T=d((0,o.useState)(""),2),j=T[0],_=T[1];return((0,s.rN)(n("Reset password")),(0,o.useEffect)(function(){var e=!0;if(!m){E(!0),P(!1);return}return t.apiClient.auth.checkResetToken({resetToken:m}).then(function(){e&&(E(!1),P(!1))}).catch(function(){e&&(E(!0),P(!1))}),function(){e=!1}},[t,m]),null==v||null==(e=v.options)?void 0:e.enableResetPassword)?O||m&&!w?i().createElement(r.Form,{form:b,layout:"vertical",onFinish:function(e){var o;return(o=function(){var o,i,a,u,l;return function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(a,"next",{value:l(0)}),u(a,"throw",{value:l(1)}),u(a,"return",{value:l(2)}),"function"==typeof Symbol&&u(a,Symbol.iterator,{value:function(){return this}}),a;function l(u){return function(l){var c=[u,l];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}(this,function(c){switch(c.label){case 0:_(""),x(!0),c.label=1;case 1:var s,p;return c.trys.push([1,3,4,5]),[4,t.apiClient.auth.resetPassword((s=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;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},e),p=p={resetToken:m},Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(p)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(p)).forEach(function(e){Object.defineProperty(s,e,Object.getOwnPropertyDescriptor(p,e))}),s))];case 2:return c.sent(),r.message.success(n("Password reset successful")),window.setTimeout(function(){f("/signin",{replace:!0})},1e3),[3,5];case 3:return _((null==(o=c.sent())||null==(l=o.response)||null==(u=l.data)||null==(a=u.errors)||null==(i=a[0])?void 0:i.message)||(null==o?void 0:o.message)||String(o)),[3,5];case 4:return x(!1),[7];case 5:return[2]}})},function(){var e=this,t=arguments;return new Promise(function(n,r){var i=o.apply(e,t);function a(e){p(i,n,r,a,u,"next",e)}function u(e){p(i,n,r,a,u,"throw",e)}a(void 0)})})()}},j?i().createElement(r.Alert,{style:{marginBottom:16},type:"error",showIcon:!0,message:j}):null,i().createElement(r.Form.Item,{label:n("New password"),name:"password",rules:[{required:!0,message:n("Please enter new password")}]},i().createElement(r.Input.Password,{autoComplete:"new-password"})),i().createElement(r.Form.Item,{label:n("Confirm password"),name:"confirmPassword",dependencies:["password"],rules:[{required:!0,message:n("Please enter the same password again")},function(e){var t=e.getFieldValue;return{validator:function(e,r){return r&&t("password")!==r?Promise.reject(Error(n("The passwords entered twice are inconsistent"))):Promise.resolve()}}}]},i().createElement(r.Input.Password,{autoComplete:"new-password"})),i().createElement(r.Form.Item,{style:{marginBottom:12}},i().createElement(r.Button,{loading:A||O,htmlType:"submit",type:"primary",block:!0},n("Confirm"))),i().createElement(a.Link,{to:"/signin"},n("Go to login"))):i().createElement(r.Result,{status:"403",title:n("Reset link has expired"),extra:i().createElement(r.Button,{type:"primary",onClick:function(){return f("/signin")}},n("Go to login"))}):i().createElement(a.Navigate,{to:"/signin",replace:!0})}},818:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return m}});var r=n(485),o=n(59),i=n(155),a=n.n(i),u=n(442),l=n(295),c=n(824),s=n(488),f=n(434);function p(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 d(e){var t=(0,r.usePlugin)(f.A);return(0,i.useMemo)(function(){var n={},r=!0,o=!1,i=void 0;try{for(var a,u=t.authTypes.getEntities()[Symbol.iterator]();!(r=(a=u.next()).done);r=!0){var l,c=(l=a.value,function(e){if(Array.isArray(e))return e}(l)||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],i=!0,a=!1;try{for(r=r.call(e);!(i=(t=r.next()).done)&&(o.push(t.value),2!==o.length);i=!0);}catch(e){a=!0,n=e}finally{try{i||null==r.return||r.return()}finally{if(a)throw n}}return o}}(l)||function(e){if(e){if("string"==typeof e)return p(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return p(e,2)}}(l)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),s=c[0],f=c[1][e];f&&(n[s]=f)}}catch(e){o=!0,i=e}finally{try{r||null==u.return||u.return()}finally{if(o)throw i}}return n},[t,e])}function h(e){var t=new Map;return function(n){if(e[n])return t.has(n)||t.set(n,(0,i.lazy)(e[n])),t.get(n)}}function m(){var e=(0,r.useApp)(),t=(0,u.useLocation)(),n=(0,u.useNavigate)(),f=(0,s.dE)().t,p=(0,s.kj)(),m=(0,i.useContext)(l.m),y=d("signInFormLoader"),v=d("signInButtonLoader"),b=(0,i.useMemo)(function(){return h(y)},[y]),g=(0,i.useMemo)(function(){return h(v)},[v]);(0,c.rN)(f("Signin")),(0,i.useEffect)(function(){var o=new URLSearchParams(t.search),i=o.get("redirect"),a=(0,r.normalizeV2RedirectPath)(e,i);i!==a&&(o.set("redirect",a),n({pathname:t.pathname,search:"?".concat(o)},{replace:!0}))},[e,t.pathname,t.search,n]);var w=(0,i.useMemo)(function(){return m.map(function(e){var t=b(e.authType);if(!t)return null;var n=p(e.authTypeTitle||e.authType);return{key:e.name,label:e.title||"".concat(f("Sign-in")," (").concat(n,")"),children:a().createElement(i.Suspense,{fallback:a().createElement(o.Spin,null)},a().createElement(t,{authenticator:e}))}}).filter(Boolean)},[m,b,f,p]),E=(0,i.useMemo)(function(){return m.map(function(e,t){var n=g(e.authType);return n?a().createElement(i.Suspense,{key:"".concat(e.name,"-").concat(t),fallback:a().createElement(o.Spin,null)},a().createElement(n,{authenticator:e})):null}).filter(Boolean)},[m,g]);return m.length?a().createElement(o.Space,{direction:"vertical",style:{display:"flex"}},w.length>1?a().createElement(o.Tabs,{items:w}):w.length?w[0].children:null,E.length?a().createElement(o.Space,{direction:"vertical",style:{display:"flex"}},E):null):a().createElement(o.Empty,{description:f("No authentication methods available.")})}},872:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return d}});var r=n(485),o=n(59),i=n(155),a=n.n(i),u=n(442),l=n(295),c=n(824),s=n(488),f=n(434);function p(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 d(){var e,t=(0,s.dE)().t,n=((function(e){if(Array.isArray(e))return e})(e=(0,u.useSearchParams)())||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],i=!0,a=!1;try{for(r=r.call(e);!(i=(t=r.next()).done)&&(o.push(t.value),1!==o.length);i=!0);}catch(e){a=!0,n=e}finally{try{i||null==r.return||r.return()}finally{if(a)throw n}}return o}}(e)||function(e){if(e){if("string"==typeof e)return p(e,1);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return p(e,1)}}(e)||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].get("name"),d=(0,l.p)(n),h=(0,r.usePlugin)(f.A),m=(0,i.useMemo)(function(){if(!d)return null;var e,t=null==(e=h.authTypes.get(d.authType))?void 0:e.signUpFormLoader;return t?(0,i.lazy)(t):null},[d,h]);return((0,c.rN)(t("Signup")),d&&m)?a().createElement(i.Suspense,{fallback:a().createElement(o.Spin,null)},a().createElement(m,{authenticatorName:d.name})):a().createElement(o.Empty,{description:t("No authentication methods available.")})}},434:function(e,t,n){"use strict";n.d(t,{A:function(){return x},T:function(){return A}});var r=n(768),o=n(485),i=n(738),a=n.n(i),u=n(258),l=n(488);function c(e,t,n,r,o,i,a){try{var u=e[i](a),l=u.value}catch(e){n(e);return}u.done?t(l):Promise.resolve(l).then(r,o)}function s(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){c(i,r,o,a,u,"next",e)}function u(e){c(i,r,o,a,u,"throw",e)}a(void 0)})}}function f(e,t,n){return t=v(t),function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e,E()?Reflect.construct(t,n||[],v(e).constructor):t.apply(e,n))}function p(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}function d(e,t,n){return(d=E()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&g(o,n.prototype),o}).apply(null,arguments)}function h(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 m(e,t,n){return t&&h(e.prototype,t),n&&h(e,n),e}function y(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function v(e){return(v=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function b(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&&g(e,t)}function g(e,t){return(g=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function w(e){var t="function"==typeof Map?new Map:void 0;return(w=function(e){if(null===e||-1===Function.toString.call(e).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,n)}function n(){return d(e,arguments,v(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),g(n,e)})(e)}function E(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(E=function(){return!!e})()}function S(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(a,"next",{value:l(0)}),u(a,"throw",{value:l(1)}),u(a,"return",{value:l(2)}),"function"==typeof Symbol&&u(a,Symbol.iterator,{value:function(){return this}}),a;function l(u){return function(l){var c=[u,l];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}var O=function(e){function t(){var e;return p(this,t),e=f(this,t,arguments),y(e,"section","preferences"),y(e,"sort",350),y(e,"label","Language"),e}return b(t,e),m(t,[{key:"prepare",value:function(){return s(function(){var e,t,n,r,i;return S(this,function(a){switch(a.label){case 0:return[4,this.context.systemSettings.load()];case 1:return i=(null==(r=a.sent())||null==(e=r.data)?void 0:e.enabledLanguages)||[],this.options=i.map(function(e){var t;return{value:e,label:(null==(t=o.languageCodes[e])?void 0:t.label)||e}}),this.value=(null==(t=(n=this.context.app.apiClient.auth).getLocale)?void 0:t.call(n))||this.context.app.apiClient.auth.locale,this.ready=this.options.length>1,[2]}})}).call(this)}},{key:"onChange",value:function(e){return s(function(){return S(this,function(t){return this.context.app.apiClient.auth.setLocale(e),window.location.reload(),[2]})}).call(this)}}]),t}(o.UserCenterSelectItemModel);y(O,"itemId","language");var P={EMPTY_TOKEN:"EMPTY_TOKEN",EXPIRED_TOKEN:"EXPIRED_TOKEN",INVALID_TOKEN:"INVALID_TOKEN",TOKEN_RENEW_FAILED:"TOKEN_RENEW_FAILED",BLOCKED_TOKEN:"BLOCKED_TOKEN",EXPIRED_SESSION:"EXPIRED_SESSION",NOT_EXIST_USER:"NOT_EXIST_USER",SKIP_TOKEN_RENEW:"SKIP_TOKEN_RENEW",USER_HAS_NO_ROLES_ERR:"USER_HAS_NO_ROLES_ERR"},k=a()(function(e){e()},3e3,{leading:!0,trailing:!1}),A=function(e){function t(){var e;return p(this,t),e=f(this,t,arguments),y(e,"authTypes",new r.Registry),e}return b(t,e),m(t,[{key:"registerType",value:function(e,t){this.authTypes.register(e,t)}},{key:"load",value:function(){return s(function(){return S(this,function(e){return this.app.providers.unshift([u.A,{}]),this.app.flowEngine.registerModels({UserCenterLanguageItemModel:O}),this.addRoutes(),this.registerPresetAuthType(),this.registerSettingsPages(),this.installInterceptors(),[2]})}).call(this)}},{key:"registerSettingsPages",value:function(){var e=this,t=function(t){return e.app.i18n.t(t,{ns:l.CU})};this.pluginSettingsManager.addMenuItem({key:l.CU,title:t("Authentication"),icon:"LoginOutlined",aclSnippet:"pm.auth"}),this.pluginSettingsManager.addPageTabItem({menuKey:l.CU,key:"authenticators",title:t("Authenticators"),icon:"LoginOutlined",aclSnippet:"pm.auth.authenticators",sort:1,componentLoader:function(){return n.e("9").then(n.bind(n,648))}}),this.pluginSettingsManager.addPageTabItem({menuKey:"security",key:"token-policy",title:t("Token policy"),icon:"ApiOutlined",aclSnippet:"pm.security.token-policy",sort:0,componentLoader:function(){return n.e("657").then(n.bind(n,632))}})}},{key:"addRoutes",value:function(){this.router.add("auth",{componentLoader:function(){return Promise.resolve().then(n.bind(n,829))}}),this.router.add("auth.signin",{path:"/signin",skipAuthCheck:!0,componentLoader:function(){return Promise.resolve().then(n.bind(n,818))}}),this.router.add("auth.signup",{path:"/signup",skipAuthCheck:!0,componentLoader:function(){return Promise.resolve().then(n.bind(n,872))}}),this.router.add("auth.forgotPassword",{path:"/forgot-password",skipAuthCheck:!0,componentLoader:function(){return Promise.resolve().then(n.bind(n,826))}}),this.router.add("auth.resetPassword",{path:"/reset-password",skipAuthCheck:!0,componentLoader:function(){return Promise.resolve().then(n.bind(n,622))}})}},{key:"registerPresetAuthType",value:function(){this.registerType("Email/Password",{signInFormLoader:function(){return n.e("795").then(n.bind(n,918))},signUpFormLoader:function(){return n.e("841").then(n.bind(n,720))},adminSettingsFormLoader:function(){return n.e("217").then(n.bind(n,264))}})}},{key:"installInterceptors",value:function(){var e=this;this.app.apiClient.axios.interceptors.response.handlers.unshift({fulfilled:function(t){var n,r=null==t||null==(n=t.headers)?void 0:n["x-new-token"];return r&&e.app.apiClient.auth.setToken(r),t},rejected:function(t){var n,r,i,a,u,l,c,s,f=null==t||null==(r=t.response)||null==(n=r.headers)?void 0:n["x-new-token"],p=null==t||null==(a=t.response)||null==(i=a.data)?void 0:i.errors,d=Array.isArray(p)?p[0]:null,h=(null==(l=e.app.router.router)||null==(u=l.state)?void 0:u.location)||window.location,m=(null==h?void 0:h.pathname)||window.location.pathname,y=(null==t?void 0:t.status)||(null==t||null==(c=t.response)?void 0:c.status);if(f&&e.app.apiClient.auth.setToken(f),401===y&&(null==d?void 0:d.code)&&P[null==d?void 0:d.code]&&(e.app.apiClient.auth.setToken(""),e.app.apiClient.auth.setRole(""),e.app.apiClient.auth.setAuthenticator("")),401===y&&!(null==(s=t.config)?void 0:s.skipAuth)&&(null==d?void 0:d.code)&&P[null==d?void 0:d.code]){if((null==d?void 0:d.code)===P.SKIP_TOKEN_RENEW)throw t;var v=e.app.router.isSkippedAuthCheckRoute(m);if(v&&(t.config.skipNotify=!0),!v){var b=(0,o.getCurrentV2RedirectPath)(e.app,h);return k(function(){e.app.apiClient.auth.setToken(""),e.app.router.navigate("/signin?redirect=".concat(encodeURIComponent(b)),{replace:!0})}),new Promise(function(){})}}throw t},synchronous:!1,runWhen:null})}}]),t}(w(o.Plugin)),x=A},258:function(e,t,n){"use strict";var r=n(485),o=n(155),i=n.n(o),a=n(442);t.A=function(e){var t=e.children,n=(0,r.useApp)(),u=(0,a.useNavigate)(),l=(0,a.useLocation)();return(0,o.useEffect)(function(){var e=new URLSearchParams(l.search),t=e.get("token"),r=e.get("authenticator");if(t){n.apiClient.auth.setToken(t),n.apiClient.auth.setAuthenticator(r),e.delete("token"),e.delete("authenticator");var o=e.toString();u({pathname:l.pathname,search:o?"?".concat(o):""},{replace:!0})}},[n,l.pathname,l.search,u]),i().createElement(i().Fragment,null,t)}},89:function(e,t,n){"use strict";var r=n(59),o=n(155),i=n.n(o),a=n(485),u=n(295);function l(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}t.A=function(e){var t,n,c=e.children,s=(0,a.useApp)(),f=function(e){if(Array.isArray(e))return e}(t=(0,o.useState)({authenticators:[],error:null,loading:!0}))||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],i=!0,a=!1;try{for(r=r.call(e);!(i=(t=r.next()).done)&&(o.push(t.value),2!==o.length);i=!0);}catch(e){a=!0,n=e}finally{try{i||null==r.return||r.return()}finally{if(a)throw n}}return o}}(t)||function(e){if(e){if("string"==typeof e)return l(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return l(e,2)}}(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.")}(),p=f[0],d=f[1];return((0,o.useEffect)(function(){var e=!0;return s.apiClient.resource("authenticators").publicList().then(function(t){var n;e&&d({authenticators:(null==t||null==(n=t.data)?void 0:n.data)||[],error:null,loading:!1})}).catch(function(t){e&&d({authenticators:[],error:t,loading:!1})}),function(){e=!1}},[s]),p.loading)?i().createElement("div",{style:{textAlign:"center",marginTop:20}},i().createElement(r.Spin,null)):p.error?i().createElement(r.Alert,{type:"error",showIcon:!0,message:(null==(n=p.error)?void 0:n.message)||"Failed to load authenticators"}):i().createElement(u.m.Provider,{value:p.authenticators},c)}},295:function(e,t,n){"use strict";n.d(t,{m:function(){return o},p:function(){return i}});var r=n(155),o=(0,r.createContext)([]);o.displayName="AuthenticatorsContext";var i=function(e){return(0,r.useContext)(o).find(function(t){return t.name===e})}},824:function(e,t,n){"use strict";n.d(t,{go:function(){return s},rN:function(){return c},wn:function(){return l}});var r=n(155),o=n(442),i=n(485);function a(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 u(e,t,n,r,o,i,a){try{var u=e[i](a),l=u.value}catch(e){n(e);return}u.done?t(l):Promise.resolve(l).then(r,o)}function l(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"/admin",n=(0,i.useApp)(),u=(0,o.useNavigate)(),l=(function(e){if(Array.isArray(e))return e}(e=(0,o.useSearchParams)())||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],i=!0,a=!1;try{for(r=r.call(e);!(i=(t=r.next()).done)&&(o.push(t.value),1!==o.length);i=!0);}catch(e){a=!0,n=e}finally{try{i||null==r.return||r.return()}finally{if(a)throw n}}return o}}(e)||function(e){if(e){if("string"==typeof e)return a(e,1);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return a(e,1)}}(e)||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,r.useCallback)(function(){var e,r;u(function(e,t){if(!t||"/"===t)return e.startsWith("/")?e:"/".concat(e);var n=t.endsWith("/")?t.slice(0,-1):t;return e===n?"/":e.startsWith("".concat(n,"/"))?e.slice(n.length)||"/":e}(l.get("redirect")||t,null==(e=(r=n.router).getBasename)?void 0:e.call(r)),{replace:!0})},[n.router,u,t,l])}function c(e){(0,r.useEffect)(function(){document.title=e},[e])}function s(e){var t=(0,i.useApp)(),n=l();return{run:function(r){var o;return(o=function(){return function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(a,"next",{value:l(0)}),u(a,"throw",{value:l(1)}),u(a,"return",{value:l(2)}),"function"==typeof Symbol&&u(a,Symbol.iterator,{value:function(){return this}}),a;function l(u){return function(l){var c=[u,l];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}(this,function(o){switch(o.label){case 0:return[4,t.apiClient.auth.signIn(r,e)];case 1:return o.sent(),[4,t.apiClient.request({url:"/auth:check",skipAuth:!0,skipNotify:!0}).catch(function(){})];case 2:return o.sent(),n(),[2]}})},function(){var e=this,t=arguments;return new Promise(function(n,r){var i=o.apply(e,t);function a(e){u(i,n,r,a,l,"next",e)}function l(e){u(i,n,r,a,l,"throw",e)}a(void 0)})})()}}}},488:function(e,t,n){"use strict";n.d(t,{CU:function(){return i},dE:function(){return a},kj:function(){return u}});var r=n(694),o=n(953),i="auth";function a(){return(0,o.useTranslation)([i,"client"],{nsMode:"fallback"})}function u(){var e=(0,r.useFlowEngine)();return function(t){return e.context.t(t,{ns:[i,"client"],nsMode:"fallback"})}}},375:function(e){"use strict";e.exports=r},230:function(e){"use strict";e.exports=n},485:function(e){"use strict";e.exports=a},694:function(e){"use strict";e.exports=o},768:function(e){"use strict";e.exports=c},6:function(e){"use strict";e.exports=i},59:function(e){"use strict";e.exports=l},773:function(e){"use strict";e.exports=s},155:function(e){"use strict";e.exports=u},953:function(t){"use strict";t.exports=e},442:function(e){"use strict";e.exports=t}},m={};function y(e){var t=m[e];if(void 0!==t)return t.exports;var n=m[e]={exports:{}};return h[e](n,n.exports,y),n.exports}y.m=h,y.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return y.d(t,{a:t}),t},y.d=function(e,t){for(var n in t)y.o(t,n)&&!y.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},y.f={},y.e=function(e){return Promise.all(Object.keys(y.f).reduce(function(t,n){return y.f[n](e,t),t},[]))},y.u=function(e){return""+e+"."+({217:"09744ff679406aff",657:"2a9dcca9ddc31ec0",795:"b26178560fd03daa",841:"ac9bfbb0615510e5",9:"c10c60a4ecc4256d"})[e]+".js"},y.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),y.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},v={},y.l=function(e,t,n,r){if(v[e])return void v[e].push(t);if(void 0!==n)for(var o,i,a=document.getElementsByTagName("script"),u=0;u<a.length;u++){var l=a[u];if(l.getAttribute("src")==e||l.getAttribute("data-rspack")=="@nocobase/plugin-auth/client-v2:"+n){o=l;break}}o||(i=!0,(o=document.createElement("script")).timeout=120,y.nc&&o.setAttribute("nonce",y.nc),o.setAttribute("data-rspack","@nocobase/plugin-auth/client-v2:"+n),o.src=e),v[e]=[t];var c=function(t,n){o.onerror=o.onload=null,clearTimeout(s);var r=v[e];if(delete v[e],o.parentNode&&o.parentNode.removeChild(o),r&&r.forEach(function(e){return e(n)}),t)return t(n)},s=setTimeout(c.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=c.bind(null,o.onerror),o.onload=c.bind(null,o.onload),i&&document.head.appendChild(o)},y.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},y.g.importScripts&&(b=y.g.location+"");var v,b,g=y.g.document;if(!b&&g&&(g.currentScript&&"SCRIPT"===g.currentScript.tagName.toUpperCase()&&(b=g.currentScript.src),!b)){var w=g.getElementsByTagName("script");if(w.length)for(var E=w.length-1;E>-1&&(!b||!/^http(s?):/.test(b));)b=w[E--].src}if(!b)throw Error("Automatic publicPath is not supported in this browser");y.p=b.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),f={889:0},y.f.j=function(e,t){var n=y.o(f,e)?f[e]:void 0;if(0!==n)if(n)t.push(n[2]);else{var r=new Promise(function(t,r){n=f[e]=[t,r]});t.push(n[2]=r);var o=y.p+y.u(e),i=Error();y.l(o,function(t){if(y.o(f,e)&&(0!==(n=f[e])&&(f[e]=void 0),n)){var r=t&&("load"===t.type?"missing":t.type),o=t&&t.target&&t.target.src;i.message="Loading chunk "+e+" failed.\n("+r+": "+o+")",i.name="ChunkLoadError",i.type=r,i.request=o,n[1](i)}},"chunk-"+e,e)}},p=function(e,t){var n,r,o=t[0],i=t[1],a=t[2],u=0;if(o.some(function(e){return 0!==f[e]})){for(n in i)y.o(i,n)&&(y.m[n]=i[n]);a&&a(y)}for(e&&e(t);u<o.length;u++)r=o[u],y.o(f,r)&&f[r]&&f[r][0](),f[r]=0},(d=self.webpackChunk_nocobase_plugin_auth_client_v2=self.webpackChunk_nocobase_plugin_auth_client_v2||[]).forEach(p.bind(null,0)),d.push=p.bind(null,d.push.bind(d));var S={};return!function(){"use strict";var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src){var n=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"");n.indexOf("/static/plugins/@nocobase/plugin-auth/dist/client-v2/")>=0&&(e=n.replace(/\/[^\/]+$/,"/"))}if(!e){var r=window.__webpack_public_path__||"";r&&("/"!==r.charAt(r.length-1)&&(r+="/"),e=r+"static/plugins/@nocobase/plugin-auth/dist/client-v2/")}if(!e){var o=window.__nocobase_modern_client_prefix__||"v",i="/"+(o=String(o).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var a=window.location.pathname||"/",u=a.indexOf(i);e=u>=0?a.slice(0,u+1):"/"}e&&(e=e.replace(RegExp("/"+o+"/?$"),"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@nocobase/plugin-auth/dist/client-v2/"}y.p=e}(),!function(){"use strict";y.r(S),y.d(S,{AuthLayout:function(){return o.default},AuthProvider:function(){return c.A},AuthenticatorsContext:function(){return t.m},AuthenticatorsContextProvider:function(){return s.A},ForgotPasswordPage:function(){return u.default},NAMESPACE:function(){return n.CU},PluginAuthClientV2:function(){return e.T},ResetPasswordPage:function(){return l.default},SignInPage:function(){return i.default},SignUpPage:function(){return a.default},default:function(){return e.A},useAuthTranslation:function(){return n.dE},useAuthenticator:function(){return t.p},useDocumentTitle:function(){return r.rN},useRedirect:function(){return r.wn},useSignIn:function(){return r.go},useT:function(){return n.kj}});var e=y(434),t=y(295),n=y(488),r=y(824),o=y(829),i=y(818),a=y(872),u=y(826),l=y(622),c=y(258),s=y(89)}(),S}()});
|
|
10
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react-i18next"),require("react-router-dom"),require("@formily/react"),require("@ant-design/icons"),require("@nocobase/flow-engine"),require("ahooks"),require("@nocobase/client-v2"),require("react"),require("antd"),require("@nocobase/utils/client"),require("lodash")):"function"==typeof define&&define.amd?define("@nocobase/plugin-auth/client-v2",["react-i18next","react-router-dom","@formily/react","@ant-design/icons","@nocobase/flow-engine","ahooks","@nocobase/client-v2","react","antd","@nocobase/utils/client","lodash"],t):"object"==typeof exports?exports["@nocobase/plugin-auth/client-v2"]=t(require("react-i18next"),require("react-router-dom"),require("@formily/react"),require("@ant-design/icons"),require("@nocobase/flow-engine"),require("ahooks"),require("@nocobase/client-v2"),require("react"),require("antd"),require("@nocobase/utils/client"),require("lodash")):e["@nocobase/plugin-auth/client-v2"]=t(e["react-i18next"],e["react-router-dom"],e["@formily/react"],e["@ant-design/icons"],e["@nocobase/flow-engine"],e.ahooks,e["@nocobase/client-v2"],e.react,e.antd,e["@nocobase/utils/client"],e.lodash)}(self,function(e,t,n,r,o,a,i,u,c,l,s){return function(){var f,p,h,d={432:function(e,t,n){e.exports=n(36).Symbol},77:function(e,t,n){var r=n(432),o=n(444),a=n(371),i=r?r.toStringTag:void 0;e.exports=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":i&&i in Object(e)?o(e):a(e)}},625:function(e,t,n){var r=n(531),o=/^\s+/;e.exports=function(e){return e?e.slice(0,r(e)+1).replace(o,""):e}},565:function(e,t,n){e.exports="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g},444:function(e,t,n){var r=n(432),o=Object.prototype,a=o.hasOwnProperty,i=o.toString,u=r?r.toStringTag:void 0;e.exports=function(e){var t=a.call(e,u),n=e[u];try{e[u]=void 0;var r=!0}catch(e){}var o=i.call(e);return r&&(t?e[u]=n:delete e[u]),o}},371:function(e){var t=Object.prototype.toString;e.exports=function(e){return t.call(e)}},36:function(e,t,n){var r=n(565),o="object"==typeof self&&self&&self.Object===Object&&self;e.exports=r||o||Function("return this")()},531:function(e){var t=/\s/;e.exports=function(e){for(var n=e.length;n--&&t.test(e.charAt(n)););return n}},738:function(e,t,n){var r=n(130),o=n(593),a=n(909),i=Math.max,u=Math.min;e.exports=function(e,t,n){var c,l,s,f,p,h,d=0,v=!1,y=!1,m=!0;if("function"!=typeof e)throw TypeError("Expected a function");function g(t){var n=c,r=l;return c=l=void 0,d=t,f=e.apply(r,n)}function b(e){var n=e-h,r=e-d;return void 0===h||n>=t||n<0||y&&r>=s}function w(){var e,n,r,a=o();if(b(a))return S(a);p=setTimeout(w,(e=a-h,n=a-d,r=t-e,y?u(r,s-n):r))}function S(e){return(p=void 0,m&&c)?g(e):(c=l=void 0,f)}function E(){var e,n=o(),r=b(n);if(c=arguments,l=this,h=n,r){if(void 0===p)return d=e=h,p=setTimeout(w,t),v?g(e):f;if(y)return clearTimeout(p),p=setTimeout(w,t),g(h)}return void 0===p&&(p=setTimeout(w,t)),f}return t=a(t)||0,r(n)&&(v=!!n.leading,s=(y="maxWait"in n)?i(a(n.maxWait)||0,t):s,m="trailing"in n?!!n.trailing:m),E.cancel=function(){void 0!==p&&clearTimeout(p),d=0,c=h=l=p=void 0},E.flush=function(){return void 0===p?f:S(o())},E}},130:function(e){e.exports=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}},189:function(e){e.exports=function(e){return null!=e&&"object"==typeof e}},733:function(e,t,n){var r=n(77),o=n(189);e.exports=function(e){return"symbol"==typeof e||o(e)&&"[object Symbol]"==r(e)}},593:function(e,t,n){var r=n(36);e.exports=function(){return r.Date.now()}},909:function(e,t,n){var r=n(625),o=n(130),a=n(733),i=0/0,u=/^[-+]0x[0-9a-f]+$/i,c=/^0b[01]+$/i,l=/^0o[0-7]+$/i,s=parseInt;e.exports=function(e){if("number"==typeof e)return e;if(a(e))return i;if(o(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=o(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=r(e);var n=c.test(e);return n||l.test(e)?s(e.slice(2),n?2:8):u.test(e)?i:+e}},829:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return s}});var r=n(59),o=n(155),a=n.n(o),i=n(442),u=n(953),c=n(485),l=n(89);function s(){var e,t=r.theme.useToken().token,n=((0,c.useSystemSettings)()||{}).data,o=(0,u.useTranslation)("lm-collections").t;return a().createElement("div",{style:{maxWidth:320,margin:"0 auto",paddingTop:"20vh",paddingBottom:"20vh"}},a().createElement("div",{style:{position:"fixed",top:t.paddingLG,right:t.paddingLG,color:t.colorText}},a().createElement(c.SwitchLanguage,null)),a().createElement("h1",{style:{textAlign:"center"}},o(null==n||null==(e=n.data)?void 0:e.title)),a().createElement(l.A,null,a().createElement(i.Outlet,null)),a().createElement("div",{style:{position:"absolute",bottom:0,left:0,width:"100%",paddingBottom:t.paddingLG,textAlign:"center",backgroundColor:t.colorBgContainer}},a().createElement(c.PoweredBy,null)))}},826:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return v}});var r=n(59),o=n(155),a=n.n(o),i=n(442),u=n(485),c=n(295),l=n(488),s=n(824),f=n(927);function p(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 h(e,t,n,r,o,a,i){try{var u=e[a](i),c=u.value}catch(e){n(e);return}u.done?t(c):Promise.resolve(c).then(r,o)}function d(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],i=!0,u=!1;try{for(o=o.call(e);!(i=(n=o.next()).done)&&(a.push(n.value),!t||a.length!==t);i=!0);}catch(e){u=!0,r=e}finally{try{i||null==o.return||o.return()}finally{if(u)throw r}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return p(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 p(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 v(){var e,t=(0,u.useApp)(),n=(0,l.dE)().t,p=d((0,i.useSearchParams)(),1)[0].get("name"),v=(0,c.p)(p),y=d(r.Form.useForm(),1)[0],m=d((0,o.useState)(!1),2),g=m[0],b=m[1],w=d((0,o.useState)(""),2),S=w[0],E=w[1],P=(0,f.f1)(t,"auth.signin");return((0,s.rN)(n("Reset password")),null==v||null==(e=v.options)?void 0:e.enableResetPassword)?a().createElement(r.Form,{form:y,layout:"vertical",onFinish:function(e){var o;return(o=function(){var o,a,i,u,c;return function(e,t){var n,r,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(i,"next",{value:c(0)}),u(i,"throw",{value:c(1)}),u(i,"return",{value:c(2)}),"function"==typeof Symbol&&u(i,Symbol.iterator,{value:function(){return this}}),i;function c(u){return function(c){var l=[u,c];if(n)throw TypeError("Generator is already executing.");for(;i&&(i=0,l[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&l[0]?r.return:l[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,l[1])).done)return o;switch(r=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return a.label++,{value:l[1],done:!1};case 5:a.label++,r=l[1],l=[0];continue;case 7:l=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){a=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){a.label=l[1];break}if(6===l[0]&&a.label<o[1]){a.label=o[1],o=l;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(l);break}o[2]&&a.ops.pop(),a.trys.pop();continue}l=t.call(e,a)}catch(e){l=[6,e],r=0}finally{n=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}(this,function(l){switch(l.label){case 0:E(""),b(!0),l.label=1;case 1:return l.trys.push([1,3,4,5]),[4,t.apiClient.auth.lostPassword(e)];case 2:return l.sent(),r.message.success(n("Reset email sent successfully")),y.resetFields(),[3,5];case 3:return E((null==(o=l.sent())||null==(c=o.response)||null==(u=c.data)||null==(i=u.errors)||null==(a=i[0])?void 0:a.message)||(null==o?void 0:o.message)||String(o)),[3,5];case 4:return b(!1),[7];case 5:return[2]}})},function(){var e=this,t=arguments;return new Promise(function(n,r){var a=o.apply(e,t);function i(e){h(a,n,r,i,u,"next",e)}function u(e){h(a,n,r,i,u,"throw",e)}i(void 0)})})()}},S?a().createElement(r.Alert,{style:{marginBottom:16},type:"error",showIcon:!0,message:S}):null,a().createElement(r.Form.Item,{label:n("Reset password"),name:"email",rules:[{required:!0,message:n("Please fill in your email address")},{type:"email",message:n("Please enter a valid email")}]},a().createElement(r.Input,{placeholder:n("Please enter your email")})),a().createElement(r.Form.Item,{style:{marginBottom:12}},a().createElement(r.Button,{loading:g,htmlType:"submit",type:"primary",block:!0},n("Send reset email"))),a().createElement(i.Link,{to:P},n("Back to login"))):a().createElement(i.Navigate,{to:P,replace:!0})}},622:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return v}});var r=n(59),o=n(155),a=n.n(o),i=n(442),u=n(485),c=n(295),l=n(488),s=n(824),f=n(927);function p(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 h(e,t,n,r,o,a,i){try{var u=e[a](i),c=u.value}catch(e){n(e);return}u.done?t(c):Promise.resolve(c).then(r,o)}function d(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],i=!0,u=!1;try{for(o=o.call(e);!(i=(n=o.next()).done)&&(a.push(n.value),!t||a.length!==t);i=!0);}catch(e){u=!0,r=e}finally{try{i||null==o.return||o.return()}finally{if(u)throw r}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return p(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 p(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 v(){var e,t=(0,u.useApp)(),n=(0,l.dE)().t,p=(0,i.useNavigate)(),v=d((0,i.useSearchParams)(),1)[0],y=v.get("resetToken"),m=v.get("name"),g=(0,c.p)(m),b=d(r.Form.useForm(),1)[0],w=d((0,o.useState)(!1),2),S=w[0],E=w[1],P=d((0,o.useState)(!0),2),k=P[0],A=P[1],O=d((0,o.useState)(!1),2),x=O[0],T=O[1],j=d((0,o.useState)(""),2),_=j[0],I=j[1],C=(0,f.f1)(t,"auth.signin");return((0,s.rN)(n("Reset password")),(0,o.useEffect)(function(){var e=!0;if(!y){E(!0),A(!1);return}return t.apiClient.auth.checkResetToken({resetToken:y}).then(function(){e&&(E(!1),A(!1))}).catch(function(){e&&(E(!0),A(!1))}),function(){e=!1}},[t,y]),null==g||null==(e=g.options)?void 0:e.enableResetPassword)?k||y&&!S?a().createElement(r.Form,{form:b,layout:"vertical",onFinish:function(e){var o;return(o=function(){var o,a,i,u,c;return function(e,t){var n,r,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(i,"next",{value:c(0)}),u(i,"throw",{value:c(1)}),u(i,"return",{value:c(2)}),"function"==typeof Symbol&&u(i,Symbol.iterator,{value:function(){return this}}),i;function c(u){return function(c){var l=[u,c];if(n)throw TypeError("Generator is already executing.");for(;i&&(i=0,l[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&l[0]?r.return:l[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,l[1])).done)return o;switch(r=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return a.label++,{value:l[1],done:!1};case 5:a.label++,r=l[1],l=[0];continue;case 7:l=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){a=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){a.label=l[1];break}if(6===l[0]&&a.label<o[1]){a.label=o[1],o=l;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(l);break}o[2]&&a.ops.pop(),a.trys.pop();continue}l=t.call(e,a)}catch(e){l=[6,e],r=0}finally{n=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}(this,function(l){switch(l.label){case 0:I(""),T(!0),l.label=1;case 1:var s,f;return l.trys.push([1,3,4,5]),[4,t.apiClient.auth.resetPassword((s=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;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},e),f=f={resetToken:y},Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(f)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(f)).forEach(function(e){Object.defineProperty(s,e,Object.getOwnPropertyDescriptor(f,e))}),s))];case 2:return l.sent(),r.message.success(n("Password reset successful")),window.setTimeout(function(){p(C,{replace:!0})},1e3),[3,5];case 3:return I((null==(o=l.sent())||null==(c=o.response)||null==(u=c.data)||null==(i=u.errors)||null==(a=i[0])?void 0:a.message)||(null==o?void 0:o.message)||String(o)),[3,5];case 4:return T(!1),[7];case 5:return[2]}})},function(){var e=this,t=arguments;return new Promise(function(n,r){var a=o.apply(e,t);function i(e){h(a,n,r,i,u,"next",e)}function u(e){h(a,n,r,i,u,"throw",e)}i(void 0)})})()}},_?a().createElement(r.Alert,{style:{marginBottom:16},type:"error",showIcon:!0,message:_}):null,a().createElement(r.Form.Item,{label:n("New password"),name:"password",rules:[{required:!0,message:n("Please enter new password")}]},a().createElement(r.Input.Password,{autoComplete:"new-password"})),a().createElement(r.Form.Item,{label:n("Confirm password"),name:"confirmPassword",dependencies:["password"],rules:[{required:!0,message:n("Please enter the same password again")},function(e){var t=e.getFieldValue;return{validator:function(e,r){return r&&t("password")!==r?Promise.reject(Error(n("The passwords entered twice are inconsistent"))):Promise.resolve()}}}]},a().createElement(r.Input.Password,{autoComplete:"new-password"})),a().createElement(r.Form.Item,{style:{marginBottom:12}},a().createElement(r.Button,{loading:x||k,htmlType:"submit",type:"primary",block:!0},n("Confirm"))),a().createElement(i.Link,{to:C},n("Go to login"))):a().createElement(r.Result,{status:"403",title:n("Reset link has expired"),extra:a().createElement(r.Button,{type:"primary",onClick:function(){return p(C)}},n("Go to login"))}):a().createElement(i.Navigate,{to:C,replace:!0})}},818:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return v}});var r=n(485),o=n(59),a=n(155),i=n.n(a),u=n(442),c=n(295),l=n(824),s=n(488),f=n(434);function p(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 h(e){var t=(0,r.usePlugin)(f.A);return(0,a.useMemo)(function(){var n={},r=!0,o=!1,a=void 0;try{for(var i,u=t.authTypes.getEntities()[Symbol.iterator]();!(r=(i=u.next()).done);r=!0){var c,l=(c=i.value,function(e){if(Array.isArray(e))return e}(c)||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],a=!0,i=!1;try{for(r=r.call(e);!(a=(t=r.next()).done)&&(o.push(t.value),2!==o.length);a=!0);}catch(e){i=!0,n=e}finally{try{a||null==r.return||r.return()}finally{if(i)throw n}}return o}}(c)||function(e){if(e){if("string"==typeof e)return p(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return p(e,2)}}(c)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),s=l[0],f=l[1][e];f&&(n[s]=f)}}catch(e){o=!0,a=e}finally{try{r||null==u.return||u.return()}finally{if(o)throw a}}return n},[t,e])}function d(e){var t=new Map;return function(n){if(e[n])return t.has(n)||t.set(n,(0,a.lazy)(e[n])),t.get(n)}}function v(){var e=(0,r.useApp)(),t=(0,r.usePlugin)(f.A),n=(0,u.useLocation)(),p=(0,u.useNavigate)(),v=(0,s.dE)().t,y=(0,s.kj)(),m=(0,a.useContext)(c.m),g=h("signInFormLoader"),b=h("signInButtonLoader"),w=(0,a.useMemo)(function(){return d(g)},[g]),S=(0,a.useMemo)(function(){return d(b)},[b]),E=t.getAuthRedirectFallbackPath(n.pathname);(0,l.rN)(v("Signin")),(0,a.useEffect)(function(){var t=new URLSearchParams(n.search),o=t.get("redirect"),a=(0,r.normalizeV2RedirectPath)(e,o,E);o!==a&&(t.set("redirect",a),p({pathname:n.pathname,search:"?".concat(t)},{replace:!0}))},[e,E,n.pathname,n.search,p]);var P=(0,a.useMemo)(function(){return m.map(function(e){var t=w(e.authType);if(!t)return null;var n=y(e.authTypeTitle||e.authType);return{key:e.name,label:e.title||"".concat(v("Sign-in")," (").concat(n,")"),children:i().createElement(a.Suspense,{fallback:i().createElement(o.Spin,null)},i().createElement(t,{authenticator:e}))}}).filter(Boolean)},[m,w,v,y]),k=(0,a.useMemo)(function(){return m.map(function(e,t){var n=S(e.authType);return n?i().createElement(a.Suspense,{key:"".concat(e.name,"-").concat(t),fallback:i().createElement(o.Spin,null)},i().createElement(n,{authenticator:e})):null}).filter(Boolean)},[m,S]);return m.length?i().createElement(o.Space,{direction:"vertical",style:{display:"flex"}},P.length>1?i().createElement(o.Tabs,{items:P}):P.length?P[0].children:null,k.length?i().createElement(o.Space,{direction:"vertical",style:{display:"flex"}},k):null):i().createElement(o.Empty,{description:v("No authentication methods available.")})}},872:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return h}});var r=n(485),o=n(59),a=n(155),i=n.n(a),u=n(442),c=n(295),l=n(824),s=n(488),f=n(434);function p(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 h(){var e,t=(0,s.dE)().t,n=((function(e){if(Array.isArray(e))return e})(e=(0,u.useSearchParams)())||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],a=!0,i=!1;try{for(r=r.call(e);!(a=(t=r.next()).done)&&(o.push(t.value),1!==o.length);a=!0);}catch(e){i=!0,n=e}finally{try{a||null==r.return||r.return()}finally{if(i)throw n}}return o}}(e)||function(e){if(e){if("string"==typeof e)return p(e,1);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return p(e,1)}}(e)||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].get("name"),h=(0,c.p)(n),d=(0,r.usePlugin)(f.A),v=(0,a.useMemo)(function(){if(!h)return null;var e,t=null==(e=d.authTypes.get(h.authType))?void 0:e.signUpFormLoader;return t?(0,a.lazy)(t):null},[h,d]);return((0,l.rN)(t("Signup")),h&&v)?i().createElement(a.Suspense,{fallback:i().createElement(o.Spin,null)},i().createElement(v,{authenticatorName:h.name})):i().createElement(o.Empty,{description:t("No authentication methods available.")})}},434:function(e,t,n){"use strict";n.d(t,{A:function(){return j},T:function(){return T}});var r=n(768),o=n(485),a=n(738),i=n.n(a),u=n(927),c=n(258),l=n(488);function s(e,t,n,r,o,a,i){try{var u=e[a](i),c=u.value}catch(e){n(e);return}u.done?t(c):Promise.resolve(c).then(r,o)}function f(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function i(e){s(a,r,o,i,u,"next",e)}function u(e){s(a,r,o,i,u,"throw",e)}i(void 0)})}}function p(e,t,n){return t=g(t),function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e,E()?Reflect.construct(t,n||[],g(e).constructor):t.apply(e,n))}function h(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}function d(e,t,n){return(d=E()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&w(o,n.prototype),o}).apply(null,arguments)}function v(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 y(e,t,n){return t&&v(e.prototype,t),n&&v(e,n),e}function m(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function g(e){return(g=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function b(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&&w(e,t)}function w(e,t){return(w=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function S(e){var t="function"==typeof Map?new Map:void 0;return(S=function(e){if(null===e||-1===Function.toString.call(e).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,n)}function n(){return d(e,arguments,g(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),w(n,e)})(e)}function E(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(E=function(){return!!e})()}function P(e,t){var n,r,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(i,"next",{value:c(0)}),u(i,"throw",{value:c(1)}),u(i,"return",{value:c(2)}),"function"==typeof Symbol&&u(i,Symbol.iterator,{value:function(){return this}}),i;function c(u){return function(c){var l=[u,c];if(n)throw TypeError("Generator is already executing.");for(;i&&(i=0,l[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&l[0]?r.return:l[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,l[1])).done)return o;switch(r=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return a.label++,{value:l[1],done:!1};case 5:a.label++,r=l[1],l=[0];continue;case 7:l=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){a=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){a.label=l[1];break}if(6===l[0]&&a.label<o[1]){a.label=o[1],o=l;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(l);break}o[2]&&a.ops.pop(),a.trys.pop();continue}l=t.call(e,a)}catch(e){l=[6,e],r=0}finally{n=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}var k=function(e){function t(){var e;return h(this,t),e=p(this,t,arguments),m(e,"section","preferences"),m(e,"sort",350),m(e,"label","Language"),e}return b(t,e),y(t,[{key:"prepare",value:function(){return f(function(){var e,t,n,r,a;return P(this,function(i){switch(i.label){case 0:return[4,this.context.systemSettings.load()];case 1:return a=(null==(r=i.sent())||null==(e=r.data)?void 0:e.enabledLanguages)||[],this.options=a.map(function(e){var t;return{value:e,label:(null==(t=o.languageCodes[e])?void 0:t.label)||e}}),this.value=(null==(t=(n=this.context.app.apiClient.auth).getLocale)?void 0:t.call(n))||this.context.app.apiClient.auth.locale,this.ready=this.options.length>1,[2]}})}).call(this)}},{key:"onChange",value:function(e){return f(function(){return P(this,function(t){return this.context.app.apiClient.auth.setLocale(e),window.location.reload(),[2]})}).call(this)}}]),t}(o.UserCenterSelectItemModel);function A(e){var t="/".concat(e.trim().replace(/^\/+|\/+$/g,""));return"/"===t?t:t.replace(/\/+$/g,"")}m(k,"itemId","language");var O={EMPTY_TOKEN:"EMPTY_TOKEN",EXPIRED_TOKEN:"EXPIRED_TOKEN",INVALID_TOKEN:"INVALID_TOKEN",TOKEN_RENEW_FAILED:"TOKEN_RENEW_FAILED",BLOCKED_TOKEN:"BLOCKED_TOKEN",EXPIRED_SESSION:"EXPIRED_SESSION",NOT_EXIST_USER:"NOT_EXIST_USER",SKIP_TOKEN_RENEW:"SKIP_TOKEN_RENEW",USER_HAS_NO_ROLES_ERR:"USER_HAS_NO_ROLES_ERR"},x=i()(function(e){e()},3e3,{leading:!0,trailing:!1}),T=function(e){function t(){var e;return h(this,t),e=p(this,t,arguments),m(e,"authTypes",new r.Registry),m(e,"authRouteScopes",new Map),e}return b(t,e),y(t,[{key:"registerType",value:function(e,t){this.authTypes.register(e,t)}},{key:"registerSignInRoute",value:function(e,t){this.router.add("auth.".concat(e),{path:t,skipAuthCheck:!0,componentLoader:function(){return Promise.resolve().then(n.bind(n,818))}})}},{key:"registerAuthRouteScope",value:function(e,t,r){var o=A(t),a="/"===o?"":o,i={basePath:o,"auth.signin":"".concat(a,"/signin"),"auth.signup":"".concat(a,"/signup")};this.authRouteScopes.set(e,i),this.registerSignInRoute((null==r?void 0:r.signin)||"".concat(e,"Signin"),i["auth.signin"]),this.router.add("auth.".concat((null==r?void 0:r.signup)||"".concat(e,"Signup")),{path:i["auth.signup"],skipAuthCheck:!0,componentLoader:function(){return Promise.resolve().then(n.bind(n,872))}})}},{key:"getAuthRoutePath",value:function(e,t){var n=A(e),r=!0,o=!1,a=void 0;try{for(var i,c=this.authRouteScopes.values()[Symbol.iterator]();!(r=(i=c.next()).done);r=!0){var l=i.value;if(l["auth.signin"]===n||l["auth.signup"]===n)return"auth.signin"===t||"auth.signup"===t?l[t]:(0,u.f1)(this.app,t)}}catch(e){o=!0,a=e}finally{try{r||null==c.return||c.return()}finally{if(o)throw a}}return(0,u.f1)(this.app,t)}},{key:"isScopedAuthRoute",value:function(e){var t=A(e),n=!0,r=!1,o=void 0;try{for(var a,i=this.authRouteScopes.values()[Symbol.iterator]();!(n=(a=i.next()).done);n=!0){var u=a.value;if(u["auth.signin"]===t||u["auth.signup"]===t)return!0}}catch(e){r=!0,o=e}finally{try{n||null==i.return||i.return()}finally{if(r)throw o}}return!1}},{key:"getAuthRedirectFallbackPath",value:function(e){var t=A(e),n=!0,r=!1,o=void 0;try{for(var a,i=this.authRouteScopes.values()[Symbol.iterator]();!(n=(a=i.next()).done);n=!0){var c=a.value;if(c["auth.signin"]===t)return c.basePath}}catch(e){r=!0,o=e}finally{try{n||null==i.return||i.return()}finally{if(r)throw o}}return(0,u.Fo)(this.app)}},{key:"load",value:function(){return f(function(){return P(this,function(e){return this.app.providers.unshift([c.A,{}]),this.app.flowEngine.registerModels({UserCenterLanguageItemModel:k}),this.addRoutes(),this.registerPresetAuthType(),this.registerSettingsPages(),this.installInterceptors(),[2]})}).call(this)}},{key:"registerSettingsPages",value:function(){var e=this,t=function(t){return e.app.i18n.t(t,{ns:l.CU})};this.pluginSettingsManager.addMenuItem({key:l.CU,title:t("Authentication"),icon:"LoginOutlined",aclSnippet:"pm.auth"}),this.pluginSettingsManager.addPageTabItem({menuKey:l.CU,key:"authenticators",title:t("Authenticators"),icon:"LoginOutlined",aclSnippet:"pm.auth.authenticators",sort:1,componentLoader:function(){return n.e("9").then(n.bind(n,648))}}),this.pluginSettingsManager.addPageTabItem({menuKey:"security",key:"token-policy",title:t("Token policy"),icon:"ApiOutlined",aclSnippet:"pm.security.token-policy",sort:0,componentLoader:function(){return n.e("657").then(n.bind(n,632))}})}},{key:"addRoutes",value:function(){this.router.add("auth",{componentLoader:function(){return Promise.resolve().then(n.bind(n,829))}}),this.router.add("auth.signin",{path:"/signin",skipAuthCheck:!0,componentLoader:function(){return Promise.resolve().then(n.bind(n,818))}}),this.router.add("auth.signup",{path:"/signup",skipAuthCheck:!0,componentLoader:function(){return Promise.resolve().then(n.bind(n,872))}}),this.router.add("auth.forgotPassword",{path:"/forgot-password",skipAuthCheck:!0,componentLoader:function(){return Promise.resolve().then(n.bind(n,826))}}),this.router.add("auth.resetPassword",{path:"/reset-password",skipAuthCheck:!0,componentLoader:function(){return Promise.resolve().then(n.bind(n,622))}})}},{key:"registerPresetAuthType",value:function(){this.registerType("Email/Password",{signInFormLoader:function(){return n.e("795").then(n.bind(n,918))},signUpFormLoader:function(){return n.e("841").then(n.bind(n,720))},adminSettingsFormLoader:function(){return n.e("217").then(n.bind(n,264))}})}},{key:"installInterceptors",value:function(){var e=this;this.app.apiClient.axios.interceptors.response.handlers.unshift({fulfilled:function(t){var n,r=null==t||null==(n=t.headers)?void 0:n["x-new-token"];return r&&e.app.apiClient.auth.setToken(r),t},rejected:function(t){var n,r,a,i,c,l,s,f,p=null==t||null==(r=t.response)||null==(n=r.headers)?void 0:n["x-new-token"],h=null==t||null==(i=t.response)||null==(a=i.data)?void 0:a.errors,d=Array.isArray(h)?h[0]:null,v=(null==(l=e.app.router.router)||null==(c=l.state)?void 0:c.location)||window.location,y=(null==v?void 0:v.pathname)||window.location.pathname,m=(null==t?void 0:t.status)||(null==t||null==(s=t.response)?void 0:s.status);if(p&&e.app.apiClient.auth.setToken(p),401===m&&(null==d?void 0:d.code)&&O[null==d?void 0:d.code]&&(e.app.apiClient.auth.setToken(""),e.app.apiClient.auth.setRole(""),e.app.apiClient.auth.setAuthenticator("")),401===m&&!(null==(f=t.config)?void 0:f.skipAuth)&&(null==d?void 0:d.code)&&O[null==d?void 0:d.code]){if((null==d?void 0:d.code)===O.SKIP_TOKEN_RENEW)throw t;var g=e.app.router.isSkippedAuthCheckRoute(y);if(g&&(t.config.skipNotify=!0),!g){var b=(0,o.getCurrentV2RedirectPath)(e.app,v);return x(function(){if(e.app.apiClient.auth.setToken(""),(0,u.Py)(e.app))(0,o.redirectToV2Signin)(e.app,b);else{var t=(0,o.resolveUnauthenticatedSignInRoute)(e.app,y);e.app.router.navigate("".concat(t,"?redirect=").concat(encodeURIComponent(b)),{replace:!0})}}),new Promise(function(){})}}throw t},synchronous:!1,runWhen:null})}}]),t}(S(o.Plugin)),j=T},258:function(e,t,n){"use strict";var r=n(485),o=n(155),a=n.n(o),i=n(442);t.A=function(e){var t=e.children,n=(0,r.useApp)(),u=(0,i.useNavigate)(),c=(0,i.useLocation)();return(0,o.useEffect)(function(){var e=new URLSearchParams(c.search),t=e.get("token"),r=e.get("authenticator");if(t){n.apiClient.auth.setToken(t),n.apiClient.auth.setAuthenticator(r),e.delete("token"),e.delete("authenticator");var o=e.toString();u({pathname:c.pathname,search:o?"?".concat(o):""},{replace:!0})}},[n,c.pathname,c.search,u]),a().createElement(a().Fragment,null,t)}},89:function(e,t,n){"use strict";var r=n(59),o=n(155),a=n.n(o),i=n(485),u=n(295);function c(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}t.A=function(e){var t,n,l=e.children,s=(0,i.useApp)(),f=function(e){if(Array.isArray(e))return e}(t=(0,o.useState)({authenticators:[],error:null,loading:!0}))||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],a=!0,i=!1;try{for(r=r.call(e);!(a=(t=r.next()).done)&&(o.push(t.value),2!==o.length);a=!0);}catch(e){i=!0,n=e}finally{try{a||null==r.return||r.return()}finally{if(i)throw n}}return o}}(t)||function(e){if(e){if("string"==typeof e)return c(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return c(e,2)}}(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.")}(),p=f[0],h=f[1];return((0,o.useEffect)(function(){var e=!0;return s.apiClient.resource("authenticators").publicList().then(function(t){var n;e&&h({authenticators:(null==t||null==(n=t.data)?void 0:n.data)||[],error:null,loading:!1})}).catch(function(t){e&&h({authenticators:[],error:t,loading:!1})}),function(){e=!1}},[s]),p.loading)?a().createElement("div",{style:{textAlign:"center",marginTop:20}},a().createElement(r.Spin,null)):p.error?a().createElement(r.Alert,{type:"error",showIcon:!0,message:(null==(n=p.error)?void 0:n.message)||"Failed to load authenticators"}):a().createElement(u.m.Provider,{value:p.authenticators},l)}},927:function(e,t,n){"use strict";n.d(t,{Fo:function(){return i},Py:function(){return a},f1:function(){return o}});var r={"auth.signin":"/signin","auth.signup":"/signup","auth.forgotPassword":"/forgot-password","auth.resetPassword":"/reset-password"};function o(e,t){var n,o=null==(n=e.router.get(t))?void 0:n.path;return"string"==typeof o?o:r[t]}function a(e){return"settings."===e.pluginSettingsManager.getRouteName("")}function i(e){return a(e)?e.pluginSettingsManager.getRoutePath(""):"/"}},295:function(e,t,n){"use strict";n.d(t,{m:function(){return o},p:function(){return a}});var r=n(155),o=(0,r.createContext)([]);o.displayName="AuthenticatorsContext";var a=function(e){return(0,r.useContext)(o).find(function(t){return t.name===e})}},824:function(e,t,n){"use strict";n.d(t,{go:function(){return p},rN:function(){return f},wn:function(){return s}});var r=n(155),o=n(442),a=n(485),i=n(927);function u(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 c(e,t,n,r,o,a,i){try{var u=e[a](i),c=u.value}catch(e){n(e);return}u.done?t(c):Promise.resolve(c).then(r,o)}function l(e){var t=new URL("/".concat(String(e||"/").trim()).replace(/\/{2,}/g,"/"),window.location.origin).pathname;return"/"===t?t:t.replace(/\/+$/,"")}function s(e){var t,n=(0,a.useApp)(),c=(0,o.useNavigate)(),s=(function(e){if(Array.isArray(e))return e}(t=(0,o.useSearchParams)())||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],a=!0,i=!1;try{for(r=r.call(e);!(a=(t=r.next()).done)&&(o.push(t.value),1!==o.length);a=!0);}catch(e){i=!0,n=e}finally{try{a||null==r.return||r.return()}finally{if(i)throw n}}return o}}(t)||function(e){if(e){if("string"==typeof e)return u(e,1);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return u(e,1)}}(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,r.useCallback)(function(){var t,r,o=s.get("redirect"),u=e||(0,i.Fo)(n),f=o||void 0===e&&(0,i.Py)(n)?(0,a.normalizeV2RedirectPath)(n,o,u):u;!function(e,t){if(!t.startsWith("/")||t.startsWith("//")||t.startsWith("/\\"))return!1;var n,r,o,a,u,c,s=null==(u=(c=e.router).getBasename)?void 0:u.call(c),f=l(e.getPublicPath()),p=(r=l(f).replace(/\/+$/,""),o=l(s||"/"),a=r&&(o===r||o.startsWith("".concat(r,"/")))?o.slice(r.length)||"/":o,(null==(n=/^\/settings(\/(?:apps|_app)\/[^/]+)(?=\/|$)/.exec(a))?void 0:n[1])||""),h=f.split("/");(0,i.Py)(e)||h.pop();var d=l(h.join("/")||"/").replace(/\/+$/,""),v=p?"".concat(d,"/settings").concat(p):"".concat(d,"/settings")||"/settings",y=l(t.split(/[?#]/)[0]);return y===v||y.startsWith("".concat(v,"/"))}(n,f)?c(function(e,t){if(!t||"/"===t)return e.startsWith("/")?e:"/".concat(e);var n=t.endsWith("/")?t.slice(0,-1):t;return e===n?"/":e.startsWith("".concat(n,"/"))?e.slice(n.length)||"/":e}(f,null==(t=(r=n.router).getBasename)?void 0:t.call(r)),{replace:!0}):window.location.replace(f)},[n,c,e,s])}function f(e){(0,r.useEffect)(function(){document.title=e},[e])}function p(e){var t=(0,a.useApp)(),n=s();return{run:function(r){var o;return(o=function(){return function(e,t){var n,r,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(i,"next",{value:c(0)}),u(i,"throw",{value:c(1)}),u(i,"return",{value:c(2)}),"function"==typeof Symbol&&u(i,Symbol.iterator,{value:function(){return this}}),i;function c(u){return function(c){var l=[u,c];if(n)throw TypeError("Generator is already executing.");for(;i&&(i=0,l[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&l[0]?r.return:l[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,l[1])).done)return o;switch(r=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return a.label++,{value:l[1],done:!1};case 5:a.label++,r=l[1],l=[0];continue;case 7:l=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){a=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){a.label=l[1];break}if(6===l[0]&&a.label<o[1]){a.label=o[1],o=l;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(l);break}o[2]&&a.ops.pop(),a.trys.pop();continue}l=t.call(e,a)}catch(e){l=[6,e],r=0}finally{n=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}(this,function(o){switch(o.label){case 0:return[4,t.apiClient.auth.signIn(r,e)];case 1:return o.sent(),[4,t.apiClient.request({url:"/auth:check",skipAuth:!0,skipNotify:!0}).catch(function(){})];case 2:return o.sent(),n(),[2]}})},function(){var e=this,t=arguments;return new Promise(function(n,r){var a=o.apply(e,t);function i(e){c(a,n,r,i,u,"next",e)}function u(e){c(a,n,r,i,u,"throw",e)}i(void 0)})})()}}}},488:function(e,t,n){"use strict";n.d(t,{CU:function(){return a},dE:function(){return i},kj:function(){return u}});var r=n(694),o=n(953),a="auth";function i(){return(0,o.useTranslation)([a,"client"],{nsMode:"fallback"})}function u(){var e=(0,r.useFlowEngine)();return function(t){return e.context.t(t,{ns:[a,"client"],nsMode:"fallback"})}}},375:function(e){"use strict";e.exports=r},230:function(e){"use strict";e.exports=n},485:function(e){"use strict";e.exports=i},694:function(e){"use strict";e.exports=o},768:function(e){"use strict";e.exports=l},6:function(e){"use strict";e.exports=a},59:function(e){"use strict";e.exports=c},773:function(e){"use strict";e.exports=s},155:function(e){"use strict";e.exports=u},953:function(t){"use strict";t.exports=e},442:function(e){"use strict";e.exports=t}},v={};function y(e){var t=v[e];if(void 0!==t)return t.exports;var n=v[e]={exports:{}};return d[e](n,n.exports,y),n.exports}y.m=d,y.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return y.d(t,{a:t}),t},y.d=function(e,t){for(var n in t)y.o(t,n)&&!y.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},y.f={},y.e=function(e){return Promise.all(Object.keys(y.f).reduce(function(t,n){return y.f[n](e,t),t},[]))},y.u=function(e){return""+e+"."+({217:"1510705562d97555",657:"2a9dcca9ddc31ec0",795:"8e4b138118e322ab",841:"9fafcb7049bfe687",9:"c10c60a4ecc4256d"})[e]+".js"},y.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),y.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},m={},y.l=function(e,t,n,r){if(m[e])return void m[e].push(t);if(void 0!==n)for(var o,a,i=document.getElementsByTagName("script"),u=0;u<i.length;u++){var c=i[u];if(c.getAttribute("src")==e||c.getAttribute("data-rspack")=="@nocobase/plugin-auth/client-v2:"+n){o=c;break}}o||(a=!0,(o=document.createElement("script")).timeout=120,y.nc&&o.setAttribute("nonce",y.nc),o.setAttribute("data-rspack","@nocobase/plugin-auth/client-v2:"+n),o.src=e),m[e]=[t];var l=function(t,n){o.onerror=o.onload=null,clearTimeout(s);var r=m[e];if(delete m[e],o.parentNode&&o.parentNode.removeChild(o),r&&r.forEach(function(e){return e(n)}),t)return t(n)},s=setTimeout(l.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=l.bind(null,o.onerror),o.onload=l.bind(null,o.onload),a&&document.head.appendChild(o)},y.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},y.g.importScripts&&(g=y.g.location+"");var m,g,b=y.g.document;if(!g&&b&&(b.currentScript&&"SCRIPT"===b.currentScript.tagName.toUpperCase()&&(g=b.currentScript.src),!g)){var w=b.getElementsByTagName("script");if(w.length)for(var S=w.length-1;S>-1&&(!g||!/^http(s?):/.test(g));)g=w[S--].src}if(!g)throw Error("Automatic publicPath is not supported in this browser");y.p=g.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),f={889:0},y.f.j=function(e,t){var n=y.o(f,e)?f[e]:void 0;if(0!==n)if(n)t.push(n[2]);else{var r=new Promise(function(t,r){n=f[e]=[t,r]});t.push(n[2]=r);var o=y.p+y.u(e),a=Error();y.l(o,function(t){if(y.o(f,e)&&(0!==(n=f[e])&&(f[e]=void 0),n)){var r=t&&("load"===t.type?"missing":t.type),o=t&&t.target&&t.target.src;a.message="Loading chunk "+e+" failed.\n("+r+": "+o+")",a.name="ChunkLoadError",a.type=r,a.request=o,n[1](a)}},"chunk-"+e,e)}},p=function(e,t){var n,r,o=t[0],a=t[1],i=t[2],u=0;if(o.some(function(e){return 0!==f[e]})){for(n in a)y.o(a,n)&&(y.m[n]=a[n]);i&&i(y)}for(e&&e(t);u<o.length;u++)r=o[u],y.o(f,r)&&f[r]&&f[r][0](),f[r]=0},(h=self.webpackChunk_nocobase_plugin_auth_client_v2=self.webpackChunk_nocobase_plugin_auth_client_v2||[]).forEach(p.bind(null,0)),h.push=p.bind(null,h.push.bind(h));var E={};return!function(){"use strict";var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src){var n=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"");n.indexOf("/static/plugins/@nocobase/plugin-auth/dist/client-v2/")>=0&&(e=n.replace(/\/[^\/]+$/,"/"))}if(!e){var r=window.__webpack_public_path__||"";r&&("/"!==r.charAt(r.length-1)&&(r+="/"),e=r+"static/plugins/@nocobase/plugin-auth/dist/client-v2/")}if(!e){var o=window.__nocobase_modern_client_prefix__||"v",a="/"+(o=String(o).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var i=window.location.pathname||"/",u=i.indexOf(a);e=u>=0?i.slice(0,u+1):"/"}e&&(e=e.replace(RegExp("/"+o+"/?$"),"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@nocobase/plugin-auth/dist/client-v2/"}y.p=e}(),!function(){"use strict";y.r(E),y.d(E,{AuthLayout:function(){return o.default},AuthProvider:function(){return l.A},AuthenticatorsContext:function(){return t.m},AuthenticatorsContextProvider:function(){return s.A},ForgotPasswordPage:function(){return u.default},NAMESPACE:function(){return n.CU},PluginAuthClientV2:function(){return e.T},ResetPasswordPage:function(){return c.default},SignInPage:function(){return a.default},SignUpPage:function(){return i.default},default:function(){return e.A},useAuthTranslation:function(){return n.dE},useAuthenticator:function(){return t.p},useDocumentTitle:function(){return r.rN},useRedirect:function(){return r.wn},useSignIn:function(){return r.go},useT:function(){return n.kj}});var e=y(434),t=y(295),n=y(488),r=y(824),o=y(829),a=y(818),i=y(872),u=y(826),c=y(622),l=y(258),s=y(89)}(),E}()});
|
|
@@ -9,9 +9,14 @@
|
|
|
9
9
|
import type { ComponentType } from 'react';
|
|
10
10
|
import { Plugin } from '@nocobase/client-v2';
|
|
11
11
|
import type { Authenticator as AuthenticatorType } from './authenticator';
|
|
12
|
+
import { type AuthRouteName } from './authRoutePaths';
|
|
12
13
|
type LoaderOf<P = Record<string, never>> = () => Promise<{
|
|
13
14
|
default: ComponentType<P>;
|
|
14
15
|
}>;
|
|
16
|
+
type AuthRouteScopeNames = {
|
|
17
|
+
signin?: string;
|
|
18
|
+
signup?: string;
|
|
19
|
+
};
|
|
15
20
|
/**
|
|
16
21
|
* V2 auth-type registration. Every form/button is registered as an async `import()` loader rather than a synchronous component reference. Consumers resolve them with `React.lazy` at render time so each auth-type contributes its own webpack chunk and is only fetched when an authenticator of that type is actually shown.
|
|
17
22
|
*
|
|
@@ -37,7 +42,13 @@ export type AuthOptions = {
|
|
|
37
42
|
};
|
|
38
43
|
export declare class PluginAuthClientV2 extends Plugin {
|
|
39
44
|
authTypes: any;
|
|
45
|
+
private authRouteScopes;
|
|
40
46
|
registerType(authType: string, options: AuthOptions): void;
|
|
47
|
+
registerSignInRoute(name: string, path: string): void;
|
|
48
|
+
registerAuthRouteScope(name: string, basePath: string, routeNames?: AuthRouteScopeNames): void;
|
|
49
|
+
getAuthRoutePath(pathname: string, name: AuthRouteName): string;
|
|
50
|
+
isScopedAuthRoute(pathname: string): boolean;
|
|
51
|
+
getAuthRedirectFallbackPath(pathname: string): string;
|
|
41
52
|
load(): Promise<void>;
|
|
42
53
|
private registerSettingsPages;
|
|
43
54
|
private addRoutes;
|
package/dist/externalVersion.js
CHANGED
|
@@ -8,21 +8,21 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
module.exports = {
|
|
11
|
-
"@nocobase/client": "
|
|
11
|
+
"@nocobase/client": "3.0.0-alpha.11",
|
|
12
12
|
"react": "18.2.0",
|
|
13
13
|
"react-router-dom": "6.30.1",
|
|
14
|
-
"@nocobase/utils": "
|
|
14
|
+
"@nocobase/utils": "3.0.0-alpha.11",
|
|
15
15
|
"axios": "1.7.7",
|
|
16
16
|
"lodash": "4.18.1",
|
|
17
|
-
"@nocobase/client-v2": "
|
|
18
|
-
"@nocobase/flow-engine": "
|
|
17
|
+
"@nocobase/client-v2": "3.0.0-alpha.11",
|
|
18
|
+
"@nocobase/flow-engine": "3.0.0-alpha.11",
|
|
19
19
|
"react-i18next": "11.18.6",
|
|
20
|
-
"@nocobase/auth": "
|
|
21
|
-
"@nocobase/database": "
|
|
22
|
-
"@nocobase/cache": "
|
|
23
|
-
"@nocobase/server": "
|
|
24
|
-
"@nocobase/logger": "
|
|
25
|
-
"@nocobase/test": "
|
|
20
|
+
"@nocobase/auth": "3.0.0-alpha.11",
|
|
21
|
+
"@nocobase/database": "3.0.0-alpha.11",
|
|
22
|
+
"@nocobase/cache": "3.0.0-alpha.11",
|
|
23
|
+
"@nocobase/server": "3.0.0-alpha.11",
|
|
24
|
+
"@nocobase/logger": "3.0.0-alpha.11",
|
|
25
|
+
"@nocobase/test": "3.0.0-alpha.11",
|
|
26
26
|
"@formily/antd-v5": "1.2.3",
|
|
27
27
|
"antd": "5.24.2",
|
|
28
28
|
"@formily/shared": "2.3.7",
|
|
@@ -30,6 +30,6 @@ module.exports = {
|
|
|
30
30
|
"@emotion/css": "11.13.0",
|
|
31
31
|
"@ant-design/icons": "5.6.1",
|
|
32
32
|
"ahooks": "3.7.8",
|
|
33
|
-
"@nocobase/actions": "
|
|
33
|
+
"@nocobase/actions": "3.0.0-alpha.11",
|
|
34
34
|
"@formily/core": "2.3.7"
|
|
35
35
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
|
-
export { AuthModel, BasicAuth, buildRedirectPath, defaultTokenPolicyConfig, default, getModernClientPrefix, presetAuthType,
|
|
10
|
-
export type { BuildRedirectPathOptions, ResolveSigninPrefixOptions } from './server';
|
|
9
|
+
export { AuthModel, appendAuthRedirectQuery, BasicAuth, buildRedirectPath, defaultTokenPolicyConfig, default, getModernClientPrefix, presetAuthType, resolveAuthRedirect, resolveSigninPrefix, resolveSubAppSegment, } from './server';
|
|
10
|
+
export type { BuildRedirectPathOptions, AuthRedirectOriginContext, ResolveSigninPrefixOptions } from './server';
|
package/dist/index.js
CHANGED
|
@@ -38,11 +38,13 @@ var src_exports = {};
|
|
|
38
38
|
__export(src_exports, {
|
|
39
39
|
AuthModel: () => import_server.AuthModel,
|
|
40
40
|
BasicAuth: () => import_server.BasicAuth,
|
|
41
|
+
appendAuthRedirectQuery: () => import_server.appendAuthRedirectQuery,
|
|
41
42
|
buildRedirectPath: () => import_server.buildRedirectPath,
|
|
42
43
|
default: () => import_server.default,
|
|
43
44
|
defaultTokenPolicyConfig: () => import_server.defaultTokenPolicyConfig,
|
|
44
45
|
getModernClientPrefix: () => import_server.getModernClientPrefix,
|
|
45
46
|
presetAuthType: () => import_server.presetAuthType,
|
|
47
|
+
resolveAuthRedirect: () => import_server.resolveAuthRedirect,
|
|
46
48
|
resolveSigninPrefix: () => import_server.resolveSigninPrefix,
|
|
47
49
|
resolveSubAppSegment: () => import_server.resolveSubAppSegment
|
|
48
50
|
});
|
|
@@ -52,10 +54,12 @@ var import_server = __toESM(require("./server"));
|
|
|
52
54
|
0 && (module.exports = {
|
|
53
55
|
AuthModel,
|
|
54
56
|
BasicAuth,
|
|
57
|
+
appendAuthRedirectQuery,
|
|
55
58
|
buildRedirectPath,
|
|
56
59
|
defaultTokenPolicyConfig,
|
|
57
60
|
getModernClientPrefix,
|
|
58
61
|
presetAuthType,
|
|
62
|
+
resolveAuthRedirect,
|
|
59
63
|
resolveSigninPrefix,
|
|
60
64
|
resolveSubAppSegment
|
|
61
65
|
});
|
|
@@ -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":"2026-08-
|
|
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":"2026-08-23T06:22:46.294Z"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"ms","version":"2.1.3","description":"Tiny millisecond conversion utility","repository":"vercel/ms","main":"./index","files":["index.js"],"scripts":{"precommit":"lint-staged","lint":"eslint lib/* bin/*","test":"mocha tests.js"},"eslintConfig":{"extends":"eslint:recommended","env":{"node":true,"es6":true}},"lint-staged":{"*.js":["npm run lint","prettier --single-quote --write","git add"]},"license":"MIT","devDependencies":{"eslint":"4.18.2","expect.js":"0.3.1","husky":"0.14.3","lint-staged":"5.0.0","mocha":"4.0.1","prettier":"2.0.5"},"_lastModified":"2026-08-
|
|
1
|
+
{"name":"ms","version":"2.1.3","description":"Tiny millisecond conversion utility","repository":"vercel/ms","main":"./index","files":["index.js"],"scripts":{"precommit":"lint-staged","lint":"eslint lib/* bin/*","test":"mocha tests.js"},"eslintConfig":{"extends":"eslint:recommended","env":{"node":true,"es6":true}},"lint-staged":{"*.js":["npm run lint","prettier --single-quote --write","git add"]},"license":"MIT","devDependencies":{"eslint":"4.18.2","expect.js":"0.3.1","husky":"0.14.3","lint-staged":"5.0.0","mocha":"4.0.1","prettier":"2.0.5"},"_lastModified":"2026-08-23T06:22:46.387Z"}
|
package/dist/server/index.d.ts
CHANGED
|
@@ -13,5 +13,7 @@ export { defaultTokenPolicyConfig } from '../constants';
|
|
|
13
13
|
export { buildRedirectPath, getModernClientPrefix, resolveSigninPrefix } from './utils/buildRedirectPath';
|
|
14
14
|
export type { BuildRedirectPathOptions, ResolveSigninPrefixOptions } from './utils/buildRedirectPath';
|
|
15
15
|
export { resolveSubAppSegment } from './utils/resolveSubAppSegment';
|
|
16
|
+
export { appendAuthRedirectQuery, resolveAuthRedirect } from './utils/authRedirect';
|
|
17
|
+
export type { AuthRedirectOriginContext } from './utils/authRedirect';
|
|
16
18
|
export { default } from './plugin';
|
|
17
19
|
export * from '../constants';
|
package/dist/server/index.js
CHANGED
|
@@ -39,11 +39,13 @@ var server_exports = {};
|
|
|
39
39
|
__export(server_exports, {
|
|
40
40
|
AuthModel: () => import_authenticator.AuthModel,
|
|
41
41
|
BasicAuth: () => import_basic_auth.BasicAuth,
|
|
42
|
+
appendAuthRedirectQuery: () => import_authRedirect.appendAuthRedirectQuery,
|
|
42
43
|
buildRedirectPath: () => import_buildRedirectPath.buildRedirectPath,
|
|
43
44
|
default: () => import_plugin.default,
|
|
44
45
|
defaultTokenPolicyConfig: () => import_constants.defaultTokenPolicyConfig,
|
|
45
46
|
getModernClientPrefix: () => import_buildRedirectPath.getModernClientPrefix,
|
|
46
47
|
presetAuthType: () => import_preset.presetAuthType,
|
|
48
|
+
resolveAuthRedirect: () => import_authRedirect.resolveAuthRedirect,
|
|
47
49
|
resolveSigninPrefix: () => import_buildRedirectPath.resolveSigninPrefix,
|
|
48
50
|
resolveSubAppSegment: () => import_resolveSubAppSegment.resolveSubAppSegment
|
|
49
51
|
});
|
|
@@ -54,16 +56,19 @@ var import_preset = require("../preset");
|
|
|
54
56
|
var import_constants = require("../constants");
|
|
55
57
|
var import_buildRedirectPath = require("./utils/buildRedirectPath");
|
|
56
58
|
var import_resolveSubAppSegment = require("./utils/resolveSubAppSegment");
|
|
59
|
+
var import_authRedirect = require("./utils/authRedirect");
|
|
57
60
|
var import_plugin = __toESM(require("./plugin"));
|
|
58
61
|
__reExport(server_exports, require("../constants"), module.exports);
|
|
59
62
|
// Annotate the CommonJS export names for ESM import in node:
|
|
60
63
|
0 && (module.exports = {
|
|
61
64
|
AuthModel,
|
|
62
65
|
BasicAuth,
|
|
66
|
+
appendAuthRedirectQuery,
|
|
63
67
|
buildRedirectPath,
|
|
64
68
|
defaultTokenPolicyConfig,
|
|
65
69
|
getModernClientPrefix,
|
|
66
70
|
presetAuthType,
|
|
71
|
+
resolveAuthRedirect,
|
|
67
72
|
resolveSigninPrefix,
|
|
68
73
|
resolveSubAppSegment,
|
|
69
74
|
...require("../constants")
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
import { type OriginContext } from '@nocobase/utils';
|
|
10
|
+
import { type BuildRedirectPathOptions } from './buildRedirectPath';
|
|
11
|
+
export interface AuthRedirectOriginContext extends OriginContext {
|
|
12
|
+
t?(key: string, options?: {
|
|
13
|
+
ns?: string;
|
|
14
|
+
}): string;
|
|
15
|
+
throw(status: number, message: string): never;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Resolve an SSO callback target without creating an open redirect.
|
|
19
|
+
*
|
|
20
|
+
* Existing NocoBase clients use root-relative paths and still need the app
|
|
21
|
+
* public path/sub-app prefix handling provided by `buildRedirectPath`.
|
|
22
|
+
* Standalone Portal development runs on another origin, so an absolute target
|
|
23
|
+
* is also accepted when that origin is trusted by the server's CORS policy.
|
|
24
|
+
*/
|
|
25
|
+
export declare function resolveAuthRedirect(ctx: AuthRedirectOriginContext, { appPublicPath, subAppSegment, target }: BuildRedirectPathOptions): {
|
|
26
|
+
safeRedirect: string;
|
|
27
|
+
target: string;
|
|
28
|
+
};
|
|
29
|
+
/** Append or replace callback parameters while preserving query and hash. */
|
|
30
|
+
export declare function appendAuthRedirectQuery(target: string, params: Record<string, string | number | boolean | null | undefined>): string;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __export = (target, all) => {
|
|
15
|
+
for (var name in all)
|
|
16
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
+
for (let key of __getOwnPropNames(from))
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
+
var authRedirect_exports = {};
|
|
28
|
+
__export(authRedirect_exports, {
|
|
29
|
+
appendAuthRedirectQuery: () => appendAuthRedirectQuery,
|
|
30
|
+
resolveAuthRedirect: () => resolveAuthRedirect
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(authRedirect_exports);
|
|
33
|
+
var import_utils = require("@nocobase/utils");
|
|
34
|
+
var import_preset = require("../../preset");
|
|
35
|
+
var import_buildRedirectPath = require("./buildRedirectPath");
|
|
36
|
+
function getInvalidOriginMessage(ctx) {
|
|
37
|
+
var _a;
|
|
38
|
+
return ((_a = ctx.t) == null ? void 0 : _a.call(ctx, "Invalid sign-in origin", { ns: import_preset.namespace })) || "Invalid sign-in origin";
|
|
39
|
+
}
|
|
40
|
+
function isRootRelativePath(value) {
|
|
41
|
+
return value.startsWith("/") && !value.startsWith("//") && !value.startsWith("/\\");
|
|
42
|
+
}
|
|
43
|
+
function isPortalPath(value, appPublicPath) {
|
|
44
|
+
const normalizedAppPublicPath = (appPublicPath || "").replace(/\/+$/, "");
|
|
45
|
+
const pathname = value.split(/[?#]/, 1)[0];
|
|
46
|
+
if (normalizedAppPublicPath && !pathname.startsWith(`${normalizedAppPublicPath}/`)) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
const pathnameWithinPublicPath = pathname.slice(normalizedAppPublicPath.length);
|
|
50
|
+
return pathnameWithinPublicPath === "/x" || pathnameWithinPublicPath.startsWith("/x/");
|
|
51
|
+
}
|
|
52
|
+
function resolveAbsoluteUrl(ctx, value) {
|
|
53
|
+
let url;
|
|
54
|
+
try {
|
|
55
|
+
url = new URL(value);
|
|
56
|
+
} catch {
|
|
57
|
+
ctx.throw(400, getInvalidOriginMessage(ctx));
|
|
58
|
+
}
|
|
59
|
+
if (!["http:", "https:"].includes(url.protocol) || url.username || url.password) {
|
|
60
|
+
ctx.throw(400, getInvalidOriginMessage(ctx));
|
|
61
|
+
}
|
|
62
|
+
const whitelist = (0, import_utils.getCorsWhitelist)();
|
|
63
|
+
if (!(0, import_utils.isSameOrigin)(ctx, url.origin) && !(whitelist == null ? void 0 : whitelist.has(url.origin))) {
|
|
64
|
+
ctx.throw(400, getInvalidOriginMessage(ctx));
|
|
65
|
+
}
|
|
66
|
+
return url;
|
|
67
|
+
}
|
|
68
|
+
function resolveSafeAuthRedirect(ctx, target) {
|
|
69
|
+
const value = typeof target === "string" ? target.trim() : "";
|
|
70
|
+
if (isRootRelativePath(value)) return value;
|
|
71
|
+
return value ? resolveAbsoluteUrl(ctx, value).toString() : null;
|
|
72
|
+
}
|
|
73
|
+
function resolveAuthRedirect(ctx, { appPublicPath, subAppSegment, target }) {
|
|
74
|
+
const safeRedirect = resolveSafeAuthRedirect(ctx, target) || "/admin";
|
|
75
|
+
const resolvedTarget = isRootRelativePath(safeRedirect) && !isPortalPath(safeRedirect, appPublicPath) ? (0, import_buildRedirectPath.buildRedirectPath)({ appPublicPath, subAppSegment, target: safeRedirect }) : safeRedirect;
|
|
76
|
+
return { safeRedirect, target: resolvedTarget };
|
|
77
|
+
}
|
|
78
|
+
function appendAuthRedirectQuery(target, params) {
|
|
79
|
+
const isAbsolute = /^[a-z][a-z\d+.-]*:/i.test(target);
|
|
80
|
+
const url = new URL(target, "http://nocobase.local");
|
|
81
|
+
for (const [key, value] of Object.entries(params)) {
|
|
82
|
+
if (value === void 0) {
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
url.searchParams.set(key, value === null ? "" : String(value));
|
|
86
|
+
}
|
|
87
|
+
return isAbsolute ? url.toString() : `${url.pathname}${url.search}${url.hash}`;
|
|
88
|
+
}
|
|
89
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
90
|
+
0 && (module.exports = {
|
|
91
|
+
appendAuthRedirectQuery,
|
|
92
|
+
resolveAuthRedirect
|
|
93
|
+
});
|
|
@@ -48,8 +48,27 @@ function buildRedirectPath({ appPublicPath, subAppSegment, target }) {
|
|
|
48
48
|
function getModernClientPrefix() {
|
|
49
49
|
return String(process.env.APP_MODERN_CLIENT_PREFIX || "").trim().replace(/^\/+|\/+$/g, "") || "v";
|
|
50
50
|
}
|
|
51
|
+
function resolveSettingsSigninPrefix(appPublicPath, redirect) {
|
|
52
|
+
if (typeof redirect !== "string") {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
const [pathname] = redirect.split(/[?#]/, 1);
|
|
56
|
+
if (appPublicPath && pathname !== appPublicPath && !pathname.startsWith(`${appPublicPath}/`)) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
const pathnameWithinPublicPath = pathname.slice(appPublicPath.length);
|
|
60
|
+
const scopedMatch = pathnameWithinPublicPath.match(/^\/settings\/((?:apps|_app)\/[^/]+)(?:\/|$)/);
|
|
61
|
+
if (scopedMatch) {
|
|
62
|
+
return `${appPublicPath}/settings/${scopedMatch[1]}`;
|
|
63
|
+
}
|
|
64
|
+
return /^\/settings(?:\/|$)/.test(pathnameWithinPublicPath) ? `${appPublicPath}/settings` : null;
|
|
65
|
+
}
|
|
51
66
|
function resolveSigninPrefix({ appPublicPath, redirect, subAppSegment }) {
|
|
52
67
|
const normalizedAppPublicPath = (appPublicPath || "").replace(/\/+$/, "");
|
|
68
|
+
const settingsSigninPrefix = resolveSettingsSigninPrefix(normalizedAppPublicPath, redirect);
|
|
69
|
+
if (settingsSigninPrefix) {
|
|
70
|
+
return settingsSigninPrefix;
|
|
71
|
+
}
|
|
53
72
|
const modernSegment = `/${getModernClientPrefix()}`;
|
|
54
73
|
const modernMarker = `${normalizedAppPublicPath}${modernSegment}`;
|
|
55
74
|
const isModernOrigin = typeof redirect === "string" && (redirect === modernMarker || redirect.startsWith(`${modernMarker}/`));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-auth",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-alpha.11",
|
|
4
4
|
"main": "./dist/server/index.js",
|
|
5
5
|
"homepage": "https://docs.nocobase.com/handbook/auth",
|
|
6
6
|
"homepage.ru-RU": "https://docs-ru.nocobase.com/handbook/auth",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"description": "User authentication management, including password, SMS, and support for Single Sign-On (SSO) protocols, with extensibility.",
|
|
32
32
|
"description.ru-RU": "Управление аутентификацией пользователей: пароли, SMS, поддержка протоколов единого входа (SSO) и возможность расширения.",
|
|
33
33
|
"description.zh-CN": "用户认证管理,包括基础的密码认证、短信认证、SSO 协议的认证等,可扩展。",
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "03574f3a2d10b1ed8469dc7405aa0c4696d6d1d1",
|
|
35
35
|
"keywords": [
|
|
36
36
|
"Authentication",
|
|
37
37
|
"Security"
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
"use strict";(self.webpackChunk_nocobase_plugin_auth_client_v2=self.webpackChunk_nocobase_plugin_auth_client_v2||[]).push([["217"],{264:function(e,t,n){n.r(t),n.d(t,{default:function(){return g}});var r=n(485),a=n(694),l=n(6),i=n(59),o=n(155),u=n.n(o),s=n(442),c=n(488);function m(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 f(e,t,n,r,a,l,i){try{var o=e[l](i),u=o.value}catch(e){n(e);return}o.done?t(u):Promise.resolve(u).then(r,a)}function d(e,t){if(e){if("string"==typeof e)return m(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 m(e,t)}}var p=["$env"];function h(e){var t,n=(0,c.dE)().t,s=(0,c.kj)(),f=(t=(0,a.useFlowContext)(),(0,o.useMemo)(function(){var e,n,r,a,l=null==(r=t.dataSourceManager)||null==(n=r.getCollection)?void 0:n.call(r,"main","users");return(null!=(e=null==l||null==(a=l.getFields)?void 0:a.call(l))?e:[]).filter(function(e){var t,n;return e&&!(null==(t=e.options)?void 0:t.hidden)&&!e.target&&e.interface&&!(null==(n=e.uiSchema)?void 0:n["x-read-pretty"])})},[t])),p=(0,o.useMemo)(function(){var t;return null!=(t=e.value)?t:[]},[e.value]),h=(0,o.useMemo)(function(){var e=new Set(f.map(function(e){return e.name})),t=p.filter(function(t){return e.has(t.field)}),n=new Set(t.map(function(e){return e.field})),r=!0,a=!1,l=void 0;try{for(var i,o=f[Symbol.iterator]();!(r=(i=o.next()).done);r=!0){var u=i.value;n.has(u.name)||t.push({field:u.name,show:"username"===u.name,required:"username"===u.name})}}catch(e){a=!0,l=e}finally{try{r||null==o.return||o.return()}finally{if(a)throw l}}return t},[f,p]);u().useEffect(function(){var t;p.length===h.length&&p.every(function(e,t){return e.field===h[t].field&&!!e.show==!!h[t].show&&!!e.required==!!h[t].required})||null==(t=e.onChange)||t.call(e,h)},[h]);var y=(0,l.useMemoizedFn)(function(t,n){var r,a=h.map(function(e){if(e.field!==t)return e;var r=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;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},e,n);return r.required&&(r.show=!0),r.show||(r.required=!1),r});null==(r=e.onChange)||r.call(e,a)}),b=(0,l.useMemoizedFn)(function(e){var t,n,r=f.find(function(t){return t.name===e});return s((null==r||null==(t=r.uiSchema)?void 0:t.title)||(null==r||null==(n=r.options)?void 0:n.title)||e)}),g=(0,o.useMemo)(function(){return[{title:n("Field"),dataIndex:"field",width:200,render:function(e){return u().createElement(i.Tag,null,b(e))}},{title:n("Show"),dataIndex:"show",width:80,align:"center",render:function(e,t){return u().createElement(i.Checkbox,{checked:!!t.show,onChange:function(e){return y(t.field,{show:e.target.checked})}})}},{title:n("Required"),dataIndex:"required",width:80,align:"center",render:function(e,t){return u().createElement(i.Checkbox,{checked:!!t.required,onChange:function(e){return y(t.field,{required:e.target.checked})}})}},{title:"",dataIndex:"_filler",render:function(){return null}}]},[b,n,y]),v=(0,l.useMemoizedFn)(function(t,n){var r,a=h.findIndex(function(e){return e.field===t.field}),l=h.findIndex(function(e){return e.field===n.field});if(!(a<0)&&!(l<0)&&a!==l){var i,o=function(e){if(Array.isArray(e))return m(e)}(h)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(h)||d(h)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),u=(function(e){if(Array.isArray(e))return e}(i=o.splice(a,1))||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var a=[],l=!0,i=!1;try{for(r=r.call(e);!(l=(t=r.next()).done)&&(a.push(t.value),1!==a.length);l=!0);}catch(e){i=!0,n=e}finally{try{l||null==r.return||r.return()}finally{if(i)throw n}}return a}}(i)||d(i,1)||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];o.splice(l,0,u),null==(r=e.onChange)||r.call(e,o)}});return u().createElement(r.Table,{rowKey:"field",pagination:!1,columns:g,dataSource:h,isDraggable:!0,onSortEnd:v,sortHandleColumnWidth:32,showIndex:!1})}function y(){var e=(0,c.dE)().t;return u().createElement(u().Fragment,null,u().createElement(i.Form.Item,{name:["options","public","allowSignUp"],label:e("Allow to sign up"),valuePropName:"checked",initialValue:!0},u().createElement(i.Checkbox,null)),u().createElement(i.Form.Item,{label:e("Sign up form"),name:["options","public","signupForm"],validateFirst:!0},u().createElement(h,null)))}function b(){var e,t,n,m=(0,c.dE)().t,d=i.Form.useFormInstance(),h=i.Form.useWatch(["options","public","enableResetPassword"],d),y=i.Form.useWatch(["options","emailContentType"],d)||"html",b=(e=(0,c.dE)().t,(0,o.useMemo)(function(){return[{name:"$user",title:e("Current user"),type:"object",paths:["$user"],children:[{name:"username",title:e("Username"),type:"string",paths:["$user","username"]},{name:"nickname",title:e("Nickname"),type:"string",paths:["$user","nickname"]},{name:"email",title:e("Email"),type:"string",paths:["$user","email"]}]},{name:"$systemSettings",title:e("System settings"),type:"object",paths:["$systemSettings"],children:[{name:"title",title:e("System title"),type:"string",paths:["$systemSettings","title"]},{name:"logo",title:e("System logo"),type:"string",paths:["$systemSettings","logo"]}]},{name:"$resetLink",title:e("Reset password link"),type:"string",paths:["$resetLink"]},{name:"$resetLinkExpiration",title:e("Reset link expiration (minutes)"),type:"string",paths:["$resetLinkExpiration"]}]},[e])),g=(t=!!h,n=(0,a.useFlowContext)(),(0,l.useRequest)(function(){var e;return(e=function(){var e,t,r,a;return function(e,t){var n,r,a,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),o=Object.defineProperty;return o(i,"next",{value:u(0)}),o(i,"throw",{value:u(1)}),o(i,"return",{value:u(2)}),"function"==typeof Symbol&&o(i,Symbol.iterator,{value:function(){return this}}),i;function u(o){return function(u){var s=[o,u];if(n)throw TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(l=0)),l;)try{if(n=1,r&&(a=2&s[0]?r.return:s[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,s[1])).done)return a;switch(r=0,a&&(s=[2&s[0],a.value]),s[0]){case 0:case 1:a=s;break;case 4:return l.label++,{value:s[1],done:!1};case 5:l.label++,r=s[1],s=[0];continue;case 7:s=l.ops.pop(),l.trys.pop();continue;default:if(!(a=(a=l.trys).length>0&&a[a.length-1])&&(6===s[0]||2===s[0])){l=0;continue}if(3===s[0]&&(!a||s[1]>a[0]&&s[1]<a[3])){l.label=s[1];break}if(6===s[0]&&l.label<a[1]){l.label=a[1],a=s;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(s);break}a[2]&&l.ops.pop(),l.trys.pop();continue}s=t.call(e,l)}catch(e){s=[6,e],r=0}finally{n=a=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}}(this,function(l){switch(l.label){case 0:return[4,n.api.resource("notificationChannels").list({filter:{notificationType:"email"},pageSize:50})];case 1:return[2,Array.isArray(a=null!=(e=null==(r=l.sent())||null==(t=r.data)?void 0:t.data)?e:null==r?void 0:r.data)?a:[]]}})},function(){var t=this,n=arguments;return new Promise(function(r,a){var l=e.apply(t,n);function i(e){f(l,r,a,i,o,"next",e)}function o(e){f(l,r,a,i,o,"throw",e)}i(void 0)})})()},{ready:t,cacheKey:"@nocobase/plugin-auth:notificationChannels:email",refreshDeps:[t]})),v=g.data,E=g.loading,w=(0,o.useMemo)(function(){return(v||[]).map(function(e){return{label:e.title,value:e.name}})},[v]);return u().createElement(u().Fragment,null,u().createElement(i.Form.Item,{name:["options","public","enableResetPassword"],label:m("Enable forget password"),valuePropName:"checked",initialValue:!1},u().createElement(i.Checkbox,null)),h?u().createElement(u().Fragment,null,u().createElement(i.Typography.Title,{level:5,style:{marginTop:0}},m("1. Select notification channel")),u().createElement(i.Form.Item,{name:["options","notificationChannel"],label:m("Notification channel (Email)"),extra:m("The notification channel used to send the reset password email, only support email channel"),rules:[{required:!0,message:m("Please select a notification channel")}]},u().createElement(i.Select,{loading:E,options:w,placeholder:m("Select"),notFoundContent:u().createElement("span",null,m("No notification channels found. Please "),u().createElement(s.Link,{to:"/admin/settings/notification-manager/channels"},m("add one first")),".")})),u().createElement(i.Typography.Title,{level:5},m("2. Configure reset email")),u().createElement(i.Form.Item,{name:["options","emailSubject"],label:m("Subject"),rules:[{required:!0,message:m("Please enter the email subject")}],initialValue:m("defaultResetPasswordEmailSubject")},u().createElement(r.VariableInput,{namespaces:p,extraNodes:b})),u().createElement(i.Form.Item,{name:["options","emailContentType"],label:m("Content type"),initialValue:"html",rules:[{required:!0}]},u().createElement(i.Radio.Group,{options:[{label:"HTML",value:"html"},{label:m("Plain text"),value:"text"}]})),"html"===y?u().createElement(i.Form.Item,{key:"html",name:["options","emailContentHTML"],label:m("Content"),rules:[{required:!0,message:m("Please enter the email content")}],initialValue:m("defaultResetPasswordEmailContentHTML")},u().createElement(r.VariableTextArea,{namespaces:p,extraNodes:b,placeholder:"Hi,",rows:10})):u().createElement(i.Form.Item,{key:"text",name:["options","emailContentText"],label:m("Content"),rules:[{required:!0,message:m("Please enter the email content")}],initialValue:m("defaultResetPasswordEmailContentText")},u().createElement(r.VariableTextArea,{namespaces:p,extraNodes:b,rows:10})),u().createElement(i.Form.Item,{name:["options","resetTokenExpiresIn"],label:m("Reset link expiration"),initialValue:120,rules:[{required:!0,message:m("Please enter the expiration in minutes")}]},u().createElement(i.InputNumber,{min:1,addonAfter:m("Minutes"),style:{width:"100%"}}))):null)}function g(){var e=(0,c.dE)().t;return u().createElement("div",null,u().createElement(i.Alert,{style:{marginBottom:16},type:"info",showIcon:!0,message:e("The authentication allows users to sign in via username or email.")}),u().createElement(i.Tabs,{items:[{key:"signup",label:e("Sign up settings"),forceRender:!0,children:u().createElement(y,null)},{key:"forgot",label:e("Forgot password"),forceRender:!0,children:u().createElement(b,null)}]}))}}}]);
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
"use strict";(self.webpackChunk_nocobase_plugin_auth_client_v2=self.webpackChunk_nocobase_plugin_auth_client_v2||[]).push([["795"],{918:function(e,t,r){r.r(t),r.d(t,{default:function(){return f}});var n=r(59),a=r(155),o=r.n(a),l=r(442),u=r(488),i=r(824);function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function c(e,t,r,n,a,o,l){try{var u=e[o](l),i=u.value}catch(e){r(e);return}u.done?t(i):Promise.resolve(i).then(n,a)}function m(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,a=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var o=[],l=!0,u=!1;try{for(a=a.call(e);!(l=(r=a.next()).done)&&(o.push(r.value),!t||o.length!==t);l=!0);}catch(e){u=!0,n=e}finally{try{l||null==a.return||a.return()}finally{if(u)throw n}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return s(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return s(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 f(e){var t,r,s=e.authenticator,f=(0,u.dE)().t,p=m(n.Form.useForm(),1)[0],y=m((0,a.useState)(""),2),d=y[0],v=y[1],h=m((0,a.useState)(!1),2),b=h[0],g=h[1],w=(0,i.go)(s.name),E=!!(null==s||null==(t=s.options)?void 0:t.allowSignUp),P=!!(null==s||null==(r=s.options)?void 0:r.enableResetPassword);return o().createElement(n.Form,{form:p,layout:"vertical",onFinish:function(e){var t;return(t=function(){var t,r,n,a,o;return function(e,t){var r,n,a,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},l=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(l,"next",{value:i(0)}),u(l,"throw",{value:i(1)}),u(l,"return",{value:i(2)}),"function"==typeof Symbol&&u(l,Symbol.iterator,{value:function(){return this}}),l;function i(u){return function(i){var s=[u,i];if(r)throw TypeError("Generator is already executing.");for(;l&&(l=0,s[0]&&(o=0)),o;)try{if(r=1,n&&(a=2&s[0]?n.return:s[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,s[1])).done)return a;switch(n=0,a&&(s=[2&s[0],a.value]),s[0]){case 0:case 1:a=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(a=(a=o.trys).length>0&&a[a.length-1])&&(6===s[0]||2===s[0])){o=0;continue}if(3===s[0]&&(!a||s[1]>a[0]&&s[1]<a[3])){o.label=s[1];break}if(6===s[0]&&o.label<a[1]){o.label=a[1],a=s;break}if(a&&o.label<a[2]){o.label=a[2],o.ops.push(s);break}a[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],n=0}finally{r=a=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}}(this,function(l){switch(l.label){case 0:v(""),g(!0),l.label=1;case 1:return l.trys.push([1,3,4,5]),[4,w.run(e)];case 2:return l.sent(),[3,5];case 3:return v((null==(t=l.sent())||null==(o=t.response)||null==(a=o.data)||null==(n=a.errors)||null==(r=n[0])?void 0:r.message)||(null==t?void 0:t.message)||String(t)),[3,5];case 4:return g(!1),[7];case 5:return[2]}})},function(){var e=this,r=arguments;return new Promise(function(n,a){var o=t.apply(e,r);function l(e){c(o,n,a,l,u,"next",e)}function u(e){c(o,n,a,l,u,"throw",e)}l(void 0)})})()}},d?o().createElement(n.Alert,{style:{marginBottom:16},type:"error",showIcon:!0,message:d}):null,o().createElement(n.Form.Item,{name:"account",rules:[{required:!0,message:f("Please enter your username or email")},{validator:function(e,t){return t?String(t).includes("@")?/^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/.test(String(t))?Promise.resolve():Promise.reject(Error(f("Please enter a valid email"))):/^[^@<>"'/]{1,50}$/.test(String(t))?Promise.resolve():Promise.reject(Error(f("Please enter a valid username"))):Promise.resolve()}}]},o().createElement(n.Input,{autoComplete:"username",placeholder:f("Username/Email")})),o().createElement(n.Form.Item,{name:"password",rules:[{required:!0,message:f("Please enter a password")}]},o().createElement(n.Input.Password,{autoComplete:"current-password",placeholder:f("Password")})),o().createElement(n.Form.Item,{style:{marginBottom:12}},o().createElement(n.Button,{loading:b,htmlType:"submit",type:"primary",block:!0},f("Sign in"))),o().createElement("div",{style:{display:"flex",justifyContent:"space-between",gap:12}},E?o().createElement(l.Link,{to:"/signup?name=".concat(s.name)},f("Create an account")):null,P?o().createElement(l.Link,{to:"/forgot-password?name=".concat(s.name)},f("Forgot password")):null))}}}]);
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
"use strict";(self.webpackChunk_nocobase_plugin_auth_client_v2=self.webpackChunk_nocobase_plugin_auth_client_v2||[]).push([["841"],{720:function(e,t,r){r.r(t),r.d(t,{default:function(){return h}});var n=r(59),a=r(155),l=r.n(a),o=r(442),u=r(230),i=r(953),s=r(485),c=r(488),m=r(295);function p(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function f(e,t,r,n,a,l,o){try{var u=e[l](o),i=u.value}catch(e){r(e);return}u.done?t(i):Promise.resolve(i).then(n,a)}function d(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,a=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var l=[],o=!0,u=!1;try{for(a=a.call(e);!(o=(r=a.next()).done)&&(l.push(r.value),!t||l.length!==t);o=!0);}catch(e){u=!0,n=e}finally{try{o||null==a.return||a.return()}finally{if(u)throw n}}return l}}(e,t)||function(e,t){if(e){if("string"==typeof e)return p(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return p(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 h(e){var t,r=e.authenticatorName,p=(0,s.useApp)(),h=(0,o.useNavigate)(),v=(0,c.dE)().t,y=(0,i.useTranslation)("lm-collections").t,b=(0,m.p)(r),g=d(n.Form.useForm(),1)[0],w=d((0,a.useState)(!1),2),E=w[0],S=w[1],k=d((0,a.useState)(""),2),I=k[0],x=k[1],P=(0,a.useMemo)(function(){var e;return((null==b||null==(e=b.options)?void 0:e.signupForm)||[]).filter(function(e){return null==e?void 0:e.show})},[b]);return(null==b||null==(t=b.options)?void 0:t.allowSignUp)?l().createElement(n.Form,{form:g,layout:"vertical",onFinish:function(e){var t;return(t=function(){var t,a,l,o,u;return function(e,t){var r,n,a,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(o,"next",{value:i(0)}),u(o,"throw",{value:i(1)}),u(o,"return",{value:i(2)}),"function"==typeof Symbol&&u(o,Symbol.iterator,{value:function(){return this}}),o;function i(u){return function(i){var s=[u,i];if(r)throw TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(l=0)),l;)try{if(r=1,n&&(a=2&s[0]?n.return:s[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,s[1])).done)return a;switch(n=0,a&&(s=[2&s[0],a.value]),s[0]){case 0:case 1:a=s;break;case 4:return l.label++,{value:s[1],done:!1};case 5:l.label++,n=s[1],s=[0];continue;case 7:s=l.ops.pop(),l.trys.pop();continue;default:if(!(a=(a=l.trys).length>0&&a[a.length-1])&&(6===s[0]||2===s[0])){l=0;continue}if(3===s[0]&&(!a||s[1]>a[0]&&s[1]<a[3])){l.label=s[1];break}if(6===s[0]&&l.label<a[1]){l.label=a[1],a=s;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(s);break}a[2]&&l.ops.pop(),l.trys.pop();continue}s=t.call(e,l)}catch(e){s=[6,e],n=0}finally{r=a=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}}(this,function(i){switch(i.label){case 0:x(""),S(!0),i.label=1;case 1:return i.trys.push([1,3,4,5]),[4,p.apiClient.auth.signUp(e,r)];case 2:return i.sent(),n.message.success(v("Sign up successfully, and automatically jump to the sign in page")),window.setTimeout(function(){h("/signin",{replace:!0})},2e3),[3,5];case 3:return x((null==(t=i.sent())||null==(u=t.response)||null==(o=u.data)||null==(l=o.errors)||null==(a=l[0])?void 0:a.message)||(null==t?void 0:t.message)||String(t)),[3,5];case 4:return S(!1),[7];case 5:return[2]}})},function(){var e=this,r=arguments;return new Promise(function(n,a){var l=t.apply(e,r);function o(e){f(l,n,a,o,u,"next",e)}function u(e){f(l,n,a,o,u,"throw",e)}o(void 0)})})()}},I?l().createElement(n.Alert,{style:{marginBottom:16},type:"error",showIcon:!0,message:I}):null,P.map(function(e){var t,r,a,o,i,s;return a=(r=(null==e?void 0:e.uiSchema)||{})["x-component"],o=r.title?y(u.Schema.compile(r.title,{t:v})):e.field,i=[],e.required&&i.push({required:!0,message:v("Please enter ".concat(e.field))}),"email"===e.field&&i.push({type:"email",message:v("Please enter a valid email address")}),s=l().createElement(n.Input,null),(null==(t=r.enum)?void 0:t.length)?s=l().createElement(n.Select,{options:r.enum.map(function(e){return{label:e.label||e.value,value:e.value}})}):"Checkbox"===a?s=l().createElement(n.Checkbox,null):("Input.TextArea"===a||"TextArea"===a)&&(s=l().createElement(n.Input.TextArea,{rows:4})),l().createElement(n.Form.Item,{key:e.field,name:e.field,label:o,valuePropName:"Checkbox"===a?"checked":"value",rules:i},s)}),l().createElement(n.Form.Item,{label:v("Password"),name:"password",rules:[{required:!0,message:v("Please enter a password")}]},l().createElement(n.Input.Password,{autoComplete:"new-password"})),l().createElement(n.Form.Item,{label:v("Confirm password"),name:"confirm_password",dependencies:["password"],rules:[{required:!0,message:v("Please enter the same password again")},function(e){var t=e.getFieldValue;return{validator:function(e,r){return r&&t("password")!==r?Promise.reject(Error(v("The passwords entered twice are inconsistent"))):Promise.resolve()}}}]},l().createElement(n.Input.Password,{autoComplete:"new-password"})),l().createElement(n.Form.Item,{style:{marginBottom:12}},l().createElement(n.Button,{loading:E,htmlType:"submit",type:"primary",block:!0},v("Sign up"))),l().createElement(o.Link,{to:"/signin"},v("Log in with an existing account"))):l().createElement(o.Navigate,{to:"/not-found",replace:!0})}}}]);
|