@nocobase/plugin-auth 1.5.0-alpha.5 → 1.6.0-alpha.1
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/280.index.js +10 -0
- package/dist/client/851.index.js +10 -0
- package/dist/client/890.index.js +10 -0
- package/dist/client/938.index.js +10 -0
- package/dist/client/index.d.ts +11 -3
- package/dist/client/index.js +1 -1
- package/dist/externalVersion.js +10 -9
- package/dist/locale/en-US.json +1 -1
- package/dist/locale/zh-CN.json +1 -1
- package/dist/node_modules/cron/package.json +1 -1
- package/dist/server/actions/authenticators.js +2 -2
- package/dist/server/basic-auth.d.ts +1 -0
- package/dist/server/basic-auth.js +25 -9
- package/dist/server/plugin.js +150 -3
- package/package.json +2 -2
|
@@ -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=self.webpackChunk_nocobase_plugin_auth||[]).push([["280"],{492:function(e,t,n){n.r(t),n.d(t,{useSignInForms:function(){return E},SignUpPage:function(){return I},AuthenticatorsContextProvider:function(){return s},AuthLayout:function(){return m},SignInPage:function(){return w},useSignInButtons:function(){return P},SignupPageProvider:function(){return j},useSignUpForms:function(){return A},SignupPageContext:function(){return O}});var r=n("964"),a=n("772"),o=n("721"),i=n("156"),u=n.n(i),l=n("128"),c=n("308");function f(){var e,t,n=(e=["\n position: absolute;\n bottom: 24px;\n width: 100%;\n left: 0;\n text-align: center;\n "],!t&&(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return f=function(){return n},n}var s=function(e){var t=e.children,n=(0,a.useAPIClient)(),r=(0,a.useRequest)(function(){return n.resource("authenticators").publicList().then(function(e){var t;return(null==e?void 0:null===(t=e.data)||void 0===t?void 0:t.data)||[]})}),i=r.data,l=r.error;if(r.loading)return u().createElement("div",{style:{textAlign:"center",marginTop:20}},u().createElement(o.Spin,null));if(l)throw l;return u().createElement(c.H.Provider,{value:void 0===i?[]:i},t)};function m(){var e,t=((0,a.useSystemSettings)()||{}).data;return u().createElement("div",{style:{maxWidth:320,margin:"0 auto",paddingTop:"20vh"}},u().createElement("div",{style:{position:"fixed",top:"2em",right:"2em"}},u().createElement(a.SwitchLanguage,null)),u().createElement("h1",{style:{textAlign:"center"}},u().createElement(a.ReadPretty.TextArea,{value:null==t?void 0:null===(e=t.data)||void 0===e?void 0:e.title})),u().createElement(s,null,u().createElement(l.Outlet,null)),u().createElement("div",{className:(0,r.css)(f())},u().createElement(a.PoweredBy,null)))}var v=n("437"),y=n("573"),p=n("505");function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function h(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,a=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var o=[],i=!0,u=!1;try{for(a=a.call(e);!(i=(n=a.next()).done)&&(o.push(n.value),!t||o.length!==t);i=!0);}catch(e){u=!0,r=e}finally{try{!i&&null!=a.return&&a.return()}finally{if(u)throw r}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return d(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return d(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function g(e,t){return!t&&(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function b(){var e=g(["\n display: flex;\n "]);return b=function(){return e},e}function S(){var e=g(["\n display: flex;\n "]);return S=function(){return e},e}var E=function(){var e=(0,a.usePlugin)(v.default).authTypes.getEntities(),t={},n=!0,r=!1,o=void 0;try{for(var i,u=e[Symbol.iterator]();!(n=(i=u.next()).done);n=!0){var l,c=h(i.value,2),f=c[0],s=c[1];(null===(l=s.components)||void 0===l?void 0:l.SignInForm)&&(t[f]=s.components.SignInForm)}}catch(e){r=!0,o=e}finally{try{!n&&null!=u.return&&u.return()}finally{if(r)throw o}}return t},P=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=(0,a.usePlugin)(v.default).authTypes.getEntities(),n={},r=!0,o=!1,i=void 0;try{for(var l,c=t[Symbol.iterator]();!(r=(l=c.next()).done);r=!0){var f,s=h(l.value,2),m=s[0],y=s[1];(null===(f=y.components)||void 0===f?void 0:f.SignInButton)&&(n[m]=y.components.SignInButton)}}catch(e){o=!0,i=e}finally{try{!r&&null!=c.return&&c.return()}finally{if(o)throw i}}var p=Object.keys(n);return e.filter(function(e){return p.includes(e.authType)}).map(function(e,t){return u().createElement(n[e.authType],{key:t,authenticator:e})})},w=function(){var e=(0,y.o$)().t;(0,a.useCurrentDocumentTitle)("Signin"),(0,a.useViewport)();var t=E(),n=(0,i.useContext)(c.H),l=P(n);if(!n.length)return u().createElement("div",{style:{color:"#ccc"}},e("No authentication methods available."));var f=n.map(function(n){var r=t[n.authType];if(!!r){var a="".concat(e("Sign-in")," (").concat(p.Schema.compile(n.authTypeTitle||n.authType,{t:e}),")");return function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r,a,o;r=e,a=t,o=n[t],a in r?Object.defineProperty(r,a,{value:o,enumerable:!0,configurable:!0,writable:!0}):r[a]=o})}return e}({component:(0,i.createElement)(r,{authenticator:n}),tabTitle:n.title||a},n)}}).filter(function(e){return e});return u().createElement(o.Space,{direction:"vertical",className:(0,r.css)(b())},f.length>1?u().createElement(o.Tabs,{items:f.map(function(e){return{label:e.tabTitle,key:e.name,children:e.component}})}):f.length?u().createElement("div",null,f[0].component):u().createElement(u().Fragment,null),u().createElement(o.Space,{direction:"vertical",className:(0,r.css)(S())},l))};function T(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 x(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,a=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var o=[],i=!0,u=!1;try{for(a=a.call(e);!(i=(n=a.next()).done)&&(o.push(n.value),!t||o.length!==t);i=!0);}catch(e){u=!0,r=e}finally{try{!i&&null!=a.return&&a.return()}finally{if(u)throw r}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return T(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 T(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var O=(0,i.createContext)({});O.displayName="SignupPageContext";var j=function(e){var t=(0,i.useContext)(O);return t[e.authType]={component:e.component},u().createElement(O.Provider,{value:t},e.children)},A=function(){var e=(0,a.usePlugin)(v.default).authTypes.getEntities(),t={},n=!0,r=!1,o=void 0;try{for(var i,u=e[Symbol.iterator]();!(n=(i=u.next()).done);n=!0){var l,c=x(i.value,2),f=c[0],s=c[1];(null===(l=s.components)||void 0===l?void 0:l.SignUpForm)&&(t[f]=s.components.SignUpForm)}}catch(e){r=!0,o=e}finally{try{!n&&null!=u.return&&u.return()}finally{if(r)throw o}}return t},I=function(){(0,a.useViewport)(),(0,a.useCurrentDocumentTitle)("Signup");var e=A(),t=x((0,l.useSearchParams)(),1)[0].get("name"),n=((0,c.u)(t)||{}).authType;return e[n]?(0,i.createElement)(e[n],{authenticatorName:t}):u().createElement(l.Navigate,{to:"/not-found",replace:!0})}}}]);
|
|
@@ -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=self.webpackChunk_nocobase_plugin_auth||[]).push([["851"],{264:function(e,t,o){o.r(t),o.d(t,{Authenticator:function(){return T}});var n=o("772"),r=o("721"),i=o("156"),c=o.n(i),a=o("875"),p=o("238"),l=(0,i.createContext)({type:""});l.displayName="AuthTypeContext";var u=(0,i.createContext)({types:[]});u.displayName="AuthTypesContext";function s(e,t,o,n,r,i,c){try{var a=e[i](c),p=a.value}catch(e){o(e);return}a.done?t(p):Promise.resolve(p).then(n,r)}var m={name:"authenticators",sortable:!0,fields:[{name:"id",type:"string",interface:"id"},{interface:"input",type:"string",name:"name",uiSchema:{type:"string",title:'{{t("Auth UID")}}',"x-component":"Input","x-validator":function(e){return/^[a-zA-Z0-9_-]+$/.test(e)?"":n.i18n.t("a-z, A-Z, 0-9, _, -")},required:!0}},{interface:"input",type:"string",name:"authType",uiSchema:{type:"string",title:'{{t("Auth Type")}}',"x-component":"Select",dataSource:"{{ types }}",required:!0}},{interface:"input",type:"string",name:"title",uiSchema:{type:"string",title:'{{t("Title")}}',"x-component":"Input"}},{interface:"textarea",type:"string",name:"description",uiSchema:{type:"string",title:'{{t("Description")}}',"x-component":"Input"}},{type:"boolean",name:"enabled",uiSchema:{type:"boolean",title:'{{t("Enabled")}}',"x-component":"Checkbox"}}]},y={type:"object",properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues:function(e){var t,o,r=(0,n.useActionContext)(),c=(0,i.useContext)(l).type;return(0,n.useRequest)(function(){return Promise.resolve({data:{name:"s_".concat((0,a.uid)()),authType:c}})},(t=function(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{},n=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(o).filter(function(e){return Object.getOwnPropertyDescriptor(o,e).enumerable}))),n.forEach(function(t){var n,r,i;n=e,r=t,i=o[t],r in n?Object.defineProperty(n,r,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[r]=i})}return e}({},e),o=(o={refreshDeps:[r.visible]},o),Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):(function(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);o.push.apply(o,n)}return o})(Object(o)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))}),t))}},title:'{{t("Add new")}}',properties:{name:{"x-component":"CollectionField","x-decorator":"FormItem"},authType:{"x-component":"CollectionField","x-decorator":"FormItem","x-component-props":{options:"{{ types }}"}},title:{"x-component":"CollectionField","x-decorator":"FormItem"},description:{"x-component":"CollectionField","x-decorator":"FormItem"},enabled:{"x-component":"CollectionField","x-decorator":"FormItem"},options:{type:"object","x-component":"Options"},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useCreateAction }}"}}}}}}}},d={type:"void",name:"authenticators","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:m,resourceName:"authenticators",dragSort:!0,request:{resource:"authenticators",action:"list",params:{pageSize:50,sort:"sort",appends:[]}}},"x-component":"CollectionProvider_deprecated","x-component-props":{collection:m},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{delete:{type:"void",title:'{{t("Delete")}}',"x-component":"Action","x-component-props":{icon:"DeleteOutlined",useAction:"{{ cm.useBulkDestroyAction }}",confirm:{title:"{{t('Delete')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},create:{type:"void",title:'{{t("Add new")}}',"x-component":"AddNew","x-component-props":{type:"primary"}}}},table:{type:"void","x-uid":"input","x-component":"Table.Void","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}",useAction:function(){var e=(0,n.useAPIClient)(),t=(0,p.useTranslation)().t;return{move:function(o,n){var i;return(i=function(){return function(e,t){var o,n,r,i,c={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(o)throw TypeError("Generator is already executing.");for(;c;)try{if(o=1,n&&(r=2&i[0]?n.return:i[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,i[1])).done)return r;switch(n=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return c.label++,{value:i[1],done:!1};case 5:c.label++,n=i[1],i=[0];continue;case 7:i=c.ops.pop(),c.trys.pop();continue;default:if(!(r=(r=c.trys).length>0&&r[r.length-1])&&(6===i[0]||2===i[0])){c=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){c.label=i[1];break}if(6===i[0]&&c.label<r[1]){c.label=r[1],r=i;break}if(r&&c.label<r[2]){c.label=r[2],c.ops.push(i);break}r[2]&&c.ops.pop(),c.trys.pop();continue}i=t.call(e,c)}catch(e){i=[6,e],n=0}finally{o=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}(this,function(i){switch(i.label){case 0:return[4,e.resource("authenticators").move({sourceId:o.id,targetId:n.id})];case 1:return i.sent(),r.message.success(t("Saved successfully"),.2),[2]}})},function(){var e=this,t=arguments;return new Promise(function(o,n){var r=i.apply(e,t);function c(e){s(r,o,n,c,a,"next",e)}function a(e){s(r,o,n,c,a,"throw",e)}c(void 0)})})()}}}},properties:{id:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{id:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},name:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{name:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},authType:{title:'{{t("Auth Type")}}',type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{authType:{type:"string","x-component":"Select","x-read-pretty":!0,enum:"{{ types }}"}}},title:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{title:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},description:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{description:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0}}},enabled:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{enabled:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{t("Actions")}}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{update:{type:"void",title:'{{t("Configure")}}',"x-component":"Action.Link","x-component-props":{type:"primary"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues:"{{ cm.useValuesFromRecord }}"},title:'{{t("Configure")}}',properties:{name:{"x-component":"CollectionField","x-decorator":"FormItem"},authType:{"x-component":"CollectionField","x-decorator":"FormItem","x-component-props":{options:"{{ types }}"}},title:{"x-component":"CollectionField","x-decorator":"FormItem"},description:{"x-component":"CollectionField","x-decorator":"FormItem"},enabled:{"x-component":"CollectionField","x-decorator":"FormItem"},options:{type:"object","x-component":"Options"},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useUpdateAction }}"}}}}}}}},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action.Link","x-component-props":{confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"},useAction:"{{cm.useDestroyAction}}"},"x-disabled":"{{ useCanNotDelete() }}"}}}}}}}}},f=o("482"),b=o("505"),x=o("437");function v(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{},n=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(o).filter(function(e){return Object.getOwnPropertyDescriptor(o,e).enumerable}))),n.forEach(function(t){var n,r,i;n=e,r=t,i=o[t],r in n?Object.defineProperty(n,r,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[r]=i})}return e}var h=function(e){var t,o,r=(0,n.useRecord)();var c=(0,n.useRequest)(function(){return Promise.resolve({data:v({},r.options)})},(t=v({},e),o=(o={manual:!0},o),Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):(function(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);o.push.apply(o,n)}return o})(Object(o)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))}),t)),a=c.run,p=(0,n.useActionContext)();return(0,i.useEffect)(function(){p.visible&&a()},[p.visible,a]),c},O=function(e){var t,o=(0,n.usePlugin)(x.default).authTypes.get(e);return null==o?void 0:null===(t=o.components)||void 0===t?void 0:t.AdminSettingsForm},g=(0,b.observer)(function(){var e=(0,b.useForm)(),t=(0,n.useRecord)(),o=O(e.values.authType||t.authType);return o?c().createElement(o,null):null},{displayName:"Options"}),w=o("573");function C(e,t){(null==t||t>e.length)&&(t=e.length);for(var o=0,n=Array(t);o<t;o++)n[o]=e[o];return n}function A(e,t,o,n,r,i,c){try{var a=e[i](c),p=a.value}catch(e){o(e);return}a.done?t(p):Promise.resolve(p).then(n,r)}function j(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var o,n,r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var i=[],c=!0,a=!1;try{for(r=r.call(e);!(c=(o=r.next()).done)&&(i.push(o.value),!t||i.length!==t);c=!0);}catch(e){a=!0,n=e}finally{try{!c&&null!=r.return&&r.return()}finally{if(a)throw n}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return C(e,t);var o=Object.prototype.toString.call(e).slice(8,-1);if("Object"===o&&e.constructor&&(o=e.constructor.name),"Map"===o||"Set"===o)return Array.from(o);if("Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o))return C(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var P=function(){var e=(0,n.useActionContext)().setVisible;return{run:function(){var t;return(t=function(){return function(e,t){var o,n,r,i,c={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(o)throw TypeError("Generator is already executing.");for(;c;)try{if(o=1,n&&(r=2&i[0]?n.return:i[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,i[1])).done)return r;switch(n=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return c.label++,{value:i[1],done:!1};case 5:c.label++,n=i[1],i=[0];continue;case 7:i=c.ops.pop(),c.trys.pop();continue;default:if(!(r=(r=c.trys).length>0&&r[r.length-1])&&(6===i[0]||2===i[0])){c=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){c.label=i[1];break}if(6===i[0]&&c.label<r[1]){c.label=r[1],r=i;break}if(r&&c.label<r[2]){c.label=r[2],c.ops.push(i);break}r[2]&&c.ops.pop(),c.trys.pop();continue}i=t.call(e,c)}catch(e){i=[6,e],n=0}finally{o=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}(this,function(t){return e(!1),[2]})},function(){var e=this,o=arguments;return new Promise(function(n,r){var i=t.apply(e,o);function c(e){A(i,n,r,c,a,"next",e)}function a(e){A(i,n,r,c,a,"throw",e)}c(void 0)})})()}}},S=function(){var e=(0,p.useTranslation)().t,t=j((0,i.useState)(!1),2),o=t[0],a=t[1],s=j((0,i.useState)(""),2),m=s[0],d=s[1],b=(0,i.useContext)(u).types,x=b.map(function(e){var t,o;return t=function(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{},n=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(o).filter(function(e){return Object.getOwnPropertyDescriptor(o,e).enumerable}))),n.forEach(function(t){var n,r,i;n=e,r=t,i=o[t],r in n?Object.defineProperty(n,r,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[r]=i})}return e}({},e),o=(o={onClick:function(){a(!0),d(e.value)}},o),Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):(function(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);o.push.apply(o,n)}return o})(Object(o)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))}),t});return c().createElement(n.ActionContextProvider,{value:{visible:o,setVisible:a}},c().createElement(l.Provider,{value:{type:m}},c().createElement(r.Dropdown,{menu:{items:x}},c().createElement(r.Button,{icon:c().createElement(f.PlusOutlined,null),type:"primary"},e("Add new")," ",c().createElement(f.DownOutlined,null))),c().createElement(n.SchemaComponent,{scope:{useCloseAction:P,types:b,setType:d},schema:y})))},D=function(){return(0,n.useAsyncData)().data,!1},T=function(){var e=(0,w.o$)().t,t=j((0,i.useState)([]),2),o=t[0],a=t[1],p=(0,n.useAPIClient)();return(0,n.useRequest)(function(){return p.resource("authenticators").listTypes().then(function(t){var o;return((null==t?void 0:null===(o=t.data)||void 0===o?void 0:o.data)||[]).map(function(t){return{key:t.name,label:b.Schema.compile(t.title||t.name,{t:e}),value:t.name}})})},{onSuccess:function(e){a(e)}}),c().createElement(r.Card,{bordered:!1},c().createElement(u.Provider,{value:{types:o}},c().createElement(n.SchemaComponent,{schema:d,components:{AddNew:S,Options:g},scope:{types:o,useValuesFromOptions:h,useCanNotDelete:D,t:e}})))}}}]);
|
|
@@ -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=self.webpackChunk_nocobase_plugin_auth||[]).push([["890"],{387:function(e,t,n){n.r(t),n.d(t,{AuthProvider:function(){return c}});var a=n(772),u=n(156),r=n.n(u),c=function(e){var t=(0,a.useLocationSearch)(),n=(0,a.useApp)();return(0,u.useEffect)(function(){var e=new URLSearchParams(t),a=e.get("authenticator"),u=e.get("token");u&&(n.apiClient.auth.setToken(u),n.apiClient.auth.setAuthenticator(a))}),r().createElement(r().Fragment,null,e.children)}}}]);
|
|
@@ -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=self.webpackChunk_nocobase_plugin_auth||[]).push([["938"],{510:function(e,t,n){n.r(t),n.d(t,{Options:function(){return C},SignInForm:function(){return y},SignUpForm:function(){return P},useRedirect:function(){return m},useSignUp:function(){return O},useSignIn:function(){return f}});var r=n("772"),o=n("156"),i=n.n(o),a=n("573"),u=n("128"),c=n("505"),s=n(581);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}function p(e,t,n,r,o,i,a){try{var u=e[i](a),c=u.value}catch(e){n(e);return}u.done?t(c):Promise.resolve(c).then(r,o)}function m(){arguments.length>0&&void 0!==arguments[0]&&arguments[0];var e,t,n=(0,u.useNavigate)();var r=(e=(0,u.useSearchParams)(),t=1,function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,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,1)||function(e,t){if(e){if("string"==typeof e)return l(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 l(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0];return(0,o.useCallback)(function(){n(r.get("redirect")||"/admin",{replace:!0})},[n,r])}var f=function(e){var t=(0,c.useForm)(),n=(0,r.useAPIClient)(),o=m(),i=(0,r.useCurrentUserContext)().refreshAsync;return{run:function(){var r;return(r=function(){return function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}(this,function(r){switch(r.label){case 0:return[4,t.submit()];case 1:return r.sent(),[4,n.auth.signIn(t.values,e)];case 2:return r.sent(),[4,i()];case 3:return r.sent(),o(),[2]}})},function(){var e=this,t=arguments;return new Promise(function(n,o){var i=r.apply(e,t);function a(e){p(i,n,o,a,u,"next",e)}function u(e){p(i,n,o,a,u,"throw",e)}a(void 0)})})()}}},d={type:"object",name:"passwordForm","x-component":"FormV2",properties:{account:{type:"string","x-component":"Input","x-validator":'{{(value) => {\n if (!value) {\n return t("Please enter your username or email");\n }\n if (value.includes(\'@\')) {\n if (!/^[\\w-]+(\\.[\\w-]+)*@[\\w-]+(\\.[\\w-]+)+$/.test(value)) {\n return t("Please enter a valid email");\n }\n } else {\n return /^[^@.<>"\'/]{1,50}$/.test(value) || t("Please enter a valid username");\n }\n }}}',"x-decorator":"FormItem","x-component-props":{placeholder:'{{t("Username/Email")}}',style:{}}},password:{type:"string","x-component":"Password",required:!0,"x-decorator":"FormItem","x-component-props":{placeholder:'{{t("Password")}}',style:{}}},actions:{type:"void","x-component":"div",properties:{submit:{title:'{{t("Sign in")}}',type:"void","x-component":"Action","x-component-props":{htmlType:"submit",block:!0,type:"primary",useAction:"{{ useBasicSignIn }}",style:{width:"100%"}}}}},signUp:{type:"void","x-component":"Link","x-component-props":{to:"{{ signUpLink }}"},"x-content":'{{t("Create an account")}}',"x-visible":"{{ allowSignUp }}"}}},y=function(e){var t=(0,a.o$)().t,o=e.authenticator,u=o.authType,c=o.name,l=o.options,p=!!(0,r.useLazy)(function(){return s("imported_-1ja1ffa_component",n.e("280").then(n.bind(n,492)))},"useSignUpForms")()[u]&&null!=l&&!!l.allowSignUp,m="/signup?name=".concat(c);return i().createElement(r.SchemaComponent,{schema:d,scope:{useBasicSignIn:function(){return f(c)},allowSignUp:p,signUpLink:m,t:t}})},b=n("875"),v=n("721"),h=n("238"),g=n("308");function w(e,t,n,r,o,i,a){try{var u=e[i](a),c=u.value}catch(e){n(e);return}u.done?t(c):Promise.resolve(c).then(r,o)}function x(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r,o,i;r=e,o=t,i=n[t],o in r?Object.defineProperty(r,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[o]=i})}return e}function S(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}var O=function(e){var t=(0,u.useNavigate)(),n=(0,c.useForm)(),o=(0,r.useAPIClient)(),i=(0,h.useTranslation)().t;return{run:function(){var r;return(r=function(){var r;return function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}(this,function(a){switch(a.label){case 0:return[4,n.submit()];case 1:return a.sent(),[4,o.auth.signUp(n.values,null==e?void 0:e.authenticator)];case 2:return a.sent(),v.message.success((null==e?void 0:null===(r=e.message)||void 0===r?void 0:r.success)||i("Sign up successfully, and automatically jump to the sign in page")),setTimeout(function(){t("/signin")},2e3),[2]}})},function(){var e=this,t=arguments;return new Promise(function(n,o){var i=r.apply(e,t);function a(e){w(i,n,o,a,u,"next",e)}function u(e){w(i,n,o,a,u,"throw",e)}a(void 0)})})()}}},P=function(e){var t,n=e.authenticatorName,c=(0,a.o$)().t,s=(0,g.u)(n).options,l=s.signupForm,p=(0,o.useMemo)(function(){return l.filter(function(e){return e.show}).reduce(function(e,t){return e[t.field]=S(x({},t.uiSchema),{required:t.required,"x-decorator":"FormItem"}),e},{})},[l]);if(!(null==s?void 0:s.allowSignUp))return i().createElement(u.Navigate,{to:"/not-found",replace:!0});var m=(t=p,{type:"object",name:(0,b.uid)(),"x-component":"FormV2",properties:S(x({},t),{password:{type:"string",required:!0,title:'{{t("Password")}}',"x-component":"Password","x-decorator":"FormItem","x-component-props":{checkStrength:!0,style:{}},"x-reactions":[{dependencies:[".confirm_password"],fulfill:{state:{selfErrors:'{{$deps[0] && $self.value && $self.value !== $deps[0] ? t("Password mismatch") : ""}}'}}}]},confirm_password:{type:"string",required:!0,"x-component":"Password","x-decorator":"FormItem",title:'{{t("Confirm password")}}',"x-component-props":{style:{}},"x-reactions":[{dependencies:[".password"],fulfill:{state:{selfErrors:'{{$deps[0] && $self.value && $self.value !== $deps[0] ? t("Password mismatch") : ""}}'}}}]},actions:{type:"void","x-component":"div",properties:{submit:{title:'{{t("Sign up")}}',type:"void","x-component":"Action","x-component-props":{block:!0,type:"primary",htmlType:"submit",useAction:"{{ useBasicSignUp }}",style:{width:"100%"}}}}},link:{type:"void","x-component":"div",properties:{link:{type:"void","x-component":"Link","x-component-props":{to:"/signin"},"x-content":'{{t("Log in with an existing account")}}'}}}})});return i().createElement(r.SchemaComponent,{schema:m,scope:{useBasicSignUp:function(){return O({authenticator:n})},t:c}})},j=n("632");function k(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function F(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){k(e,t,n[t])})}return e}function A(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}var I=function(){var e=(0,r.useRecord)(),t=(0,r.useCollectionManager)().getCollection("users").fields.filter(function(e){var t;return!e.hidden&&!e.target&&e.interface&&!(null===(t=e.uiSchema)||void 0===t?void 0:t["x-read-pretty"])}),n=t.map(function(e){var t;return{value:e.name,label:null===(t=e.uiSchema)||void 0===t?void 0:t.title}}),u=(0,o.useMemo)(function(){var n=((null===(u=e.options)||void 0===u?void 0:null===(a=u.public)||void 0===a?void 0:a.signupForm)||[]).filter(function(e){return t.find(function(t){return t.name===e.field})}),r=!0,o=!1,i=void 0;try{for(var a,u,c,s=t[Symbol.iterator]();!(r=(c=s.next()).done);r=!0)!function(){var e=c.value;!n.find(function(t){return t.field===e.name})&&n.push({field:e.name,show:"username"===e.name,required:"username"===e.name})}()}catch(e){o=!0,i=e}finally{try{!r&&null!=s.return&&s.return()}finally{if(o)throw i}}return n},[t,e]);return(0,o.useEffect)(function(){var t;e.options=A(F({},e.options),{public:A(F({},null===(t=e.options)||void 0===t?void 0:t.public),{signupForm:u})})},[e,u]),i().createElement(r.SchemaComponent,{components:{ArrayTable:j.ArrayTable},schema:{type:"void",properties:{signupForm:{title:'{{t("Sign up form")}}',type:"array","x-decorator":"FormItem","x-component":"ArrayTable","x-component-props":{bordered:!1},"x-validator":"{{ (value) => {\n const check = value?.some((item) => ['username', 'email'].includes(item.field) && item.show && item.required);\n if (!check) {\n return t('At least one of the username or email fields is required');\n }\n} }}",default:u,items:{type:"object","x-decorator":"ArrayItems.Item",properties:{column0:{type:"void","x-component":"ArrayTable.Column","x-component-props":{width:20,align:"center"},properties:{sort:{type:"void","x-component":"ArrayTable.SortHandle"}}},column1:{type:"void","x-component":"ArrayTable.Column","x-component-props":{width:100,title:(0,a.KQ)("Field")},properties:{field:{type:"string","x-decorator":"FormItem","x-component":"Select",enum:n,"x-read-pretty":!0}}},column2:{type:"void","x-component":"ArrayTable.Column","x-component-props":{width:80,title:(0,a.KQ)("Show")},properties:{show:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-reactions":{dependencies:[".required"],fulfill:{state:{value:"{{ $deps[0] || $self.value }}"}}}}}},column3:{type:"void","x-component":"ArrayTable.Column","x-component-props":{width:80,title:(0,a.KQ)("Required")},properties:{required:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox","x-reactions":{dependencies:[".show"],fulfill:{state:{value:"{{ !$deps[0] ? false : $self.value }}"}}}}}}}}}}}})},C=function(){var e=(0,a.o$)().t;return i().createElement(r.SchemaComponent,{scope:{t:e},components:{Alert:v.Alert,SignupFormSettings:I,FormTab:j.FormTab},schema:{type:"object",properties:{notice:{type:"void","x-decorator":"FormItem","x-component":"Alert","x-component-props":{showIcon:!0,message:'{{t("The authentication allows users to sign in via username or email.")}}'}},public:{type:"object",properties:{collapse:{type:"void","x-component":"FormTab",properties:{basic:{type:"void","x-component":"FormTab.TabPane","x-component-props":{tab:(0,a.KQ)("Sign up settings")},properties:k({allowSignUp:{"x-decorator":"FormItem",type:"boolean",title:'{{t("Allow to sign up")}}',"x-component":"Checkbox",default:!0}},(0,b.uid)(),{type:"void","x-component":"SignupFormSettings"})}}}}}}}})}}}]);
|
package/dist/client/index.d.ts
CHANGED
|
@@ -8,8 +8,13 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { Plugin } from '@nocobase/client';
|
|
10
10
|
import { ComponentType } from 'react';
|
|
11
|
-
import { Authenticator as AuthenticatorType } from './authenticator';
|
|
12
|
-
|
|
11
|
+
import type { Authenticator as AuthenticatorType } from './authenticator';
|
|
12
|
+
declare const AuthenticatorsContextProvider: import("react").LazyExoticComponent<import("react").FC<{
|
|
13
|
+
children: import("react").ReactNode;
|
|
14
|
+
}> | typeof import("./pages").AuthLayout>, ExportAuthLayout: import("react").LazyExoticComponent<import("react").FC<{
|
|
15
|
+
children: import("react").ReactNode;
|
|
16
|
+
}> | typeof import("./pages").AuthLayout>;
|
|
17
|
+
export { AuthenticatorsContextProvider, ExportAuthLayout as AuthLayout };
|
|
13
18
|
export type AuthOptions = {
|
|
14
19
|
components: Partial<{
|
|
15
20
|
SignInForm: ComponentType<{
|
|
@@ -31,5 +36,8 @@ export declare class PluginAuthClient extends Plugin {
|
|
|
31
36
|
}
|
|
32
37
|
export { AuthenticatorsContext, useAuthenticator } from './authenticator';
|
|
33
38
|
export type { Authenticator } from './authenticator';
|
|
34
|
-
|
|
39
|
+
declare const useSignIn: (name: string) => {
|
|
40
|
+
run(): Promise<void>;
|
|
41
|
+
};
|
|
42
|
+
export { useSignIn };
|
|
35
43
|
export default PluginAuthClient;
|
package/dist/client/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("@nocobase/client"),require("@ant-design/icons"),require("@formily/react"),require("@formily/antd-v5"),require("@emotion/css"),require("react-i18next"),require("react"),require("@formily/shared"),require("@nocobase/utils/client"),require("antd"),require("react-router-dom")):"function"==typeof define&&define.amd?define("@nocobase/plugin-auth",["@nocobase/client","@ant-design/icons","@formily/react","@formily/antd-v5","@emotion/css","react-i18next","react","@formily/shared","@nocobase/utils/client","antd","react-router-dom"],t):"object"==typeof exports?exports["@nocobase/plugin-auth"]=t(require("@nocobase/client"),require("@ant-design/icons"),require("@formily/react"),require("@formily/antd-v5"),require("@emotion/css"),require("react-i18next"),require("react"),require("@formily/shared"),require("@nocobase/utils/client"),require("antd"),require("react-router-dom")):e["@nocobase/plugin-auth"]=t(e["@nocobase/client"],e["@ant-design/icons"],e["@formily/react"],e["@formily/antd-v5"],e["@emotion/css"],e["react-i18next"],e.react,e["@formily/shared"],e["@nocobase/utils/client"],e.antd,e["react-router-dom"])}(self,function(e,t,n,r,o,i,a,c,u,l,s){return function(){"use strict";var p={482:function(e){e.exports=t},964:function(e){e.exports=o},632:function(e){e.exports=r},505:function(e){e.exports=n},875:function(e){e.exports=c},772:function(t){t.exports=e},584:function(e){e.exports=u},721:function(e){e.exports=l},156:function(e){e.exports=a},238:function(e){e.exports=i},128:function(e){e.exports=s}},f={};function m(e){var t=f[e];if(void 0!==t)return t.exports;var n=f[e]={exports:{}};return p[e](n,n.exports,m),n.exports}m.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return m.d(t,{a:t}),t},m.d=function(e,t){for(var n in t)m.o(t,n)&&!m.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},m.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},m.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var y={};m.r(y),m.d(y,{AuthLayout:function(){return k},useSignIn:function(){return H},PluginAuthClient:function(){return eE},AuthenticatorsContextProvider:function(){return I},default:function(){return eF},AuthenticatorsContext:function(){return T},useAuthenticator:function(){return E}});var d=m("772"),b=m("584"),v=m("156"),h=m.n(v),x=function(e){var t=(0,d.useLocationSearch)(),n=(0,d.useApp)();return(0,v.useEffect)(function(){var e=new URLSearchParams(t),r=e.get("authenticator"),o=e.get("token");o&&(n.apiClient.auth.setToken(o),n.apiClient.auth.setAuthenticator(r))}),h().createElement(h().Fragment,null,e.children)},g=m("238"),w="auth";function O(){return(0,g.useTranslation)([w,"client"],{nsMode:"fallback"})}function S(e){return d.i18n.t(e,{ns:[w,"client"],nsMode:"fallback"})}var P=m("128"),A=m("505"),j=m("964"),C=m("721"),T=(0,v.createContext)([]);T.displayName="AuthenticatorsContext";var E=function(e){return(0,v.useContext)(T).find(function(t){return t.name===e})};function F(){var e,t,n=(e=["\n position: absolute;\n bottom: 24px;\n width: 100%;\n left: 0;\n text-align: center;\n "],!t&&(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return F=function(){return n},n}var I=function(e){var t=e.children,n=(0,d.useAPIClient)(),r=(0,d.useRequest)(function(){return n.resource("authenticators").publicList().then(function(e){var t;return(null==e?void 0:null===(t=e.data)||void 0===t?void 0:t.data)||[]})}),o=r.data,i=r.error;if(r.loading)return h().createElement("div",{style:{textAlign:"center",marginTop:20}},h().createElement(C.Spin,null));if(i)throw i;return h().createElement(T.Provider,{value:void 0===o?[]:o},t)};function k(){var e,t=(0,d.useSystemSettings)().data;return h().createElement("div",{style:{maxWidth:320,margin:"0 auto",paddingTop:"20vh"}},h().createElement("div",{style:{position:"fixed",top:"2em",right:"2em"}},h().createElement(d.SwitchLanguage,null)),h().createElement("h1",{style:{textAlign:"center"}},h().createElement(d.ReadPretty.TextArea,{value:null==t?void 0:null===(e=t.data)||void 0===e?void 0:e.title})),h().createElement(I,null,h().createElement(P.Outlet,null)),h().createElement("div",{className:(0,j.css)(F())},h().createElement(d.PoweredBy,null)))}function D(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function q(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,c=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){c=!0,r=e}finally{try{!a&&null!=o.return&&o.return()}finally{if(c)throw r}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return D(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return D(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function U(e,t){return!t&&(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function N(){var e=U(["\n display: flex;\n "]);return N=function(){return e},e}function _(){var e=U(["\n display: flex;\n "]);return _=function(){return e},e}var R=function(){var e=(0,d.usePlugin)(eF).authTypes.getEntities(),t={},n=!0,r=!1,o=void 0;try{for(var i,a=e[Symbol.iterator]();!(n=(i=a.next()).done);n=!0){var c,u=q(i.value,2),l=u[0],s=u[1];(null===(c=s.components)||void 0===c?void 0:c.SignInForm)&&(t[l]=s.components.SignInForm)}}catch(e){r=!0,o=e}finally{try{!n&&null!=a.return&&a.return()}finally{if(r)throw o}}return t},L=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=(0,d.usePlugin)(eF).authTypes.getEntities(),n={},r=!0,o=!1,i=void 0;try{for(var a,c=t[Symbol.iterator]();!(r=(a=c.next()).done);r=!0){var u,l=q(a.value,2),s=l[0],p=l[1];(null===(u=p.components)||void 0===u?void 0:u.SignInButton)&&(n[s]=p.components.SignInButton)}}catch(e){o=!0,i=e}finally{try{!r&&null!=c.return&&c.return()}finally{if(o)throw i}}var f=Object.keys(n);return e.filter(function(e){return f.includes(e.authType)}).map(function(e,t){return h().createElement(n[e.authType],{key:t,authenticator:e})})},$=function(){var e=O().t;(0,d.useCurrentDocumentTitle)("Signin"),(0,d.useViewport)();var t=R(),n=(0,v.useContext)(T),r=L(n);if(!n.length)return h().createElement("div",{style:{color:"#ccc"}},e("No authentication methods available."));var o=n.map(function(n){var r=t[n.authType];if(!!r){var o="".concat(e("Sign-in")," (").concat(A.Schema.compile(n.authTypeTitle||n.authType,{t:e}),")");return function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r,o,i;r=e,o=t,i=n[t],o in r?Object.defineProperty(r,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[o]=i})}return e}({component:(0,v.createElement)(r,{authenticator:n}),tabTitle:n.title||o},n)}}).filter(function(e){return e});return h().createElement(C.Space,{direction:"vertical",className:(0,j.css)(N())},o.length>1?h().createElement(C.Tabs,{items:o.map(function(e){return{label:e.tabTitle,key:e.name,children:e.component}})}):o.length?h().createElement("div",null,o[0].component):h().createElement(h().Fragment,null),h().createElement(C.Space,{direction:"vertical",className:(0,j.css)(_())},r))};function B(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function M(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,c=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){c=!0,r=e}finally{try{!a&&null!=o.return&&o.return()}finally{if(c)throw r}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return B(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return B(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(0,v.createContext)({}).displayName="SignupPageContext";var V=function(){var e=(0,d.usePlugin)(eF).authTypes.getEntities(),t={},n=!0,r=!1,o=void 0;try{for(var i,a=e[Symbol.iterator]();!(n=(i=a.next()).done);n=!0){var c,u=M(i.value,2),l=u[0],s=u[1];(null===(c=s.components)||void 0===c?void 0:c.SignUpForm)&&(t[l]=s.components.SignUpForm)}}catch(e){r=!0,o=e}finally{try{!n&&null!=a.return&&a.return()}finally{if(r)throw o}}return t},z=function(){(0,d.useViewport)(),(0,d.useCurrentDocumentTitle)("Signup");var e=V(),t=M((0,P.useSearchParams)(),1)[0].get("name"),n=(E(t)||{}).authType;return e[n]?(0,v.createElement)(e[n],{authenticatorName:t}):h().createElement(P.Navigate,{to:"/not-found",replace:!0})};function G(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Z(e,t,n,r,o,i,a){try{var c=e[i](a),u=c.value}catch(e){n(e);return}c.done?t(u):Promise.resolve(u).then(r,o)}var H=function(e){var t=(0,A.useForm)(),n=(0,d.useAPIClient)(),r=function(){arguments.length>0&&void 0!==arguments[0]&&arguments[0];var e,t,n=(0,P.useNavigate)();var r=(e=(0,P.useSearchParams)(),t=1,function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,c=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){c=!0,r=e}finally{try{!a&&null!=o.return&&o.return()}finally{if(c)throw r}}return i}}(e,1)||function(e,t){if(e){if("string"==typeof e)return G(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return G(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0];return(0,v.useCallback)(function(){n(r.get("redirect")||"/admin",{replace:!0})},[n,r])}(),o=(0,d.useCurrentUserContext)().refreshAsync;return{run:function(){var i;return(i=function(){return function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}}(this,function(i){switch(i.label){case 0:return[4,t.submit()];case 1:return i.sent(),[4,n.auth.signIn(t.values,e)];case 2:return i.sent(),[4,o()];case 3:return i.sent(),r(),[2]}})},function(){var e=this,t=arguments;return new Promise(function(n,r){var o=i.apply(e,t);function a(e){Z(o,n,r,a,c,"next",e)}function c(e){Z(o,n,r,a,c,"throw",e)}a(void 0)})})()}}},K={type:"object",name:"passwordForm","x-component":"FormV2",properties:{account:{type:"string","x-component":"Input","x-validator":'{{(value) => {\n if (!value) {\n return t("Please enter your username or email");\n }\n if (value.includes(\'@\')) {\n if (!/^[\\w-]+(\\.[\\w-]+)*@[\\w-]+(\\.[\\w-]+)+$/.test(value)) {\n return t("Please enter a valid email");\n }\n } else {\n return /^[^@.<>"\'/]{1,50}$/.test(value) || t("Please enter a valid username");\n }\n }}}',"x-decorator":"FormItem","x-component-props":{placeholder:'{{t("Username/Email")}}',style:{}}},password:{type:"string","x-component":"Password",required:!0,"x-decorator":"FormItem","x-component-props":{placeholder:'{{t("Password")}}',style:{}}},actions:{type:"void","x-component":"div",properties:{submit:{title:'{{t("Sign in")}}',type:"void","x-component":"Action","x-component-props":{htmlType:"submit",block:!0,type:"primary",useAction:"{{ useBasicSignIn }}",style:{width:"100%"}}}}},signUp:{type:"void","x-component":"Link","x-component-props":{to:"{{ signUpLink }}"},"x-content":'{{t("Create an account")}}',"x-visible":"{{ allowSignUp }}"}}},W=function(e){var t=O().t,n=e.authenticator,r=n.authType,o=n.name,i=n.options,a=!!V()[r]&&null!=i&&!!i.allowSignUp,c="/signup?name=".concat(o);return h().createElement(d.SchemaComponent,{schema:K,scope:{useBasicSignIn:function(){return H(o)},allowSignUp:a,signUpLink:c,t:t}})},J=m("875");function Q(e,t,n,r,o,i,a){try{var c=e[i](a),u=c.value}catch(e){n(e);return}c.done?t(u):Promise.resolve(u).then(r,o)}var X={username:{type:"string","x-component":"Input","x-validator":{username:!0},"x-decorator":"FormItem","x-component-props":{placeholder:'{{t("Username")}}',style:{}}},email:{type:"string","x-component":"Input","x-validator":"email","x-decorator":"FormItem","x-component-props":{placeholder:'{{t("Email")}}',style:{}}}},Y=function(e){var t=(0,P.useNavigate)(),n=(0,A.useForm)(),r=(0,d.useAPIClient)(),o=(0,g.useTranslation)().t;return{run:function(){var i;return(i=function(){var i;return function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}}(this,function(a){switch(a.label){case 0:return[4,n.submit()];case 1:return a.sent(),[4,r.auth.signUp(n.values,null==e?void 0:e.authenticator)];case 2:return a.sent(),C.message.success((null==e?void 0:null===(i=e.message)||void 0===i?void 0:i.success)||o("Sign up successfully, and automatically jump to the sign in page")),setTimeout(function(){t("/signin")},2e3),[2]}})},function(){var e=this,t=arguments;return new Promise(function(n,r){var o=i.apply(e,t);function a(e){Q(o,n,r,a,c,"next",e)}function c(e){Q(o,n,r,a,c,"throw",e)}a(void 0)})})()}}},ee=function(e){var t,n;return{type:"object",name:(0,J.uid)(),"x-component":"FormV2",properties:(t=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r,o,i;r=e,o=t,i=n[t],o in r?Object.defineProperty(r,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[o]=i})}return e}({},e),n=(n={password:{type:"string",required:!0,"x-component":"Password","x-decorator":"FormItem","x-component-props":{placeholder:'{{t("Password")}}',checkStrength:!0,style:{}},"x-reactions":[{dependencies:[".confirm_password"],fulfill:{state:{selfErrors:'{{$deps[0] && $self.value && $self.value !== $deps[0] ? t("Password mismatch") : ""}}'}}}]},confirm_password:{type:"string",required:!0,"x-component":"Password","x-decorator":"FormItem","x-component-props":{placeholder:'{{t("Confirm password")}}',style:{}},"x-reactions":[{dependencies:[".password"],fulfill:{state:{selfErrors:'{{$deps[0] && $self.value && $self.value !== $deps[0] ? t("Password mismatch") : ""}}'}}}]},actions:{type:"void","x-component":"div",properties:{submit:{title:'{{t("Sign up")}}',type:"void","x-component":"Action","x-component-props":{block:!0,type:"primary",htmlType:"submit",useAction:"{{ useBasicSignUp }}",style:{width:"100%"}}}}},link:{type:"void","x-component":"div",properties:{link:{type:"void","x-component":"Link","x-component-props":{to:"/signin"},"x-content":'{{t("Log in with an existing account")}}'}}}},n),Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}),t)}},et=function(e){var t=e.authenticatorName,n=O().t,r=E(t).options,o=r.signupForm;!((null==o?void 0:o.length)&&o.some(function(e){return e.show&&e.required}))&&(o=[{field:"username",show:!0,required:!0}]);var i=(0,v.useMemo)(function(){return o.filter(function(e){return e.show}).reduce(function(e,t){var n=t.field;if(X[n])return e[n]=X[n],t.required&&(e[n].required=!0),e},{})},[o]);if(!(null==r?void 0:r.allowSignUp))return h().createElement(P.Navigate,{to:"/not-found",replace:!0});var a=ee(i);return h().createElement(d.SchemaComponent,{schema:a,scope:{useBasicSignUp:function(){return Y({authenticator:t})},t:n}})},en=m("632"),er=function(){var e=O().t;return h().createElement(d.SchemaComponent,{scope:{t:e},components:{Alert:C.Alert,FormTab:en.FormTab,ArrayTable:en.ArrayTable},schema:{type:"object",properties:{notice:{type:"void","x-decorator":"FormItem","x-component":"Alert","x-component-props":{showIcon:!0,message:'{{t("The authentication allows users to sign in via username or email.")}}'}},public:{type:"object",properties:{collapse:{type:"void","x-component":"FormTab",properties:{basic:{type:"void","x-component":"FormTab.TabPane","x-component-props":{tab:S("Sign up settings")},properties:{allowSignUp:{"x-decorator":"FormItem",type:"boolean",title:'{{t("Allow to sign up")}}',"x-component":"Checkbox",default:!0},signupForm:{title:'{{t("Sign up form")}}',type:"array","x-decorator":"FormItem","x-component":"ArrayTable","x-component-props":{bordered:!1},"x-validator":"{{ (value) => {\n const field = value?.filter((item) => item.show && item.required);\n if (!field?.length) {\n return t('At least one field is required');\n }\n} }}",default:[{field:"username",show:!0,required:!0},{field:"email",show:!1,required:!1}],items:{type:"object","x-decorator":"ArrayItems.Item",properties:{column0:{type:"void","x-component":"ArrayTable.Column","x-component-props":{width:20,align:"center"},properties:{sort:{type:"void","x-component":"ArrayTable.SortHandle"}}},column1:{type:"void","x-component":"ArrayTable.Column","x-component-props":{width:100,title:S("Field")},properties:{field:{type:"string","x-decorator":"FormItem","x-component":"Select",enum:[{label:S("Username"),value:"username"},{label:S("Email"),value:"email"}],"x-read-pretty":!0}}},column2:{type:"void","x-component":"ArrayTable.Column","x-component-props":{width:80,title:S("Show")},properties:{show:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox"}}},column3:{type:"void","x-component":"ArrayTable.Column","x-component-props":{width:80,title:S("Required")},properties:{required:{type:"boolean","x-decorator":"FormItem","x-component":"Checkbox"}}}}}}}}}}}}}}})},eo=(0,v.createContext)({type:""});eo.displayName="AuthTypeContext";var ei=(0,v.createContext)({types:[]});ei.displayName="AuthTypesContext";function ea(e,t,n,r,o,i,a){try{var c=e[i](a),u=c.value}catch(e){n(e);return}c.done?t(u):Promise.resolve(u).then(r,o)}var ec={name:"authenticators",sortable:!0,fields:[{name:"id",type:"string",interface:"id"},{interface:"input",type:"string",name:"name",uiSchema:{type:"string",title:'{{t("Auth UID")}}',"x-component":"Input","x-validator":function(e){return/^[a-zA-Z0-9_-]+$/.test(e)?"":d.i18n.t("a-z, A-Z, 0-9, _, -")},required:!0}},{interface:"input",type:"string",name:"authType",uiSchema:{type:"string",title:'{{t("Auth Type")}}',"x-component":"Select",dataSource:"{{ types }}",required:!0}},{interface:"input",type:"string",name:"title",uiSchema:{type:"string",title:'{{t("Title")}}',"x-component":"Input"}},{interface:"textarea",type:"string",name:"description",uiSchema:{type:"string",title:'{{t("Description")}}',"x-component":"Input"}},{type:"boolean",name:"enabled",uiSchema:{type:"boolean",title:'{{t("Enabled")}}',"x-component":"Checkbox"}}]},eu={type:"object",properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues:function(e){var t,n,r=(0,d.useActionContext)(),o=(0,v.useContext)(eo).type;return(0,d.useRequest)(function(){return Promise.resolve({data:{name:"s_".concat((0,J.uid)()),authType:o}})},(t=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r,o,i;r=e,o=t,i=n[t],o in r?Object.defineProperty(r,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[o]=i})}return e}({},e),n=(n={refreshDeps:[r.visible]},n),Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}),t))}},title:'{{t("Add new")}}',properties:{name:{"x-component":"CollectionField","x-decorator":"FormItem"},authType:{"x-component":"CollectionField","x-decorator":"FormItem","x-component-props":{options:"{{ types }}"}},title:{"x-component":"CollectionField","x-decorator":"FormItem"},description:{"x-component":"CollectionField","x-decorator":"FormItem"},enabled:{"x-component":"CollectionField","x-decorator":"FormItem"},options:{type:"object","x-component":"Options"},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useCreateAction }}"}}}}}}}},el={type:"void",name:"authenticators","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:ec,resourceName:"authenticators",dragSort:!0,request:{resource:"authenticators",action:"list",params:{pageSize:50,sort:"sort",appends:[]}}},"x-component":"CollectionProvider_deprecated","x-component-props":{collection:ec},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{delete:{type:"void",title:'{{t("Delete")}}',"x-component":"Action","x-component-props":{icon:"DeleteOutlined",useAction:"{{ cm.useBulkDestroyAction }}",confirm:{title:"{{t('Delete')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},create:{type:"void",title:'{{t("Add new")}}',"x-component":"AddNew","x-component-props":{type:"primary"}}}},table:{type:"void","x-uid":"input","x-component":"Table.Void","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}",useAction:function(){var e=(0,d.useAPIClient)(),t=(0,g.useTranslation)().t;return{move:function(n,r){var o;return(o=function(){return function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}}(this,function(o){switch(o.label){case 0:return[4,e.resource("authenticators").move({sourceId:n.id,targetId:r.id})];case 1:return o.sent(),C.message.success(t("Saved successfully"),.2),[2]}})},function(){var e=this,t=arguments;return new Promise(function(n,r){var i=o.apply(e,t);function a(e){ea(i,n,r,a,c,"next",e)}function c(e){ea(i,n,r,a,c,"throw",e)}a(void 0)})})()}}}},properties:{id:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{id:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},name:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{name:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},authType:{title:'{{t("Auth Type")}}',type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{authType:{type:"string","x-component":"Select","x-read-pretty":!0,enum:"{{ types }}"}}},title:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{title:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},description:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{description:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0}}},enabled:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{enabled:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{t("Actions")}}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{update:{type:"void",title:'{{t("Configure")}}',"x-component":"Action.Link","x-component-props":{type:"primary"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues:"{{ cm.useValuesFromRecord }}"},title:'{{t("Configure")}}',properties:{name:{"x-component":"CollectionField","x-decorator":"FormItem"},authType:{"x-component":"CollectionField","x-decorator":"FormItem","x-component-props":{options:"{{ types }}"}},title:{"x-component":"CollectionField","x-decorator":"FormItem"},description:{"x-component":"CollectionField","x-decorator":"FormItem"},enabled:{"x-component":"CollectionField","x-decorator":"FormItem"},options:{type:"object","x-component":"Options"},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useUpdateAction }}"}}}}}}}},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action.Link","x-component-props":{confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"},useAction:"{{cm.useDestroyAction}}"},"x-disabled":"{{ useCanNotDelete() }}"}}}}}}}}},es=m("482");function ep(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r,o,i;r=e,o=t,i=n[t],o in r?Object.defineProperty(r,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[o]=i})}return e}var ef=function(e){var t,n,r=(0,d.useRecord)();var o=(0,d.useRequest)(function(){return Promise.resolve({data:ep({},r.options)})},(t=ep({},e),n=(n={manual:!0},n),Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}),t)),i=o.run,a=(0,d.useActionContext)();return(0,v.useEffect)(function(){a.visible&&i()},[a.visible,i]),o},em=function(e){var t,n=(0,d.usePlugin)(eF).authTypes.get(e);return null==n?void 0:null===(t=n.components)||void 0===t?void 0:t.AdminSettingsForm},ey=(0,A.observer)(function(){var e=(0,A.useForm)(),t=(0,d.useRecord)(),n=em(e.values.authType||t.authType);return n?h().createElement(n,null):null},{displayName:"Options"});function ed(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function eb(e,t,n,r,o,i,a){try{var c=e[i](a),u=c.value}catch(e){n(e);return}c.done?t(u):Promise.resolve(u).then(r,o)}function ev(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,c=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){c=!0,r=e}finally{try{!a&&null!=o.return&&o.return()}finally{if(c)throw r}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return ed(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ed(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var eh=function(){var e=(0,d.useActionContext)().setVisible;return{run:function(){var t;return(t=function(){return function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}}(this,function(t){return e(!1),[2]})},function(){var e=this,n=arguments;return new Promise(function(r,o){var i=t.apply(e,n);function a(e){eb(i,r,o,a,c,"next",e)}function c(e){eb(i,r,o,a,c,"throw",e)}a(void 0)})})()}}},ex=function(){var e=(0,g.useTranslation)().t,t=ev((0,v.useState)(!1),2),n=t[0],r=t[1],o=ev((0,v.useState)(""),2),i=o[0],a=o[1],c=(0,v.useContext)(ei).types,u=c.map(function(e){var t,n;return t=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r,o,i;r=e,o=t,i=n[t],o in r?Object.defineProperty(r,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[o]=i})}return e}({},e),n=(n={onClick:function(){r(!0),a(e.value)}},n),Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}),t});return h().createElement(d.ActionContextProvider,{value:{visible:n,setVisible:r}},h().createElement(eo.Provider,{value:{type:i}},h().createElement(C.Dropdown,{menu:{items:u}},h().createElement(C.Button,{icon:h().createElement(es.PlusOutlined,null),type:"primary"},e("Add new")," ",h().createElement(es.DownOutlined,null))),h().createElement(d.SchemaComponent,{scope:{useCloseAction:eh,types:c,setType:a},schema:eu})))},eg=function(){return(0,d.useAsyncData)().data,!1},ew=function(){var e=O().t,t=ev((0,v.useState)([]),2),n=t[0],r=t[1],o=(0,d.useAPIClient)();return(0,d.useRequest)(function(){return o.resource("authenticators").listTypes().then(function(t){var n;return((null==t?void 0:null===(n=t.data)||void 0===n?void 0:n.data)||[]).map(function(t){return{key:t.name,label:A.Schema.compile(t.title||t.name,{t:e}),value:t.name}})})},{onSuccess:function(e){r(e)}}),h().createElement(C.Card,{bordered:!1},h().createElement(ei.Provider,{value:{types:n}},h().createElement(d.SchemaComponent,{schema:el,components:{AddNew:ex,Options:ey},scope:{types:n,useValuesFromOptions:ef,useCanNotDelete:eg,t:e}})))};function eO(e,t,n,r,o,i,a){try{var c=e[i](a),u=c.value}catch(e){n(e);return}c.done?t(u):Promise.resolve(u).then(r,o)}function eS(e,t,n){return(eS=eT()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&ej(o,n.prototype),o}).apply(null,arguments)}function eP(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function eA(e){return(eA=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function ej(e,t){return(ej=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function eC(e){var t="function"==typeof Map?new Map:void 0;return(eC=function(e){var n;if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return eS(e,arguments,eA(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),ej(r,e)})(e)}function eT(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(eT=function(){return!!e})()}var eE=function(e){var t,n,r;function o(){var e,t,n,r,i,a,c;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,o),t=this,n=o,r=arguments,n=eA(n),i=e=function(e,t){return t&&("object"===function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t)||"function"==typeof t)?t:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(t,eT()?Reflect.construct(n,r||[],eA(t).constructor):n.apply(t,r)),a="authTypes",c=new b.Registry,a in i?Object.defineProperty(i,a,{value:c,enumerable:!0,configurable:!0,writable:!0}):i[a]=c,e}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&ej(e,t)}(o,e),t=o,n=[{key:"registerType",value:function(e,t){this.authTypes.register(e,t)}},{key:"load",value:function(){var e,t=this;return(e=function(){return function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}}(this,function(e){return t.app.pluginSettingsManager.add(w,{icon:"LoginOutlined",title:'{{t("Authentication", { ns: "'.concat(w,'" })}}'),Component:ew,aclSnippet:"pm.auth.authenticators"}),t.router.add("auth",{Component:"AuthLayout"}),t.router.add("auth.signin",{path:"/signin",Component:"SignInPage"}),t.router.add("auth.signup",{path:"/signup",Component:"SignUpPage"}),t.app.addComponents({AuthLayout:k,SignInPage:$,SignUpPage:z}),t.app.providers.unshift([x,{}]),t.registerType("Email/Password",{components:{SignInForm:W,SignUpForm:et,AdminSettingsForm:er}}),[2]})},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){eO(i,r,o,a,c,"next",e)}function c(e){eO(i,r,o,a,c,"throw",e)}a(void 0)})})()}}],eP(t.prototype,n),o}(eC(d.Plugin)),eF=eE;return y}()});
|
|
10
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react-i18next"),require("@formily/antd-v5"),require("@formily/shared"),require("@nocobase/utils/client"),require("@nocobase/client"),require("antd"),require("@ant-design/icons"),require("@formily/react"),require("react-router-dom"),require("react"),require("@emotion/css")):"function"==typeof define&&define.amd?define("@nocobase/plugin-auth",["react-i18next","@formily/antd-v5","@formily/shared","@nocobase/utils/client","@nocobase/client","antd","@ant-design/icons","@formily/react","react-router-dom","react","@emotion/css"],e):"object"==typeof exports?exports["@nocobase/plugin-auth"]=e(require("react-i18next"),require("@formily/antd-v5"),require("@formily/shared"),require("@nocobase/utils/client"),require("@nocobase/client"),require("antd"),require("@ant-design/icons"),require("@formily/react"),require("react-router-dom"),require("react"),require("@emotion/css")):t["@nocobase/plugin-auth"]=e(t["react-i18next"],t["@formily/antd-v5"],t["@formily/shared"],t["@nocobase/utils/client"],t["@nocobase/client"],t.antd,t["@ant-design/icons"],t["@formily/react"],t["react-router-dom"],t.react,t["@emotion/css"])}(self,function(t,e,n,r,o,i,u,c,a,s,f){return function(){var l,p,d,h,y,b={437:function(t,e,n){"use strict";n.r(e),n.d(e,{AuthLayout:function(){return q},useSignIn:function(){return j},PluginAuthClient:function(){return O},AuthenticatorsContextProvider:function(){return k},default:function(){return C},AuthenticatorsContext:function(){return u.H},useAuthenticator:function(){return u.u}});var r=n("772"),o=n("584"),i=n("573"),u=n("308"),c=n(581);function a(t,e,n,r,o,i,u){try{var c=t[i](u),a=c.value}catch(t){n(t);return}c.done?e(a):Promise.resolve(a).then(r,o)}function s(t,e,n){return(s=h()?Reflect.construct:function(t,e,n){var r=[null];r.push.apply(r,e);var o=new(Function.bind.apply(t,r));return n&&p(o,n.prototype),o}).apply(null,arguments)}function f(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function l(t){return(l=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function p(t,e){return(p=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function d(t){var e="function"==typeof Map?new Map:void 0;return(d=function(t){var n;if(null===t||(n=t,-1===Function.toString.call(n).indexOf("[native code]")))return t;if("function"!=typeof t)throw TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return s(t,arguments,l(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),p(r,t)})(t)}function h(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(h=function(){return!!t})()}var y=(0,r.lazy)(function(){return c("imported_gs6osn_component",n.e("890").then(n.bind(n,387)))},"AuthProvider").AuthProvider,b=(0,r.lazy)(function(){return c("imported_kl5khg_component",n.e("938").then(n.bind(n,510)))},"Options","SignInForm","SignUpForm"),m=b.Options,g=b.SignInForm,v=b.SignUpForm,_=(0,r.lazy)(function(){return c("imported_-1ja1ffa_component",n.e("280").then(n.bind(n,492)))},"AuthLayout","SignInPage","SignUpPage"),x=_.AuthLayout,S=_.SignInPage,P=_.SignUpPage,A=(0,r.lazy)(function(){return c("imported_10vpsc8_component",n.e("851").then(n.bind(n,264)))},"Authenticator").Authenticator,w=(0,r.lazy)(function(){return c("imported_-1ja1ffa_component",n.e("280").then(n.bind(n,492)))},"AuthenticatorsContextProvider","AuthLayout"),k=w.AuthenticatorsContextProvider,q=w.AuthLayout,O=function(t){var e,n,r;function u(){var t,e,n,r,i,c,a;return!function(t,e){if(!(t instanceof e))throw TypeError("Cannot call a class as a function")}(this,u),e=this,n=u,r=arguments,n=l(n),i=t=function(t,e){return e&&("object"===function(t){return t&&"undefined"!=typeof Symbol&&t.constructor===Symbol?"symbol":typeof t}(e)||"function"==typeof e)?e:function(t){if(void 0===t)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(e,h()?Reflect.construct(n,r||[],l(e).constructor):n.apply(e,r)),c="authTypes",a=new o.Registry,c in i?Object.defineProperty(i,c,{value:a,enumerable:!0,configurable:!0,writable:!0}):i[c]=a,t}return!function(t,e){if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&p(t,e)}(u,t),e=u,n=[{key:"registerType",value:function(t,e){this.authTypes.register(t,e)}},{key:"load",value:function(){var t,e=this;return(t=function(){return function(t,e){var n,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(n)throw TypeError("Generator is already executing.");for(;u;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,r=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!(o=(o=u.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=e.call(t,u)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}}(this,function(t){return e.app.pluginSettingsManager.add(i.A7,{icon:"LoginOutlined",title:'{{t("Authentication", { ns: "'.concat(i.A7,'" })}}'),Component:A,aclSnippet:"pm.auth.authenticators"}),e.router.add("auth",{Component:"AuthLayout"}),e.router.add("auth.signin",{path:"/signin",Component:"SignInPage"}),e.router.add("auth.signup",{path:"/signup",Component:"SignUpPage"}),e.app.addComponents({AuthLayout:x,SignInPage:S,SignUpPage:P}),e.app.providers.unshift([y,{}]),e.registerType("Email/Password",{components:{SignInForm:g,SignUpForm:v,AdminSettingsForm:m}}),[2]})},function(){var e=this,n=arguments;return new Promise(function(r,o){var i=t.apply(e,n);function u(t){a(i,r,o,u,c,"next",t)}function c(t){a(i,r,o,u,c,"throw",t)}u(void 0)})})()}}],f(e.prototype,n),u}(d(r.Plugin)),j=function(t){return(0,r.useLazy)(function(){return c("imported_kl5khg_component",n.e("938").then(n.bind(n,510)))},"useSignIn")(t)},C=O},308:function(t,e,n){"use strict";n.d(e,{H:function(){return o},u:function(){return i}});var r=n(156),o=(0,r.createContext)([]);o.displayName="AuthenticatorsContext";var i=function(t){return(0,r.useContext)(o).find(function(e){return e.name===t})}},573:function(t,e,n){"use strict";n.d(e,{A7:function(){return i},KQ:function(){return c},o$:function(){return u}});var r=n(238),o=n(772),i="auth";function u(){return(0,r.useTranslation)([i,"client"],{nsMode:"fallback"})}function c(t){return o.i18n.t(t,{ns:[i,"client"],nsMode:"fallback"})}},581:function(t){t.exports=function(t,e){return"undefined"!=typeof __deoptimization_sideEffect__&&__deoptimization_sideEffect__(t,e),e}},482:function(t){"use strict";t.exports=u},964:function(t){"use strict";t.exports=f},632:function(t){"use strict";t.exports=e},505:function(t){"use strict";t.exports=c},875:function(t){"use strict";t.exports=n},772:function(t){"use strict";t.exports=o},584:function(t){"use strict";t.exports=r},721:function(t){"use strict";t.exports=i},156:function(t){"use strict";t.exports=s},238:function(e){"use strict";e.exports=t},128:function(t){"use strict";t.exports=a}},m={};function g(t){var e=m[t];if(void 0!==e)return e.exports;var n=m[t]={exports:{}};return b[t](n,n.exports,g),n.exports}return g.m=b,g.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return g.d(e,{a:e}),e},g.d=function(t,e){for(var n in e)g.o(e,n)&&!g.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},g.f={},g.e=function(t){return Promise.all(Object.keys(g.f).reduce(function(e,n){return g.f[n](t,e),e},[]))},g.u=function(t){return""+t+".index.js"},g.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},l={},p="@nocobase/plugin-auth:",g.l=function(t,e,n,r){if(l[t]){l[t].push(e);return}if(void 0!==n){for(var o,i,u=document.getElementsByTagName("script"),c=0;c<u.length;c++){var a=u[c];if(a.getAttribute("src")==t||a.getAttribute("data-webpack")==p+n){o=a;break}}}!o&&(i=!0,(o=document.createElement("script")).charset="utf-8",o.timeout=120,g.nc&&o.setAttribute("nonce",g.nc),o.setAttribute("data-webpack",p+n),o.src=t),l[t]=[e];var s=function(e,n){o.onerror=o.onload=null,clearTimeout(f);var r=l[t];if(delete l[t],o.parentNode&&o.parentNode.removeChild(o),r&&r.forEach(function(t){return t(n)}),e)return e(n)},f=setTimeout(s.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=s.bind(null,o.onerror),o.onload=s.bind(null,o.onload),i&&document.head.appendChild(o)},g.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},g.p="/static/plugins/@nocobase/plugin-auth/dist/client/",d={909:0},g.f.j=function(t,e){var n=g.o(d,t)?d[t]:void 0;if(0!==n){if(n)e.push(n[2]);else{var r=new Promise(function(e,r){n=d[t]=[e,r]});e.push(n[2]=r);var o=g.p+g.u(t),i=Error();g.l(o,function(e){if(g.o(d,t)&&(0!==(n=d[t])&&(d[t]=void 0),n)){var r=e&&("load"===e.type?"missing":e.type),o=e&&e.target&&e.target.src;i.message="Loading chunk "+t+" failed.\n("+r+": "+o+")",i.name="ChunkLoadError",i.type=r,i.request=o,n[1](i)}},"chunk-"+t,t)}}},h=function(t,e){var n=e[0],r=e[1],o=e[2],i,u,c=0;if(n.some(function(t){return 0!==d[t]})){for(i in r)g.o(r,i)&&(g.m[i]=r[i]);o&&o(g)}for(t&&t(e);c<n.length;c++)u=n[c],g.o(d,u)&&d[u]&&d[u][0](),d[u]=0},(y=self.webpackChunk_nocobase_plugin_auth=self.webpackChunk_nocobase_plugin_auth||[]).forEach(h.bind(null,0)),y.push=h.bind(null,y.push.bind(y)),g("437")}()});
|
package/dist/externalVersion.js
CHANGED
|
@@ -8,21 +8,22 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
module.exports = {
|
|
11
|
-
"@nocobase/client": "1.
|
|
11
|
+
"@nocobase/client": "1.6.0-alpha.1",
|
|
12
12
|
"react": "18.2.0",
|
|
13
|
-
"@nocobase/utils": "1.
|
|
14
|
-
"@nocobase/auth": "1.
|
|
15
|
-
"@nocobase/database": "1.
|
|
16
|
-
"
|
|
17
|
-
"@nocobase/
|
|
18
|
-
"@nocobase/
|
|
13
|
+
"@nocobase/utils": "1.6.0-alpha.1",
|
|
14
|
+
"@nocobase/auth": "1.6.0-alpha.1",
|
|
15
|
+
"@nocobase/database": "1.6.0-alpha.1",
|
|
16
|
+
"lodash": "4.17.21",
|
|
17
|
+
"@nocobase/cache": "1.6.0-alpha.1",
|
|
18
|
+
"@nocobase/server": "1.6.0-alpha.1",
|
|
19
|
+
"@nocobase/test": "1.6.0-alpha.1",
|
|
19
20
|
"@formily/antd-v5": "1.1.9",
|
|
20
21
|
"antd": "5.12.8",
|
|
22
|
+
"@formily/shared": "2.3.2",
|
|
21
23
|
"@formily/react": "2.3.0",
|
|
22
24
|
"react-router-dom": "6.21.0",
|
|
23
|
-
"@formily/shared": "2.3.2",
|
|
24
25
|
"react-i18next": "11.18.6",
|
|
25
26
|
"@emotion/css": "11.13.0",
|
|
26
27
|
"@ant-design/icons": "5.2.6",
|
|
27
|
-
"@nocobase/actions": "1.
|
|
28
|
+
"@nocobase/actions": "1.6.0-alpha.1"
|
|
28
29
|
};
|
package/dist/locale/en-US.json
CHANGED
|
@@ -28,5 +28,5 @@
|
|
|
28
28
|
"Show": "Show",
|
|
29
29
|
"Sign up settings": "Sign up settings",
|
|
30
30
|
"Sign up form": "Sign up form",
|
|
31
|
-
"At least one
|
|
31
|
+
"At least one of the username or email fields is required": "At least one of the username or email fields is required"
|
|
32
32
|
}
|
package/dist/locale/zh-CN.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"cron","description":"Cron jobs for your node","version":"2.4.4","author":"Nick Campbell <nicholas.j.campbell@gmail.com> (https://github.com/ncb000gt)","bugs":{"url":"https://github.com/kelektiv/node-cron/issues"},"repository":{"type":"git","url":"https://github.com/kelektiv/node-cron.git"},"main":"lib/cron","scripts":{"lint":"eslint {lib,tests}/*.js","test":"jest --coverage","test:watch":"jest --watch --coverage","test:types":"tsd","prepare":"husky install","release":"semantic-release"},"types":"types/index.d.ts","dependencies":{"@types/luxon":"~3.3.0","luxon":"~3.3.0"},"devDependencies":{"@commitlint/cli":"~17.6.6","@insurgentlab/commitlint-config":"^18.1.0","@insurgentlab/conventional-changelog-preset":"~6.0.3","@semantic-release/changelog":"~6.0.x","@semantic-release/commit-analyzer":"~9.0.x","@semantic-release/git":"~10.0.x","@semantic-release/github":"~8.1.x","@semantic-release/npm":"~10.0.x","@semantic-release/release-notes-generator":"~11.0.x","chai":"~4.2.x","eslint":"~8.36.x","eslint-config-prettier":"^8.7.x","eslint-config-standard":"~17.0.x","eslint-plugin-import":"~2.27.x","eslint-plugin-jest":"~27.2.x","eslint-plugin-n":"~15.6.x","eslint-plugin-prettier":"~4.2.x","eslint-plugin-promise":"~6.1.x","husky":"^8.0.3","jest":"~29.5.x","prettier":"~2.8.x","semantic-release":"~21.0.x","sinon":"^15.0.x","tsd":"^0.28.1"},"keywords":["cron","node cron","node-cron","schedule","scheduler","cronjob","cron job"],"license":"MIT","contributors":["Brandon der Blätter <https://interlucid.com/contact/> (https://github.com/intcreator)","Romain Beauxis <toots@rastageeks.org> (https://github.com/toots)","James Padolsey <> (https://github.com/jamespadolsey)","Finn Herpich <fh@three-heads.de> (https://github.com/ErrorProne)","Clifton Cunningham <clifton.cunningham@gmail.com> (https://github.com/cliftonc)","Eric Abouaf <eric.abouaf@gmail.com> (https://github.com/neyric)","humanchimp <morphcham@gmail.com> (https://github.com/humanchimp)","Craig Condon <craig@spiceapps.com> (https://github.com/spiceapps)","Dan Bear <daniel@hulu.com> (https://github.com/danhbear)","Vadim Baryshev <vadimbaryshev@gmail.com> (https://github.com/baryshev)","Leandro Ferrari <lfthomaz@gmail.com> (https://github.com/lfthomaz)","Gregg Zigler <greggzigler@gmail.com> (https://github.com/greggzigler)","Jordan Abderrachid <jabderrachid@gmail.com> (https://github.com/jordanabderrachid)","Masakazu Matsushita <matsukaz@gmail.com> (matsukaz)","Christopher Lunt <me@kirisu.co.uk> (https://github.com/kirisu)"],"jest":{"collectCoverage":true,"collectCoverageFrom":["lib/*.js"],"coverageThreshold":{"global":{"statements":80,"branches":80,"functions":70,"lines":80}}},"files":["lib","types","CHANGELOG.md","LICENSE","README.md"],"_lastModified":"2024-
|
|
1
|
+
{"name":"cron","description":"Cron jobs for your node","version":"2.4.4","author":"Nick Campbell <nicholas.j.campbell@gmail.com> (https://github.com/ncb000gt)","bugs":{"url":"https://github.com/kelektiv/node-cron/issues"},"repository":{"type":"git","url":"https://github.com/kelektiv/node-cron.git"},"main":"lib/cron","scripts":{"lint":"eslint {lib,tests}/*.js","test":"jest --coverage","test:watch":"jest --watch --coverage","test:types":"tsd","prepare":"husky install","release":"semantic-release"},"types":"types/index.d.ts","dependencies":{"@types/luxon":"~3.3.0","luxon":"~3.3.0"},"devDependencies":{"@commitlint/cli":"~17.6.6","@insurgentlab/commitlint-config":"^18.1.0","@insurgentlab/conventional-changelog-preset":"~6.0.3","@semantic-release/changelog":"~6.0.x","@semantic-release/commit-analyzer":"~9.0.x","@semantic-release/git":"~10.0.x","@semantic-release/github":"~8.1.x","@semantic-release/npm":"~10.0.x","@semantic-release/release-notes-generator":"~11.0.x","chai":"~4.2.x","eslint":"~8.36.x","eslint-config-prettier":"^8.7.x","eslint-config-standard":"~17.0.x","eslint-plugin-import":"~2.27.x","eslint-plugin-jest":"~27.2.x","eslint-plugin-n":"~15.6.x","eslint-plugin-prettier":"~4.2.x","eslint-plugin-promise":"~6.1.x","husky":"^8.0.3","jest":"~29.5.x","prettier":"~2.8.x","semantic-release":"~21.0.x","sinon":"^15.0.x","tsd":"^0.28.1"},"keywords":["cron","node cron","node-cron","schedule","scheduler","cronjob","cron job"],"license":"MIT","contributors":["Brandon der Blätter <https://interlucid.com/contact/> (https://github.com/intcreator)","Romain Beauxis <toots@rastageeks.org> (https://github.com/toots)","James Padolsey <> (https://github.com/jamespadolsey)","Finn Herpich <fh@three-heads.de> (https://github.com/ErrorProne)","Clifton Cunningham <clifton.cunningham@gmail.com> (https://github.com/cliftonc)","Eric Abouaf <eric.abouaf@gmail.com> (https://github.com/neyric)","humanchimp <morphcham@gmail.com> (https://github.com/humanchimp)","Craig Condon <craig@spiceapps.com> (https://github.com/spiceapps)","Dan Bear <daniel@hulu.com> (https://github.com/danhbear)","Vadim Baryshev <vadimbaryshev@gmail.com> (https://github.com/baryshev)","Leandro Ferrari <lfthomaz@gmail.com> (https://github.com/lfthomaz)","Gregg Zigler <greggzigler@gmail.com> (https://github.com/greggzigler)","Jordan Abderrachid <jabderrachid@gmail.com> (https://github.com/jordanabderrachid)","Masakazu Matsushita <matsukaz@gmail.com> (matsukaz)","Christopher Lunt <me@kirisu.co.uk> (https://github.com/kirisu)"],"jest":{"collectCoverage":true,"collectCoverageFrom":["lib/*.js"],"coverageThreshold":{"global":{"statements":80,"branches":80,"functions":70,"lines":80}}},"files":["lib","types","CHANGELOG.md","LICENSE","README.md"],"_lastModified":"2024-12-03T15:32:30.428Z"}
|
|
@@ -59,14 +59,14 @@ var authenticators_default = {
|
|
|
59
59
|
sort: "sort"
|
|
60
60
|
});
|
|
61
61
|
ctx.body = authenticators.map((authenticator) => {
|
|
62
|
-
var _a;
|
|
62
|
+
var _a, _b;
|
|
63
63
|
const authType = authManager.getAuthConfig(authenticator.authType);
|
|
64
64
|
return {
|
|
65
65
|
name: authenticator.name,
|
|
66
66
|
authType: authenticator.authType,
|
|
67
67
|
authTypeTitle: (authType == null ? void 0 : authType.title) || "",
|
|
68
68
|
title: authenticator.title,
|
|
69
|
-
options: ((_a = authenticator.options) == null ? void 0 :
|
|
69
|
+
options: ((_a = authType == null ? void 0 : authType.getPublicOptions) == null ? void 0 : _a.call(authType, authenticator.options)) || ((_b = authenticator.options) == null ? void 0 : _b.public) || {}
|
|
70
70
|
};
|
|
71
71
|
});
|
|
72
72
|
await next();
|
|
@@ -10,6 +10,7 @@ import { AuthConfig, BaseAuth } from '@nocobase/auth';
|
|
|
10
10
|
export declare class BasicAuth extends BaseAuth {
|
|
11
11
|
constructor(config: AuthConfig);
|
|
12
12
|
validate(): Promise<any>;
|
|
13
|
+
private getSignupFormSettings;
|
|
13
14
|
private verfiySignupParams;
|
|
14
15
|
signUp(): Promise<any>;
|
|
15
16
|
lostPassword(): Promise<any>;
|
|
@@ -42,6 +42,7 @@ module.exports = __toCommonJS(basic_auth_exports);
|
|
|
42
42
|
var import_auth = require("@nocobase/auth");
|
|
43
43
|
var import_crypto = __toESM(require("crypto"));
|
|
44
44
|
var import_preset = require("../preset");
|
|
45
|
+
var import_lodash = __toESM(require("lodash"));
|
|
45
46
|
class BasicAuth extends import_auth.BaseAuth {
|
|
46
47
|
constructor(config) {
|
|
47
48
|
const userCollection = config.ctx.db.getCollection("users");
|
|
@@ -75,21 +76,27 @@ class BasicAuth extends import_auth.BaseAuth {
|
|
|
75
76
|
}
|
|
76
77
|
return user;
|
|
77
78
|
}
|
|
78
|
-
|
|
79
|
+
getSignupFormSettings() {
|
|
79
80
|
var _a;
|
|
80
81
|
const options = ((_a = this.authenticator.options) == null ? void 0 : _a.public) || {};
|
|
81
|
-
let { signupForm } = options;
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
let { signupForm = [] } = options;
|
|
83
|
+
signupForm = signupForm.filter((item) => item.show);
|
|
84
|
+
if (!(signupForm.length && signupForm.some(
|
|
85
|
+
(item) => ["username", "email"].includes(item.field) && item.show && item.required
|
|
86
|
+
))) {
|
|
87
|
+
signupForm.push({ field: "username", show: true, required: true });
|
|
84
88
|
}
|
|
89
|
+
return signupForm;
|
|
90
|
+
}
|
|
91
|
+
verfiySignupParams(signupFormSettings, values) {
|
|
85
92
|
const { username, email } = values;
|
|
86
|
-
const usernameSetting =
|
|
93
|
+
const usernameSetting = signupFormSettings.find((item) => item.field === "username");
|
|
87
94
|
if (usernameSetting && usernameSetting.show) {
|
|
88
95
|
if (username && !this.validateUsername(username) || usernameSetting.required && !username) {
|
|
89
96
|
throw new Error("Please enter a valid username");
|
|
90
97
|
}
|
|
91
98
|
}
|
|
92
|
-
const emailSetting =
|
|
99
|
+
const emailSetting = signupFormSettings.find((item) => item.field === "email");
|
|
93
100
|
if (emailSetting && emailSetting.show) {
|
|
94
101
|
if (email && !/^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/.test(email)) {
|
|
95
102
|
throw new Error("Please enter a valid email address");
|
|
@@ -98,6 +105,12 @@ class BasicAuth extends import_auth.BaseAuth {
|
|
|
98
105
|
throw new Error("Please enter a valid email address");
|
|
99
106
|
}
|
|
100
107
|
}
|
|
108
|
+
const requiredFields = signupFormSettings.filter((item) => item.show && item.required);
|
|
109
|
+
requiredFields.forEach((item) => {
|
|
110
|
+
if (!values[item.field]) {
|
|
111
|
+
throw new Error(`Please enter ${item.field}`);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
101
114
|
}
|
|
102
115
|
async signUp() {
|
|
103
116
|
var _a;
|
|
@@ -108,9 +121,10 @@ class BasicAuth extends import_auth.BaseAuth {
|
|
|
108
121
|
}
|
|
109
122
|
const User = ctx.db.getRepository("users");
|
|
110
123
|
const { values } = ctx.action.params;
|
|
111
|
-
const {
|
|
124
|
+
const { password, confirm_password } = values;
|
|
125
|
+
const signupFormSettings = this.getSignupFormSettings();
|
|
112
126
|
try {
|
|
113
|
-
this.verfiySignupParams(values);
|
|
127
|
+
this.verfiySignupParams(signupFormSettings, values);
|
|
114
128
|
} catch (error) {
|
|
115
129
|
ctx.throw(400, this.ctx.t(error.message, { ns: import_preset.namespace }));
|
|
116
130
|
}
|
|
@@ -120,7 +134,9 @@ class BasicAuth extends import_auth.BaseAuth {
|
|
|
120
134
|
if (password !== confirm_password) {
|
|
121
135
|
ctx.throw(400, ctx.t("The password is inconsistent, please re-enter", { ns: import_preset.namespace }));
|
|
122
136
|
}
|
|
123
|
-
const
|
|
137
|
+
const fields = signupFormSettings.map((item) => item.field);
|
|
138
|
+
const userValues = import_lodash.default.pick(values, fields);
|
|
139
|
+
const user = await User.create({ values: { ...userValues, password } });
|
|
124
140
|
return user;
|
|
125
141
|
}
|
|
126
142
|
/* istanbul ignore next -- @preserve */
|
package/dist/server/plugin.js
CHANGED
|
@@ -72,16 +72,42 @@ class PluginAuthServer extends import_server.Plugin {
|
|
|
72
72
|
}
|
|
73
73
|
this.app.authManager.registerTypes(import_preset.presetAuthType, {
|
|
74
74
|
auth: import_basic_auth.BasicAuth,
|
|
75
|
-
title: (0, import_utils.tval)("Password", { ns: import_preset.namespace })
|
|
75
|
+
title: (0, import_utils.tval)("Password", { ns: import_preset.namespace }),
|
|
76
|
+
getPublicOptions: (options) => {
|
|
77
|
+
var _a;
|
|
78
|
+
const usersCollection = this.db.getCollection("users");
|
|
79
|
+
let signupForm = ((_a = options == null ? void 0 : options.public) == null ? void 0 : _a.signupForm) || [];
|
|
80
|
+
signupForm = signupForm.filter((item) => item.show);
|
|
81
|
+
if (!(signupForm.length && signupForm.some(
|
|
82
|
+
(item) => ["username", "email"].includes(item.field) && item.show && item.required
|
|
83
|
+
))) {
|
|
84
|
+
signupForm.unshift({ field: "username", show: true, required: true });
|
|
85
|
+
}
|
|
86
|
+
signupForm = signupForm.filter((field) => field.show).map((item) => {
|
|
87
|
+
var _a2;
|
|
88
|
+
const field = usersCollection.getField(item.field);
|
|
89
|
+
return {
|
|
90
|
+
...item,
|
|
91
|
+
uiSchema: {
|
|
92
|
+
...(_a2 = field.options) == null ? void 0 : _a2.uiSchema,
|
|
93
|
+
required: item.required
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
});
|
|
97
|
+
return {
|
|
98
|
+
...options == null ? void 0 : options.public,
|
|
99
|
+
signupForm
|
|
100
|
+
};
|
|
101
|
+
}
|
|
76
102
|
});
|
|
77
103
|
Object.entries(import_auth.default).forEach(
|
|
78
104
|
([action, handler]) => {
|
|
79
105
|
var _a;
|
|
80
|
-
return (_a = this.app.
|
|
106
|
+
return (_a = this.app.resourceManager.getResource("auth")) == null ? void 0 : _a.addAction(action, handler);
|
|
81
107
|
}
|
|
82
108
|
);
|
|
83
109
|
Object.entries(import_authenticators.default).forEach(
|
|
84
|
-
([action, handler]) => this.app.
|
|
110
|
+
([action, handler]) => this.app.resourceManager.registerActionHandler(`authenticators:${action}`, handler)
|
|
85
111
|
);
|
|
86
112
|
["check", "signIn", "signUp"].forEach((action) => this.app.acl.allow("auth", action));
|
|
87
113
|
["signOut", "changePassword"].forEach((action) => this.app.acl.allow("auth", action, "loggedIn"));
|
|
@@ -101,6 +127,127 @@ class PluginAuthServer extends import_server.Plugin {
|
|
|
101
127
|
this.app.on("cache:del:auth", async ({ userId }) => {
|
|
102
128
|
await this.cache.del(`auth:${userId}`);
|
|
103
129
|
});
|
|
130
|
+
this.app.auditManager.registerActions([
|
|
131
|
+
{
|
|
132
|
+
name: "auth:signIn",
|
|
133
|
+
getMetaData: async (ctx) => {
|
|
134
|
+
var _a, _b, _c, _d, _e, _f;
|
|
135
|
+
let body = {};
|
|
136
|
+
if (ctx.status === 200) {
|
|
137
|
+
body = {
|
|
138
|
+
data: {
|
|
139
|
+
...ctx.body.data,
|
|
140
|
+
token: void 0
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
} else {
|
|
144
|
+
body = ctx.body;
|
|
145
|
+
}
|
|
146
|
+
return {
|
|
147
|
+
request: {
|
|
148
|
+
params: (_a = ctx.request) == null ? void 0 : _a.params,
|
|
149
|
+
body: {
|
|
150
|
+
...(_b = ctx.request) == null ? void 0 : _b.body,
|
|
151
|
+
password: void 0
|
|
152
|
+
},
|
|
153
|
+
path: (_c = ctx.request) == null ? void 0 : _c.path,
|
|
154
|
+
headers: {
|
|
155
|
+
"x-authenticator": (_d = ctx.request) == null ? void 0 : _d.headers["x-authenticator"],
|
|
156
|
+
"x-locale": (_e = ctx.request) == null ? void 0 : _e.headers["x-locale"],
|
|
157
|
+
"x-timezone": (_f = ctx.request) == null ? void 0 : _f.headers["x-timezone"]
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
response: {
|
|
161
|
+
body
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
},
|
|
165
|
+
getUserInfo: async (ctx) => {
|
|
166
|
+
var _a, _b;
|
|
167
|
+
if (!((_b = (_a = ctx.body) == null ? void 0 : _a.data) == null ? void 0 : _b.user)) {
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
170
|
+
const userId = ctx.body.data.user.id;
|
|
171
|
+
const user = await ctx.db.getRepository("users").findOne({
|
|
172
|
+
filterByTk: userId
|
|
173
|
+
});
|
|
174
|
+
const roles = await (user == null ? void 0 : user.getRoles());
|
|
175
|
+
if (!roles) {
|
|
176
|
+
return {
|
|
177
|
+
userId
|
|
178
|
+
};
|
|
179
|
+
} else {
|
|
180
|
+
if (roles.length === 1) {
|
|
181
|
+
return {
|
|
182
|
+
userId,
|
|
183
|
+
roleName: roles[0].name
|
|
184
|
+
};
|
|
185
|
+
} else {
|
|
186
|
+
return {
|
|
187
|
+
userId
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
name: "auth:signUp",
|
|
195
|
+
getMetaData: async (ctx) => {
|
|
196
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
197
|
+
return {
|
|
198
|
+
request: {
|
|
199
|
+
params: (_a = ctx.request) == null ? void 0 : _a.params,
|
|
200
|
+
body: {
|
|
201
|
+
...(_b = ctx.request) == null ? void 0 : _b.body,
|
|
202
|
+
password: void 0,
|
|
203
|
+
confirm_password: void 0
|
|
204
|
+
},
|
|
205
|
+
path: (_c = ctx.request) == null ? void 0 : _c.path,
|
|
206
|
+
headers: {
|
|
207
|
+
"x-authenticator": (_d = ctx.request) == null ? void 0 : _d.headers["x-authenticator"],
|
|
208
|
+
"x-locale": (_e = ctx.request) == null ? void 0 : _e.headers["x-locale"],
|
|
209
|
+
"x-timezone": (_f = ctx.request) == null ? void 0 : _f.headers["x-timezone"]
|
|
210
|
+
}
|
|
211
|
+
},
|
|
212
|
+
response: {
|
|
213
|
+
body: {
|
|
214
|
+
...(_g = ctx.response) == null ? void 0 : _g.body,
|
|
215
|
+
token: void 0
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
name: "auth:changePassword",
|
|
223
|
+
getMetaData: async (ctx) => {
|
|
224
|
+
var _a, _b, _c;
|
|
225
|
+
return {
|
|
226
|
+
request: {
|
|
227
|
+
params: ctx.request.params,
|
|
228
|
+
query: ctx.request.query,
|
|
229
|
+
body: {},
|
|
230
|
+
path: ctx.request.path,
|
|
231
|
+
headers: {
|
|
232
|
+
"x-authenticator": (_a = ctx.request) == null ? void 0 : _a.headers["x-authenticator"],
|
|
233
|
+
"x-locale": (_b = ctx.request) == null ? void 0 : _b.headers["x-locale"],
|
|
234
|
+
"x-timezone": (_c = ctx.request) == null ? void 0 : _c.headers["x-timezone"]
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
response: {
|
|
238
|
+
body: {}
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
},
|
|
242
|
+
getSourceAndTarget: async (ctx) => {
|
|
243
|
+
return {
|
|
244
|
+
targetCollection: "users",
|
|
245
|
+
targetRecordUK: ctx.auth.user.id
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
},
|
|
249
|
+
"auth:signOut"
|
|
250
|
+
]);
|
|
104
251
|
}
|
|
105
252
|
async install(options) {
|
|
106
253
|
const repository = this.db.getRepository("authenticators");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-auth",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0-alpha.1",
|
|
4
4
|
"main": "./dist/server/index.js",
|
|
5
5
|
"homepage": "https://docs.nocobase.com/handbook/auth",
|
|
6
6
|
"homepage.zh-CN": "https://docs-cn.nocobase.com/handbook/auth",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"displayName.zh-CN": "用户认证",
|
|
27
27
|
"description": "User authentication management, including password, SMS, and support for Single Sign-On (SSO) protocols, with extensibility.",
|
|
28
28
|
"description.zh-CN": "用户认证管理,包括基础的密码认证、短信认证、SSO 协议的认证等,可扩展。",
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "a4c91015e34ec0c9a427451b5fbdfb5fedc4f3d7",
|
|
30
30
|
"keywords": [
|
|
31
31
|
"Authentication"
|
|
32
32
|
]
|