@nocobase/plugin-users 2.1.0-beta.36 → 2.1.0-beta.38

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.
@@ -7,4 +7,4 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react-i18next"),require("@emotion/css"),require("react-router-dom"),require("@formily/core"),require("@formily/shared"),require("react"),require("antd"),require("@nocobase/client"),require("@formily/react"),require("@nocobase/plugin-acl/client"),require("@nocobase/utils/client")):"function"==typeof define&&define.amd?define("@nocobase/plugin-users",["react-i18next","@emotion/css","react-router-dom","@formily/core","@formily/shared","react","antd","@nocobase/client","@formily/react","@nocobase/plugin-acl/client","@nocobase/utils/client"],t):"object"==typeof exports?exports["@nocobase/plugin-users"]=t(require("react-i18next"),require("@emotion/css"),require("react-router-dom"),require("@formily/core"),require("@formily/shared"),require("react"),require("antd"),require("@nocobase/client"),require("@formily/react"),require("@nocobase/plugin-acl/client"),require("@nocobase/utils/client")):e["@nocobase/plugin-users"]=t(e["react-i18next"],e["@emotion/css"],e["react-router-dom"],e["@formily/core"],e["@formily/shared"],e.react,e.antd,e["@nocobase/client"],e["@formily/react"],e["@nocobase/plugin-acl/client"],e["@nocobase/utils/client"])}(self,function(e,t,r,n,o,i,a,u,c,l,s){return function(){"use strict";var f,p,d,b={477:function(e){e.exports=t},452:function(e){e.exports=n},230:function(e){e.exports=c},166:function(e){e.exports=o},342:function(e){e.exports=u},79:function(e){e.exports=l},768:function(e){e.exports=s},59:function(e){e.exports=a},155:function(e){e.exports=i},953:function(t){t.exports=e},442:function(e){e.exports=r}},m={};function y(e){var t=m[e];if(void 0!==t)return t.exports;var r=m[e]={exports:{}};return b[e](r,r.exports,y),r.exports}y.m=b,y.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return y.d(t,{a:t}),t},y.d=function(e,t){for(var r in t)y.o(t,r)&&!y.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},y.f={},y.e=function(e){return Promise.all(Object.keys(y.f).reduce(function(t,r){return y.f[r](e,t),t},[]))},y.u=function(e){return""+e+"."+({49:"919f2c983a959288",772:"61c09631dd20ae13",821:"8ca2f675db381516",825:"5b87f2d207f047ef"})[e]+".js"},y.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),y.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},v={},y.l=function(e,t,r,n){if(v[e])return void v[e].push(t);if(void 0!==r)for(var o,i,a=document.getElementsByTagName("script"),u=0;u<a.length;u++){var c=a[u];if(c.getAttribute("src")==e||c.getAttribute("data-rspack")=="@nocobase/plugin-users:"+r){o=c;break}}o||(i=!0,(o=document.createElement("script")).timeout=120,y.nc&&o.setAttribute("nonce",y.nc),o.setAttribute("data-rspack","@nocobase/plugin-users:"+r),o.src=e),v[e]=[t];var l=function(t,r){o.onerror=o.onload=null,clearTimeout(s);var n=v[e];if(delete v[e],o.parentNode&&o.parentNode.removeChild(o),n&&n.forEach(function(e){return e(r)}),t)return t(r)},s=setTimeout(l.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=l.bind(null,o.onerror),o.onload=l.bind(null,o.onload),i&&document.head.appendChild(o)},y.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},y.g.importScripts&&(h=y.g.location+"");var v,h,g=y.g.document;if(!h&&g&&(g.currentScript&&"SCRIPT"===g.currentScript.tagName.toUpperCase()&&(h=g.currentScript.src),!h)){var w=g.getElementsByTagName("script");if(w.length)for(var x=w.length-1;x>-1&&(!h||!/^http(s?):/.test(h));)h=w[x--].src}if(!h)throw Error("Automatic publicPath is not supported in this browser");y.p=h.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),f={889:0},y.f.j=function(e,t){var r=y.o(f,e)?f[e]:void 0;if(0!==r)if(r)t.push(r[2]);else{var n=new Promise(function(t,n){r=f[e]=[t,n]});t.push(r[2]=n);var o=y.p+y.u(e),i=Error();y.l(o,function(t){if(y.o(f,e)&&(0!==(r=f[e])&&(f[e]=void 0),r)){var n=t&&("load"===t.type?"missing":t.type),o=t&&t.target&&t.target.src;i.message="Loading chunk "+e+" failed.\n("+n+": "+o+")",i.name="ChunkLoadError",i.type=n,i.request=o,r[1](i)}},"chunk-"+e,e)}},p=function(e,t){var r,n,o=t[0],i=t[1],a=t[2],u=0;if(o.some(function(e){return 0!==f[e]})){for(r in i)y.o(i,r)&&(y.m[r]=i[r]);a&&a(y)}for(e&&e(t);u<o.length;u++)n=o[u],y.o(f,n)&&f[n]&&f[n][0](),f[n]=0},(d=self.webpackChunk_nocobase_plugin_users=self.webpackChunk_nocobase_plugin_users||[]).forEach(p.bind(null,0)),d.push=p.bind(null,d.push.bind(d));var P={};return!function(){var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src&&(e=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/")),!e){var r=window.__webpack_public_path__||"";r&&("/"!==r.charAt(r.length-1)&&(r+="/"),e=r+"static/plugins/@nocobase/plugin-users/dist/client/")}if(!e){if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var n=window.location.pathname||"/",o=n.indexOf("/v2/");e=o>=0?n.slice(0,o+1):"/"}e&&(e=e.replace(/\/v2\/?$/,"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@nocobase/plugin-users/dist/client/"}y.p=e}(),!function(){y.r(P),y.d(P,{default:function(){return B}});var e,t,r,n=y(342),o=y(768),i=y(79),a=y.n(i),u=y(230),c=y(166),l=y(953),s=y(442),f=y(155),p=y.n(f);function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function b(e,t,r,n,o,i,a){try{var u=e[i](a),c=u.value}catch(e){r(e);return}u.done?t(c):Promise.resolve(c).then(n,o)}function m(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function a(e){b(i,n,o,a,u,"next",e)}function u(e){b(i,n,o,a,u,"throw",e)}a(void 0)})}}function v(e,t){var r,n,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(a,"next",{value:c(0)}),u(a,"throw",{value:c(1)}),u(a,"return",{value:c(2)}),"function"==typeof Symbol&&u(a,Symbol.iterator,{value:function(){return this}}),a;function c(u){return function(c){var l=[u,c];if(r)throw TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&l[0]?n.return:l[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,l[1])).done)return o;switch(n=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,n=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){i.label=l[1];break}if(6===l[0]&&i.label<o[1]){i.label=o[1],o=l;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(l);break}o[2]&&i.ops.pop(),i.trys.pop();continue}l=t.call(e,i)}catch(e){l=[6,e],n=0}finally{r=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}var h=function(){var e=(0,n.useActionContext)().setVisible,t=(0,u.useForm)();return{run:function(){return m(function(){return v(this,function(r){switch(r.label){case 0:return e(!1),[4,t.reset()];case 1:return r.sent(),[2]}})})()}}},g=function(){var e=(0,s.useNavigate)(),t=(0,n.useActionContext)().setVisible,r=(0,u.useForm)(),o=(0,n.useAPIClient)();return{run:function(){return m(function(){return v(this,function(n){switch(n.label){case 0:return[4,r.submit()];case 1:return n.sent(),[4,o.resource("auth").changePassword({values:r.values})];case 2:return n.sent(),[4,r.reset()];case 3:return n.sent(),t(!1),e("/signin"),[2]}})})()}}},w={type:"object",properties:(e={},t=(0,c.uid)(),r={"x-decorator":"Form","x-component":"Action.Drawer","x-component-props":{zIndex:2e3},type:"void",title:'{{t("Change password")}}',properties:{oldPassword:{type:"string",title:'{{t("Old password")}}',required:!0,"x-component":"Password","x-decorator":"FormItem"},newPassword:{type:"string",title:'{{t("New password")}}',required:!0,"x-component":"Password","x-decorator":"FormItem","x-validator":{password:!0},"x-component-props":{checkStrength:!0,style:{}},"x-reactions":[{dependencies:[".confirmPassword"],fulfill:{state:{selfErrors:'{{$deps[0] && $self.value && $self.value !== $deps[0] ? t("Password mismatch") : ""}}'}}}]},confirmPassword:{type:"string",required:!0,title:'{{t("Confirm password")}}',"x-component":"Password","x-decorator":"FormItem","x-component-props":{checkStrength:!0,style:{}},"x-reactions":[{dependencies:[".newPassword"],fulfill:{state:{selfErrors:'{{$deps[0] && $self.value && $self.value !== $deps[0] ? t("Password mismatch") : ""}}'}}}]},footer:{"x-component":"Action.Drawer.Footer",type:"void",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ useCloseAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSaveCurrentUserValues }}"}}}}}},t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e)},x=function(){var e,t=(0,f.useContext)(n.DropdownVisibleContext),r=function(e){if(Array.isArray(e))return e}(e=(0,f.useState)(!1))||function(e){var t,r,n=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var o=[],i=!0,a=!1;try{for(n=n.call(e);!(i=(t=n.next()).done)&&(o.push(t.value),2!==o.length);i=!0);}catch(e){a=!0,r=e}finally{try{i||null==n.return||n.return()}finally{if(a)throw r}}return o}}(e)||function(e){if(e){if("string"==typeof e)return d(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return d(e,2)}}(e)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),o=r[0],i=r[1],a=(0,l.useTranslation)().t,u=((0,n.useSystemSettings)()||{}).data,c=((null==u?void 0:u.data)||{}).enableChangePassword,s=(0,n.useZIndexContext)()+10,b=(0,f.useCallback)(function(e){var r;e.stopPropagation(),null==t||null==(r=t.setVisible)||r.call(t,!1),i(function(e){return!e||e})},[t]),m=(0,f.useMemo)(function(){return p().createElement(n.SchemaComponentContext.Provider,{value:{designable:!1}},p().createElement(n.SchemaComponent,{scope:{useCloseAction:h,useSaveCurrentUserValues:g},schema:w}))},[s]);return!1===c?null:p().createElement(n.zIndexContext.Provider,{value:s},p().createElement(n.SchemaSettingsItem,{eventKey:"changePassword",title:"changePassword"},p().createElement("div",{onClick:b},a("Change password"))),p().createElement(n.ActionContextProvider,{value:{visible:o,setVisible:i}},o&&p().createElement("div",{onClick:function(e){return e.stopPropagation()}},m)))};function C(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function S(e,t,r,n,o,i,a){try{var u=e[i](a),c=u.value}catch(e){r(e);return}u.done?t(c):Promise.resolve(c).then(n,o)}function O(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function j(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){O(e,t,r[t])})}return e}var k=function(){var e=(0,n.useCurrentUserContext)(),t=(0,n.useActionContext)().setVisible,r=(0,u.useForm)(),o=(0,n.useAPIClient)(),i=(0,u.useFieldSchema)(),a=(0,u.useField)(),c=(0,n.useCollectValuesToSubmit)();return{type:"primary",htmlType:"submit",onClick:function(){var n;return(n=function(){var n,u,l,s,f;return function(e,t){var r,n,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(a,"next",{value:c(0)}),u(a,"throw",{value:c(1)}),u(a,"return",{value:c(2)}),"function"==typeof Symbol&&u(a,Symbol.iterator,{value:function(){return this}}),a;function c(u){return function(c){var l=[u,c];if(r)throw TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&l[0]?n.return:l[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,l[1])).done)return o;switch(n=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,n=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){i.label=l[1];break}if(6===l[0]&&i.label<o[1]){i.label=o[1],o=l;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(l);break}o[2]&&i.ops.pop(),i.trys.pop();continue}l=t.call(e,i)}catch(e){l=[6,e],n=0}finally{r=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}(this,function(p){switch(p.label){case 0:if(l=(u=null!=(n=null==i?void 0:i["x-action-settings"])?n:{}).triggerWorkflows,u.skipValidator)return[3,2];return[4,r.submit()];case 1:p.sent(),p.label=2;case 2:return[4,c()];case 3:s=p.sent(),a.data=a.data||{},a.data.loading=!0,p.label=4;case 4:return p.trys.push([4,7,,8]),[4,o.resource("users").updateProfile({values:s,triggerWorkflows:(null==l?void 0:l.length)?l.map(function(e){return[e.workflowKey,e.context].filter(Boolean).join("!")}).join(","):void 0})];case 5:return p.sent(),e.mutate({data:j({},null==e||null==(f=e.data)?void 0:f.data,s)}),[4,r.reset()];case 6:return p.sent(),a.data.loading=!1,t(!1),[3,8];case 7:return p.sent(),a.data.loading=!1,[3,8];case 8:return[2]}})},function(){var e=this,t=arguments;return new Promise(function(r,o){var i=n.apply(e,t);function a(e){S(i,r,o,a,u,"next",e)}function u(e){S(i,r,o,a,u,"throw",e)}a(void 0)})})()}}},E=function(){var e,t=((0,n.useCurrentUserContext)()||{}).data;return{params:{filterByTk:null==t||null==(e=t.data)?void 0:e.id}}},A=function(){var e=(0,n.useActionContext)().setVisible;return{type:"default",onClick:function(){e(!1)}}},I=function(){var e=(0,f.useContext)(n.DropdownVisibleContext),t=(0,n.useCollectionManager)().getCollection("users"),r=(0,f.useMemo)(function(){var e,r;return e=j({},t),r=r={name:"users",fields:t.fields.filter(function(e){return!["password","roles"].includes(e.name)})},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t})(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}),e},[t]);return(0,f.useEffect)(function(){null==e||e.setVisible(!1)},[e]),p().createElement(n.ExtendCollectionsProvider,{collections:[r]},p().createElement(n.RemoteSchemaComponent,{uid:"nocobase-user-profile-edit-form",noForm:!0,scope:{useUpdateProfileActionProps:k,useEditFormBlockDecoratorProps:E,useCancelActionProps:A}}))},_=function(){var e,t,r=(0,f.useContext)(n.DropdownVisibleContext),o=function(e){if(Array.isArray(e))return e}(e=(0,f.useState)(!1))||function(e){var t,r,n=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var o=[],i=!0,a=!1;try{for(n=n.call(e);!(i=(t=n.next()).done)&&(o.push(t.value),2!==o.length);i=!0);}catch(e){a=!0,r=e}finally{try{i||null==n.return||n.return()}finally{if(a)throw r}}return o}}(e)||function(e){if(e){if("string"==typeof e)return C(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return C(e,2)}}(e)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),i=o[0],a=o[1],u=(0,l.useTranslation)().t,s=((0,n.useSystemSettings)()||{}).data,d=(null!=(t=null==s?void 0:s.data)?t:{}).enableEditProfile,b=(0,n.useZIndexContext)()+10,m=(0,f.useCallback)(function(e){var t;e.stopPropagation(),null==r||null==(t=r.setVisible)||t.call(r,!1),a(function(e){return!e||e})},[r]),y=(0,f.useMemo)(function(){return p().createElement(n.SchemaComponent,{components:{ProfileEditForm:I},schema:{type:"object",properties:O({},(0,c.uid)(),{"x-component":"Action.Drawer","x-component-props":{zIndex:b},type:"void",title:'{{t("Edit profile")}}',properties:{form:{type:"void","x-component":"ProfileEditForm"}}})}})},[b]);return!1===d?null:p().createElement(n.zIndexContext.Provider,{value:b},p().createElement(n.SchemaSettingsItem,{eventKey:"EditProfile",title:"EditProfile"},p().createElement("div",{onClick:m},u("Edit profile"))),p().createElement(n.ActionContextProvider,{value:{visible:i,setVisible:a}},i&&p().createElement("div",{onClick:function(e){return e.stopPropagation()}},y)))},U=function(){var e,t,r,o=(0,n.useCurrentUserContext)().data,i=(0,n.useToken)().token;return p().createElement(n.SchemaSettingsItem,{disabled:!0,eventKey:"nickname",title:"nickname"},p().createElement("span",{"aria-disabled":"false",style:{cursor:"text",color:i.colorTextDescription}},(null==o||null==(e=o.data)?void 0:e.nickname)||(null==o||null==(t=o.data)?void 0:t.username)||(null==o||null==(r=o.data)?void 0:r.email)))};function T(e,t,r,n,o,i,a){try{var u=e[i](a),c=u.value}catch(e){r(e);return}u.done?t(c):Promise.resolve(c).then(n,o)}var q=function(){var e=(0,l.useTranslation)().t,t=(0,n.useNavigateNoUpdate)(),r=(0,n.useAPIClient)(),o=(0,n.useCurrentUserContext)();return p().createElement(n.SchemaSettingsItem,{title:"signOut",eventKey:"signOut",onClick:function(){var e;return(e=function(){var e,n;return function(e,t){var r,n,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(a,"next",{value:c(0)}),u(a,"throw",{value:c(1)}),u(a,"return",{value:c(2)}),"function"==typeof Symbol&&u(a,Symbol.iterator,{value:function(){return this}}),a;function c(u){return function(c){var l=[u,c];if(r)throw TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&l[0]?n.return:l[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,l[1])).done)return o;switch(n=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,n=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){i.label=l[1];break}if(6===l[0]&&i.label<o[1]){i.label=o[1],o=l;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(l);break}o[2]&&i.ops.pop(),i.trys.pop();continue}l=t.call(e,i)}catch(e){l=[6,e],n=0}finally{r=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}(this,function(i){switch(i.label){case 0:return[4,r.auth.signOut()];case 1:return(null==(n=i.sent().data)||null==(e=n.data)?void 0:e.redirect)?window.location.href=n.data.redirect:t("/signin?redirect=".concat(encodeURIComponent(""))),o.mutate(null),[2]}})},function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function a(e){T(i,n,o,a,u,"next",e)}function u(e){T(i,n,o,a,u,"throw",e)}a(void 0)})})()}},e("Sign out"))};function M(e,t,r,n,o,i,a){try{var u=e[i](a),c=u.value}catch(e){r(e);return}u.done?t(c):Promise.resolve(c).then(n,o)}function F(e,t,r){return(F=N()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var o=new(Function.bind.apply(e,n));return r&&V(o,r.prototype),o}).apply(null,arguments)}function $(e){return($=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function V(e,t){return(V=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function D(e){var t="function"==typeof Map?new Map:void 0;return(D=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return F(e,arguments,$(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),V(r,e)})(e)}function N(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(N=function(){return!!e})()}(0,n.lazy)(function(){return y.e("821").then(y.bind(y,404))},"UsersProvider").UsersProvider;var R=(0,n.lazy)(function(){return Promise.all([y.e("49"),y.e("825")]).then(y.bind(y,616))},"UsersManagement").UsersManagement,z=(0,n.lazy)(function(){return Promise.all([y.e("49"),y.e("772")]).then(y.bind(y,687))},"RoleUsersManager").RoleUsersManager,B=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function r(){var e,t;if(!(this instanceof r))throw TypeError("Cannot call a class as a function");return e=r,t=arguments,e=$(e),function(e,t){var r;if(t&&("object"==((r=t)&&"u">typeof Symbol&&r.constructor===Symbol?"symbol":typeof r)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,N()?Reflect.construct(e,t||[],$(this).constructor):e.apply(this,t))}return r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),e&&V(r,e),t=[{key:"load",value:function(){var e;return(e=function(){return function(e,t){var r,n,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(a,"next",{value:c(0)}),u(a,"throw",{value:c(1)}),u(a,"return",{value:c(2)}),"function"==typeof Symbol&&u(a,Symbol.iterator,{value:function(){return this}}),a;function c(u){return function(c){var l=[u,c];if(r)throw TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&l[0]?n.return:l[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,l[1])).done)return o;switch(n=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,n=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){i.label=l[1];break}if(6===l[0]&&i.label<o[1]){i.label=o[1],o=l;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(l);break}o[2]&&i.ops.pop(),i.trys.pop();continue}l=t.call(e,i)}catch(e){l=[6,e],n=0}finally{r=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}(this,function(e){return this.app.pluginSettingsManager.add("users-permissions",{title:(0,o.tval)("Users & Permissions",{ns:"users"}),isPinned:!0,sort:200,icon:"TeamOutlined"}),this.app.pluginSettingsManager.add("users-permissions.users",{title:(0,o.tval)("Users"),icon:"UserOutlined",Component:R,aclSnippet:"pm.users"}),this.app.pm.get(a()).rolesManager.add("users",{title:(0,o.tval)("Users"),Component:z}),this.app.addUserCenterSettingsItem({name:"nickName",Component:U,sort:0}),this.app.addUserCenterSettingsItem({name:"divider1",type:"divider",sort:10}),this.app.addUserCenterSettingsItem({name:"editProfile",Component:_,sort:50}),this.app.addUserCenterSettingsItem({name:"changePassword",Component:x,sort:100}),this.app.addUserCenterSettingsItem({name:"divider_signOut",type:"divider",sort:900}),this.app.addUserCenterSettingsItem({name:"signOut",Component:q,sort:1e3}),[2]})},function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function a(e){M(i,n,o,a,u,"next",e)}function u(e){M(i,n,o,a,u,"throw",e)}a(void 0)})}).call(this)}}],function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(r.prototype,t),r}(D(n.Plugin))}(),P}()});
10
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react-i18next"),require("@emotion/css"),require("react-router-dom"),require("@formily/core"),require("@formily/shared"),require("react"),require("antd"),require("@nocobase/client"),require("@formily/react"),require("@nocobase/plugin-acl/client"),require("@nocobase/utils/client")):"function"==typeof define&&define.amd?define("@nocobase/plugin-users",["react-i18next","@emotion/css","react-router-dom","@formily/core","@formily/shared","react","antd","@nocobase/client","@formily/react","@nocobase/plugin-acl/client","@nocobase/utils/client"],t):"object"==typeof exports?exports["@nocobase/plugin-users"]=t(require("react-i18next"),require("@emotion/css"),require("react-router-dom"),require("@formily/core"),require("@formily/shared"),require("react"),require("antd"),require("@nocobase/client"),require("@formily/react"),require("@nocobase/plugin-acl/client"),require("@nocobase/utils/client")):e["@nocobase/plugin-users"]=t(e["react-i18next"],e["@emotion/css"],e["react-router-dom"],e["@formily/core"],e["@formily/shared"],e.react,e.antd,e["@nocobase/client"],e["@formily/react"],e["@nocobase/plugin-acl/client"],e["@nocobase/utils/client"])}(self,function(e,t,r,n,o,i,a,u,c,l,s){return function(){"use strict";var f,p,d,b={477:function(e){e.exports=t},452:function(e){e.exports=n},230:function(e){e.exports=c},166:function(e){e.exports=o},342:function(e){e.exports=u},79:function(e){e.exports=l},768:function(e){e.exports=s},59:function(e){e.exports=a},155:function(e){e.exports=i},953:function(t){t.exports=e},442:function(e){e.exports=r}},m={};function y(e){var t=m[e];if(void 0!==t)return t.exports;var r=m[e]={exports:{}};return b[e](r,r.exports,y),r.exports}y.m=b,y.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return y.d(t,{a:t}),t},y.d=function(e,t){for(var r in t)y.o(t,r)&&!y.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},y.f={},y.e=function(e){return Promise.all(Object.keys(y.f).reduce(function(t,r){return y.f[r](e,t),t},[]))},y.u=function(e){return""+e+"."+({49:"919f2c983a959288",772:"61c09631dd20ae13",821:"8ca2f675db381516",825:"5b87f2d207f047ef"})[e]+".js"},y.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),y.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},v={},y.l=function(e,t,r,n){if(v[e])return void v[e].push(t);if(void 0!==r)for(var o,i,a=document.getElementsByTagName("script"),u=0;u<a.length;u++){var c=a[u];if(c.getAttribute("src")==e||c.getAttribute("data-rspack")=="@nocobase/plugin-users:"+r){o=c;break}}o||(i=!0,(o=document.createElement("script")).timeout=120,y.nc&&o.setAttribute("nonce",y.nc),o.setAttribute("data-rspack","@nocobase/plugin-users:"+r),o.src=e),v[e]=[t];var l=function(t,r){o.onerror=o.onload=null,clearTimeout(s);var n=v[e];if(delete v[e],o.parentNode&&o.parentNode.removeChild(o),n&&n.forEach(function(e){return e(r)}),t)return t(r)},s=setTimeout(l.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=l.bind(null,o.onerror),o.onload=l.bind(null,o.onload),i&&document.head.appendChild(o)},y.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},y.g.importScripts&&(h=y.g.location+"");var v,h,g=y.g.document;if(!h&&g&&(g.currentScript&&"SCRIPT"===g.currentScript.tagName.toUpperCase()&&(h=g.currentScript.src),!h)){var w=g.getElementsByTagName("script");if(w.length)for(var x=w.length-1;x>-1&&(!h||!/^http(s?):/.test(h));)h=w[x--].src}if(!h)throw Error("Automatic publicPath is not supported in this browser");y.p=h.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),f={889:0},y.f.j=function(e,t){var r=y.o(f,e)?f[e]:void 0;if(0!==r)if(r)t.push(r[2]);else{var n=new Promise(function(t,n){r=f[e]=[t,n]});t.push(r[2]=n);var o=y.p+y.u(e),i=Error();y.l(o,function(t){if(y.o(f,e)&&(0!==(r=f[e])&&(f[e]=void 0),r)){var n=t&&("load"===t.type?"missing":t.type),o=t&&t.target&&t.target.src;i.message="Loading chunk "+e+" failed.\n("+n+": "+o+")",i.name="ChunkLoadError",i.type=n,i.request=o,r[1](i)}},"chunk-"+e,e)}},p=function(e,t){var r,n,o=t[0],i=t[1],a=t[2],u=0;if(o.some(function(e){return 0!==f[e]})){for(r in i)y.o(i,r)&&(y.m[r]=i[r]);a&&a(y)}for(e&&e(t);u<o.length;u++)n=o[u],y.o(f,n)&&f[n]&&f[n][0](),f[n]=0},(d=self.webpackChunk_nocobase_plugin_users=self.webpackChunk_nocobase_plugin_users||[]).forEach(p.bind(null,0)),d.push=p.bind(null,d.push.bind(d));var P={};return!function(){var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src&&(e=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/")),!e){var r=window.__webpack_public_path__||"";r&&("/"!==r.charAt(r.length-1)&&(r+="/"),e=r+"static/plugins/@nocobase/plugin-users/dist/client/")}if(!e){if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var n=window.location.pathname||"/",o=n.indexOf("/v2/");e=o>=0?n.slice(0,o+1):"/"}e&&(e=e.replace(/\/v2\/?$/,"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@nocobase/plugin-users/dist/client/"}y.p=e}(),!function(){y.r(P),y.d(P,{default:function(){return B}});var e,t,r,n=y(342),o=y(768),i=y(79),a=y.n(i),u=y(230),c=y(166),l=y(953),s=y(442),f=y(155),p=y.n(f);function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function b(e,t,r,n,o,i,a){try{var u=e[i](a),c=u.value}catch(e){r(e);return}u.done?t(c):Promise.resolve(c).then(n,o)}function m(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function a(e){b(i,n,o,a,u,"next",e)}function u(e){b(i,n,o,a,u,"throw",e)}a(void 0)})}}function v(e,t){var r,n,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(a,"next",{value:c(0)}),u(a,"throw",{value:c(1)}),u(a,"return",{value:c(2)}),"function"==typeof Symbol&&u(a,Symbol.iterator,{value:function(){return this}}),a;function c(u){return function(c){var l=[u,c];if(r)throw TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&l[0]?n.return:l[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,l[1])).done)return o;switch(n=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,n=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){i.label=l[1];break}if(6===l[0]&&i.label<o[1]){i.label=o[1],o=l;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(l);break}o[2]&&i.ops.pop(),i.trys.pop();continue}l=t.call(e,i)}catch(e){l=[6,e],n=0}finally{r=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}var h=function(){var e=(0,n.useActionContext)().setVisible,t=(0,u.useForm)();return{run:function(){return m(function(){return v(this,function(r){switch(r.label){case 0:return e(!1),[4,t.reset()];case 1:return r.sent(),[2]}})})()}}},g=function(){var e=(0,s.useNavigate)(),t=(0,n.useActionContext)().setVisible,r=(0,u.useForm)(),o=(0,n.useAPIClient)();return{run:function(){return m(function(){return v(this,function(n){switch(n.label){case 0:return[4,r.submit()];case 1:return n.sent(),[4,o.resource("auth").changePassword({values:r.values})];case 2:return n.sent(),[4,r.reset()];case 3:return n.sent(),t(!1),e("/signin"),[2]}})})()}}},w={type:"object",properties:(e={},t=(0,c.uid)(),r={"x-decorator":"Form","x-component":"Action.Drawer","x-component-props":{zIndex:2e3},type:"void",title:'{{t("Change password")}}',properties:{oldPassword:{type:"string",title:'{{t("Old password")}}',required:!0,"x-component":"Password","x-decorator":"FormItem"},newPassword:{type:"string",title:'{{t("New password")}}',required:!0,"x-component":"Password","x-decorator":"FormItem","x-validator":{password:!0},"x-component-props":{checkStrength:!0,style:{}},"x-reactions":[{dependencies:[".confirmPassword"],fulfill:{state:{selfErrors:'{{$deps[0] && $self.value && $self.value !== $deps[0] ? t("Password mismatch") : ""}}'}}}]},confirmPassword:{type:"string",required:!0,title:'{{t("Confirm password")}}',"x-component":"Password","x-decorator":"FormItem","x-component-props":{checkStrength:!0,style:{}},"x-reactions":[{dependencies:[".newPassword"],fulfill:{state:{selfErrors:'{{$deps[0] && $self.value && $self.value !== $deps[0] ? t("Password mismatch") : ""}}'}}}]},footer:{"x-component":"Action.Drawer.Footer",type:"void",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ useCloseAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useSaveCurrentUserValues }}"}}}}}},t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e)},x=function(){var e,t=(0,f.useContext)(n.DropdownVisibleContext),r=function(e){if(Array.isArray(e))return e}(e=(0,f.useState)(!1))||function(e){var t,r,n=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var o=[],i=!0,a=!1;try{for(n=n.call(e);!(i=(t=n.next()).done)&&(o.push(t.value),2!==o.length);i=!0);}catch(e){a=!0,r=e}finally{try{i||null==n.return||n.return()}finally{if(a)throw r}}return o}}(e)||function(e){if(e){if("string"==typeof e)return d(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return d(e,2)}}(e)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),o=r[0],i=r[1],a=(0,l.useTranslation)().t,u=((0,n.useSystemSettings)()||{}).data,c=((null==u?void 0:u.data)||{}).enableChangePassword,s=(0,n.useZIndexContext)()+10,b=(0,f.useCallback)(function(e){var r;e.stopPropagation(),null==t||null==(r=t.setVisible)||r.call(t,!1),i(function(e){return!e||e})},[t]),m=(0,f.useMemo)(function(){return p().createElement(n.SchemaComponentContext.Provider,{value:{designable:!1}},p().createElement(n.SchemaComponent,{scope:{useCloseAction:h,useSaveCurrentUserValues:g},schema:w}))},[s]);return!1===c?null:p().createElement(n.zIndexContext.Provider,{value:s},p().createElement(n.SchemaSettingsItem,{eventKey:"changePassword",title:"changePassword"},p().createElement("div",{onClick:b},a("Change password"))),p().createElement(n.ActionContextProvider,{value:{visible:o,setVisible:i}},o&&p().createElement("div",{onClick:function(e){return e.stopPropagation()}},m)))};function C(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function S(e,t,r,n,o,i,a){try{var u=e[i](a),c=u.value}catch(e){r(e);return}u.done?t(c):Promise.resolve(c).then(n,o)}function O(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function j(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){O(e,t,r[t])})}return e}var k=function(){var e=(0,n.useCurrentUserContext)(),t=(0,n.useActionContext)().setVisible,r=(0,u.useForm)(),o=(0,n.useAPIClient)(),i=(0,u.useFieldSchema)(),a=(0,u.useField)(),c=(0,n.useCollectValuesToSubmit)();return{type:"primary",htmlType:"submit",onClick:function(){var n;return(n=function(){var n,u,l,s,f;return function(e,t){var r,n,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(a,"next",{value:c(0)}),u(a,"throw",{value:c(1)}),u(a,"return",{value:c(2)}),"function"==typeof Symbol&&u(a,Symbol.iterator,{value:function(){return this}}),a;function c(u){return function(c){var l=[u,c];if(r)throw TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&l[0]?n.return:l[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,l[1])).done)return o;switch(n=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,n=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){i.label=l[1];break}if(6===l[0]&&i.label<o[1]){i.label=o[1],o=l;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(l);break}o[2]&&i.ops.pop(),i.trys.pop();continue}l=t.call(e,i)}catch(e){l=[6,e],n=0}finally{r=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}(this,function(p){switch(p.label){case 0:if(l=(u=null!=(n=null==i?void 0:i["x-action-settings"])?n:{}).triggerWorkflows,u.skipValidator)return[3,2];return[4,r.submit()];case 1:p.sent(),p.label=2;case 2:return[4,c()];case 3:s=p.sent(),a.data=a.data||{},a.data.loading=!0,p.label=4;case 4:return p.trys.push([4,7,,8]),[4,o.resource("users").updateProfile({values:s,triggerWorkflows:(null==l?void 0:l.length)?l.map(function(e){return[e.workflowKey,e.context].filter(Boolean).join("!")}).join(","):void 0})];case 5:return p.sent(),e.mutate({data:j({},null==e||null==(f=e.data)?void 0:f.data,s)}),[4,r.reset()];case 6:return p.sent(),a.data.loading=!1,t(!1),[3,8];case 7:return p.sent(),a.data.loading=!1,[3,8];case 8:return[2]}})},function(){var e=this,t=arguments;return new Promise(function(r,o){var i=n.apply(e,t);function a(e){S(i,r,o,a,u,"next",e)}function u(e){S(i,r,o,a,u,"throw",e)}a(void 0)})})()}}},E=function(){var e,t=((0,n.useCurrentUserContext)()||{}).data;return{params:{filterByTk:null==t||null==(e=t.data)?void 0:e.id}}},A=function(){var e=(0,n.useActionContext)().setVisible;return{type:"default",onClick:function(){e(!1)}}},I=function(){var e=(0,f.useContext)(n.DropdownVisibleContext),t=(0,n.useCollectionManager)().getCollection("users"),r=(0,f.useMemo)(function(){var e,r;return e=j({},t),r=r={name:"users",fields:t.fields.filter(function(e){return!["password","roles"].includes(e.name)})},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t})(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}),e},[t]);return(0,f.useEffect)(function(){null==e||e.setVisible(!1)},[e]),p().createElement(n.ExtendCollectionsProvider,{collections:[r]},p().createElement(n.RemoteSchemaComponent,{uid:"nocobase-user-profile-edit-form",noForm:!0,scope:{useUpdateProfileActionProps:k,useEditFormBlockDecoratorProps:E,useCancelActionProps:A}}))},_=function(){var e,t,r=(0,f.useContext)(n.DropdownVisibleContext),o=function(e){if(Array.isArray(e))return e}(e=(0,f.useState)(!1))||function(e){var t,r,n=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var o=[],i=!0,a=!1;try{for(n=n.call(e);!(i=(t=n.next()).done)&&(o.push(t.value),2!==o.length);i=!0);}catch(e){a=!0,r=e}finally{try{i||null==n.return||n.return()}finally{if(a)throw r}}return o}}(e)||function(e){if(e){if("string"==typeof e)return C(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return C(e,2)}}(e)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),i=o[0],a=o[1],u=(0,l.useTranslation)().t,s=((0,n.useSystemSettings)()||{}).data,d=(null!=(t=null==s?void 0:s.data)?t:{}).enableEditProfile,b=(0,n.useZIndexContext)()+10,m=(0,f.useCallback)(function(e){var t;e.stopPropagation(),null==r||null==(t=r.setVisible)||t.call(r,!1),a(function(e){return!e||e})},[r]),y=(0,f.useMemo)(function(){return p().createElement(n.SchemaComponent,{components:{ProfileEditForm:I},schema:{type:"object",properties:O({},(0,c.uid)(),{"x-component":"Action.Drawer","x-component-props":{zIndex:b},type:"void",title:'{{t("Edit profile")}}',properties:{form:{type:"void","x-component":"ProfileEditForm"}}})}})},[b]);return!1===d?null:p().createElement(n.zIndexContext.Provider,{value:b},p().createElement(n.SchemaSettingsItem,{eventKey:"EditProfile",title:"EditProfile"},p().createElement("div",{onClick:m},u("Edit profile"))),p().createElement(n.ActionContextProvider,{value:{visible:i,setVisible:a}},i&&p().createElement("div",{onClick:function(e){return e.stopPropagation()}},y)))},T=function(){var e,t,r,o=(0,n.useCurrentUserContext)().data,i=(0,n.useToken)().token;return p().createElement(n.SchemaSettingsItem,{disabled:!0,eventKey:"nickname",title:"nickname"},p().createElement("span",{"aria-disabled":"false",style:{cursor:"text",color:i.colorTextDescription}},(null==o||null==(e=o.data)?void 0:e.nickname)||(null==o||null==(t=o.data)?void 0:t.username)||(null==o||null==(r=o.data)?void 0:r.email)))};function U(e,t,r,n,o,i,a){try{var u=e[i](a),c=u.value}catch(e){r(e);return}u.done?t(c):Promise.resolve(c).then(n,o)}var q=function(){var e=(0,l.useTranslation)().t,t=(0,n.useNavigateNoUpdate)(),r=(0,n.useAPIClient)();return p().createElement(n.SchemaSettingsItem,{title:"signOut",eventKey:"signOut",onClick:function(){var e;return(e=function(){var e,n;return function(e,t){var r,n,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(a,"next",{value:c(0)}),u(a,"throw",{value:c(1)}),u(a,"return",{value:c(2)}),"function"==typeof Symbol&&u(a,Symbol.iterator,{value:function(){return this}}),a;function c(u){return function(c){var l=[u,c];if(r)throw TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&l[0]?n.return:l[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,l[1])).done)return o;switch(n=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,n=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){i.label=l[1];break}if(6===l[0]&&i.label<o[1]){i.label=o[1],o=l;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(l);break}o[2]&&i.ops.pop(),i.trys.pop();continue}l=t.call(e,i)}catch(e){l=[6,e],n=0}finally{r=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}(this,function(o){switch(o.label){case 0:return[4,r.auth.signOut()];case 1:return(null==(n=o.sent().data)||null==(e=n.data)?void 0:e.redirect)?window.location.href=n.data.redirect:t("/signin?redirect=".concat(encodeURIComponent("")),{replace:!0}),[2]}})},function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function a(e){U(i,n,o,a,u,"next",e)}function u(e){U(i,n,o,a,u,"throw",e)}a(void 0)})})()}},e("Sign out"))};function M(e,t,r,n,o,i,a){try{var u=e[i](a),c=u.value}catch(e){r(e);return}u.done?t(c):Promise.resolve(c).then(n,o)}function F(e,t,r){return(F=N()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var o=new(Function.bind.apply(e,n));return r&&V(o,r.prototype),o}).apply(null,arguments)}function $(e){return($=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function V(e,t){return(V=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function D(e){var t="function"==typeof Map?new Map:void 0;return(D=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return F(e,arguments,$(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),V(r,e)})(e)}function N(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(N=function(){return!!e})()}(0,n.lazy)(function(){return y.e("821").then(y.bind(y,404))},"UsersProvider").UsersProvider;var R=(0,n.lazy)(function(){return Promise.all([y.e("49"),y.e("825")]).then(y.bind(y,616))},"UsersManagement").UsersManagement,z=(0,n.lazy)(function(){return Promise.all([y.e("49"),y.e("772")]).then(y.bind(y,687))},"RoleUsersManager").RoleUsersManager,B=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function r(){var e,t;if(!(this instanceof r))throw TypeError("Cannot call a class as a function");return e=r,t=arguments,e=$(e),function(e,t){var r;if(t&&("object"==((r=t)&&"u">typeof Symbol&&r.constructor===Symbol?"symbol":typeof r)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,N()?Reflect.construct(e,t||[],$(this).constructor):e.apply(this,t))}return r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),e&&V(r,e),t=[{key:"load",value:function(){var e;return(e=function(){return function(e,t){var r,n,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(a,"next",{value:c(0)}),u(a,"throw",{value:c(1)}),u(a,"return",{value:c(2)}),"function"==typeof Symbol&&u(a,Symbol.iterator,{value:function(){return this}}),a;function c(u){return function(c){var l=[u,c];if(r)throw TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&l[0]?n.return:l[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,l[1])).done)return o;switch(n=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,n=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){i.label=l[1];break}if(6===l[0]&&i.label<o[1]){i.label=o[1],o=l;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(l);break}o[2]&&i.ops.pop(),i.trys.pop();continue}l=t.call(e,i)}catch(e){l=[6,e],n=0}finally{r=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}(this,function(e){return this.app.pluginSettingsManager.add("users-permissions",{title:(0,o.tval)("Users & Permissions",{ns:"users"}),isPinned:!0,sort:200,icon:"TeamOutlined"}),this.app.pluginSettingsManager.add("users-permissions.users",{title:(0,o.tval)("Users"),icon:"UserOutlined",Component:R,aclSnippet:"pm.users"}),this.app.pm.get(a()).rolesManager.add("users",{title:(0,o.tval)("Users"),Component:z}),this.app.addUserCenterSettingsItem({name:"nickName",Component:T,sort:0}),this.app.addUserCenterSettingsItem({name:"divider1",type:"divider",sort:10}),this.app.addUserCenterSettingsItem({name:"editProfile",Component:_,sort:50}),this.app.addUserCenterSettingsItem({name:"changePassword",Component:x,sort:100}),this.app.addUserCenterSettingsItem({name:"divider_signOut",type:"divider",sort:900}),this.app.addUserCenterSettingsItem({name:"signOut",Component:q,sort:1e3}),[2]})},function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function a(e){M(i,n,o,a,u,"next",e)}function u(e){M(i,n,o,a,u,"throw",e)}a(void 0)})}).call(this)}}],function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(r.prototype,t),r}(D(n.Plugin))}(),P}()});
@@ -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("ahooks"),require("react-i18next"),require("@nocobase/client-v2"),require("react-router-dom"),require("react"),require("antd"),require("@nocobase/flow-engine")):"function"==typeof define&&define.amd?define("@nocobase/plugin-users/client-v2",["ahooks","react-i18next","@nocobase/client-v2","react-router-dom","react","antd","@nocobase/flow-engine"],t):"object"==typeof exports?exports["@nocobase/plugin-users/client-v2"]=t(require("ahooks"),require("react-i18next"),require("@nocobase/client-v2"),require("react-router-dom"),require("react"),require("antd"),require("@nocobase/flow-engine")):e["@nocobase/plugin-users/client-v2"]=t(e.ahooks,e["react-i18next"],e["@nocobase/client-v2"],e["react-router-dom"],e.react,e.antd,e["@nocobase/flow-engine"])}(self,function(e,t,r,n,o,i,a){return function(){"use strict";var u={485:function(e){e.exports=r},694:function(e){e.exports=a},625:function(t){t.exports=e},59:function(e){e.exports=i},155:function(e){e.exports=o},953:function(e){e.exports=t},442:function(e){e.exports=n}},c={};function l(e){var t=c[e];if(void 0!==t)return t.exports;var r=c[e]={exports:{}};return u[e](r,r.exports,l),r.exports}l.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return l.d(t,{a:t}),t},l.d=function(e,t){for(var r in t)l.o(t,r)&&!l.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},l.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),l.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},l.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},l.g.importScripts&&(s=l.g.location+"");var s,f=l.g.document;if(!s&&f&&(f.currentScript&&"SCRIPT"===f.currentScript.tagName.toUpperCase()&&(s=f.currentScript.src),!s)){var p=f.getElementsByTagName("script");if(p.length)for(var d=p.length-1;d>-1&&(!s||!/^http(s?):/.test(s));)s=p[d--].src}if(!s)throw Error("Automatic publicPath is not supported in this browser");l.p=s.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/");var b={};return!function(){var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src&&(e=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/")),!e){var r=window.__webpack_public_path__||"";r&&("/"!==r.charAt(r.length-1)&&(r+="/"),e=r+"static/plugins/@nocobase/plugin-users/dist/client-v2/")}if(!e){if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var n=window.location.pathname||"/",o=n.indexOf("/v2/");e=o>=0?n.slice(0,o+1):"/"}e&&(e=e.replace(/\/v2\/?$/,"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@nocobase/plugin-users/dist/client-v2/"}l.p=e}(),!function(){l.r(b),l.d(b,{PluginUsersClientV2:function(){return G},NAMESPACE:function(){return o},default:function(){return J},useUsersTranslation:function(){return a},usersLocaleResources:function(){return i}});var e=l(485),t=l(953),r=JSON.parse('{"Add user":"Add user","Add users":"Add users","Allow change password":"Allow change password","Allow edit profile":"Allow edit profile","Are you sure you want to remove it?":"Are you sure you want to remove it?","Random password":"Random password","Remove user":"Remove user","User profile is not allowed to be edited":"User profile is not allowed to be edited","Users & Permissions":"Users & Permissions","Users manager":"Users manager"}'),n=JSON.parse('{"Add user":"添加用户","Add users":"添加用户","Allow change password":"允许修改密码","Allow edit profile":"允许修改个人资料","Are you sure you want to remove it?":"你确定要移除吗?","Random password":"随机密码","Remove user":"移除用户","User profile is not allowed to be edited":"用户资料不允许修改","Users & Permissions":"用户和权限","Users manager":"用户管理"}'),o="users",i={"en-US":r,"zh-CN":n};function a(){return(0,t.useTranslation)([o,"client"],{nsMode:"fallback"})}var u=l(694),c=l(625),s=l(59),f=l(155),p=l.n(f),d=l(442);function h(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function y(e,t,r,n,o,i,a){try{var u=e[i](a),c=u.value}catch(e){r(e);return}u.done?t(c):Promise.resolve(c).then(n,o)}function m(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function a(e){y(i,n,o,a,u,"next",e)}function u(e){y(i,n,o,a,u,"throw",e)}a(void 0)})}}function v(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function w(e){return(w=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function g(e,t){return(g=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function S(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,u=!1;try{for(o=o.call(e);!(a=(r=o.next()).done)&&(i.push(r.value),!t||i.length!==t);a=!0);}catch(e){u=!0,n=e}finally{try{a||null==o.return||o.return()}finally{if(u)throw n}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return h(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return h(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 O(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(O=function(){return!!e})()}function P(e,t){var r,n,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(a,"next",{value:c(0)}),u(a,"throw",{value:c(1)}),u(a,"return",{value:c(2)}),"function"==typeof Symbol&&u(a,Symbol.iterator,{value:function(){return this}}),a;function c(u){return function(c){var l=[u,c];if(r)throw TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&l[0]?n.return:l[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,l[1])).done)return o;switch(n=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,n=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){i.label=l[1];break}if(6===l[0]&&i.label<o[1]){i.label=o[1],o=l;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(l);break}o[2]&&i.ops.pop(),i.trys.pop();continue}l=t.call(e,i)}catch(e){l=[6,e],n=0}finally{r=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}function x(){var t=a().t,r=(0,u.useFlowContext)(),n=(0,d.useNavigate)(),o=S(s.Form.useForm(),1)[0],i=S((0,f.useState)(!1),2),l=i[0],b=i[1],h=S((0,f.useState)(""),2),y=h[0],v=h[1],w=(0,c.useMemoizedFn)(function(){return m(function(){var e,t,i,a,u,c;return P(this,function(l){switch(l.label){case 0:return[4,o.validateFields()];case 1:e=l.sent(),v(""),b(!0),l.label=2;case 2:return l.trys.push([2,4,5,6]),[4,r.api.resource("auth").changePassword({values:e})];case 3:return l.sent(),o.resetFields(),n("/signin"),[3,6];case 4:throw v((null==(t=l.sent())||null==(c=t.response)||null==(u=c.data)||null==(a=u.errors)||null==(i=a[0])?void 0:i.message)||(null==t?void 0:t.message)||String(t)),t;case 5:return b(!1),[7];case 6:return[2]}})})()});return p().createElement(e.DrawerFormLayout,{title:t("Change password"),onSubmit:w,submitting:l,submitText:t("Submit"),cancelText:t("Cancel")},p().createElement(s.Form,{form:o,layout:"vertical"},y?p().createElement(s.Alert,{type:"error",showIcon:!0,message:y,style:{marginBottom:16}}):null,p().createElement(s.Form.Item,{name:"oldPassword",label:t("Old password"),rules:[{required:!0,message:t("Please enter the old password")}]},p().createElement(e.PasswordInput,{autoComplete:"current-password"})),p().createElement(s.Form.Item,{name:"newPassword",label:t("New password"),rules:[{required:!0,message:t("Please enter the new password")}]},p().createElement(e.PasswordInput,{autoComplete:"new-password",checkStrength:!0})),p().createElement(s.Form.Item,{name:"confirmPassword",label:t("Confirm password"),dependencies:["newPassword"],rules:[{required:!0,message:t("Please confirm the new password")},function(e){var r=e.getFieldValue;return{validator:function(e,n){return n&&r("newPassword")!==n?Promise.reject(Error(t("Password mismatch"))):Promise.resolve()}}}]},p().createElement(e.PasswordInput,{autoComplete:"new-password",checkStrength:!0}))))}var j=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function r(){var e,t,n;if(!(this instanceof r))throw TypeError("Cannot call a class as a function");return t=r,n=arguments,t=w(t),v(e=function(e,t){var r;if(t&&("object"==((r=t)&&"u">typeof Symbol&&r.constructor===Symbol?"symbol":typeof r)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,O()?Reflect.construct(t,n||[],w(this).constructor):t.apply(this,n)),"section","profile"),v(e,"sort",100),v(e,"label","Change password"),e}return r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),e&&g(r,e),t=[{key:"prepare",value:function(){return m(function(){var e,t,r;return P(this,function(n){switch(n.label){case 0:return[4,this.context.systemSettings.load()];case 1:return r=null==(t=n.sent())||null==(e=t.data)?void 0:e.enableChangePassword,this.ready=!1!==r,[2]}})}).call(this)}},{key:"onClick",value:function(){return m(function(){return P(this,function(e){return this.context.viewer.drawer({width:"50%",closable:!0,content:function(){return p().createElement(x,null)}}),[2]})}).call(this)}}],function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(r.prototype,t),r}(e.UserCenterActionItemModel);function A(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function _(e,t,r,n,o,i,a){try{var u=e[i](a),c=u.value}catch(e){r(e);return}u.done?t(c):Promise.resolve(c).then(n,o)}function E(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function a(e){_(i,n,o,a,u,"next",e)}function u(e){_(i,n,o,a,u,"throw",e)}a(void 0)})}}function k(e,t,r){return t=q(t),function(e,t){var r;if(t&&("object"==((r=t)&&"u">typeof Symbol&&r.constructor===Symbol?"symbol":typeof r)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e,$()?Reflect.construct(t,r||[],q(e).constructor):t.apply(e,r))}function I(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}function C(e,t,r){return(C=$()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var o=new(Function.bind.apply(e,n));return r&&F(o,r.prototype),o}).apply(null,arguments)}function T(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function U(e,t,r){return t&&T(e.prototype,t),r&&T(e,r),e}function R(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function q(e){return(q=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function M(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&&F(e,t)}function F(e,t){return(F=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function N(e){var t="function"==typeof Map?new Map:void 0;return(N=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return C(e,arguments,q(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),F(r,e)})(e)}function $(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return($=function(){return!!e})()}function B(e,t){var r,n,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(a,"next",{value:c(0)}),u(a,"throw",{value:c(1)}),u(a,"return",{value:c(2)}),"function"==typeof Symbol&&u(a,Symbol.iterator,{value:function(){return this}}),a;function c(u){return function(c){var l=[u,c];if(r)throw TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&l[0]?n.return:l[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,l[1])).done)return o;switch(n=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,n=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){i.label=l[1];break}if(6===l[0]&&i.label<o[1]){i.label=o[1],o=l;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(l);break}o[2]&&i.ops.pop(),i.trys.pop();continue}l=t.call(e,i)}catch(e){l=[6,e],n=0}finally{r=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}v(j,"itemId","change-password");var V=function(e){function t(){var e;return I(this,t),e=k(this,t,arguments),R(e,"section","profile"),R(e,"sort",0),e}return M(t,e),U(t,[{key:"prepare",value:function(){return E(function(){var e;return B(this,function(t){return e=this.context.user||{},this.label=e.nickname||e.username||e.email||"",this.value=void 0,this.description=void 0,this.ready=!!this.label,[2]})}).call(this)}}]),t}(e.UserCenterTextItemModel);R(V,"itemId","current-user-summary");var z=function(t){function r(){var e;return I(this,r),e=k(this,r,arguments),R(e,"section","danger"),R(e,"sort",1e3),R(e,"label","Sign out"),e}return M(r,t),U(r,[{key:"onClick",value:function(){return E(function(){var t,r,n,o;return B(this,function(i){switch(i.label){case 0:return[4,this.context.api.auth.signOut()];case 1:if(n=i.sent(),o=(0,e.resolveV2SigninRedirect)(null==n||null==(r=n.data)||null==(t=r.data)?void 0:t.redirect,this.context.app))return window.location.replace(o),[2];return(0,e.redirectToV2Signin)(this.context.app,(0,e.getCurrentV2RedirectPath)(this.context.app,window.location),{replace:!0}),[2]}})}).call(this)}}]),r}(e.UserCenterActionItemModel);R(z,"itemId","sign-out");var G=function(e){function t(){return I(this,t),k(this,t,arguments)}return M(t,e),U(t,[{key:"load",value:function(){return E(function(){var e;return B(this,function(t){return e=this,Object.entries(i).forEach(function(t){var r,n=function(e){if(Array.isArray(e))return e}(t)||function(e){var t,r,n=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var o=[],i=!0,a=!1;try{for(n=n.call(e);!(i=(t=n.next()).done)&&(o.push(t.value),2!==o.length);i=!0);}catch(e){a=!0,r=e}finally{try{i||null==n.return||n.return()}finally{if(a)throw r}}return o}}(t)||function(e){if(e){if("string"==typeof e)return A(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return A(e,2)}}(t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),o=n[0],i=n[1];e.app.i18n.addResources(o,(null==(r=e.options)?void 0:r.packageName)||"@nocobase/plugin-users",i)}),this.app.flowEngine.registerModels({ChangePasswordItemModel:j,CurrentUserSummaryItemModel:V,SignOutItemModel:z}),[2]})}).call(this)}}]),t}(N(e.Plugin)),J=G}(),b}()});
10
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("ahooks"),require("react-i18next"),require("@nocobase/client-v2"),require("react-router-dom"),require("react"),require("antd"),require("@nocobase/flow-engine")):"function"==typeof define&&define.amd?define("@nocobase/plugin-users/client-v2",["ahooks","react-i18next","@nocobase/client-v2","react-router-dom","react","antd","@nocobase/flow-engine"],t):"object"==typeof exports?exports["@nocobase/plugin-users/client-v2"]=t(require("ahooks"),require("react-i18next"),require("@nocobase/client-v2"),require("react-router-dom"),require("react"),require("antd"),require("@nocobase/flow-engine")):e["@nocobase/plugin-users/client-v2"]=t(e.ahooks,e["react-i18next"],e["@nocobase/client-v2"],e["react-router-dom"],e.react,e.antd,e["@nocobase/flow-engine"])}(self,function(e,t,r,n,o,a,i){return function(){"use strict";var u={485:function(e){e.exports=r},694:function(e){e.exports=i},625:function(t){t.exports=e},59:function(e){e.exports=a},155:function(e){e.exports=o},953:function(e){e.exports=t},442:function(e){e.exports=n}},c={};function l(e){var t=c[e];if(void 0!==t)return t.exports;var r=c[e]={exports:{}};return u[e](r,r.exports,l),r.exports}l.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return l.d(t,{a:t}),t},l.d=function(e,t){for(var r in t)l.o(t,r)&&!l.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},l.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),l.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},l.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},l.g.importScripts&&(s=l.g.location+"");var s,f=l.g.document;if(!s&&f&&(f.currentScript&&"SCRIPT"===f.currentScript.tagName.toUpperCase()&&(s=f.currentScript.src),!s)){var p=f.getElementsByTagName("script");if(p.length)for(var d=p.length-1;d>-1&&(!s||!/^http(s?):/.test(s));)s=p[d--].src}if(!s)throw Error("Automatic publicPath is not supported in this browser");l.p=s.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/");var b={};return!function(){var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src&&(e=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/")),!e){var r=window.__webpack_public_path__||"";r&&("/"!==r.charAt(r.length-1)&&(r+="/"),e=r+"static/plugins/@nocobase/plugin-users/dist/client-v2/")}if(!e){if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var n=window.location.pathname||"/",o=n.indexOf("/v2/");e=o>=0?n.slice(0,o+1):"/"}e&&(e=e.replace(/\/v2\/?$/,"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@nocobase/plugin-users/dist/client-v2/"}l.p=e}(),!function(){l.r(b),l.d(b,{PluginUsersClientV2:function(){return $},NAMESPACE:function(){return c},default:function(){return B},useUsersTranslation:function(){return s}});var e=l(485),t=l(694),r=l(625),n=l(59),o=l(155),a=l.n(o),i=l(442),u=l(953),c="users";function s(){return(0,u.useTranslation)([c,"client"],{nsMode:"fallback"})}function f(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function p(e,t,r,n,o,a,i){try{var u=e[a](i),c=u.value}catch(e){r(e);return}u.done?t(c):Promise.resolve(c).then(n,o)}function d(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var a=e.apply(t,r);function i(e){p(a,n,o,i,u,"next",e)}function u(e){p(a,n,o,i,u,"throw",e)}i(void 0)})}}function h(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function y(e){return(y=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function v(e,t){return(v=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function m(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],i=!0,u=!1;try{for(o=o.call(e);!(i=(r=o.next()).done)&&(a.push(r.value),!t||a.length!==t);i=!0);}catch(e){u=!0,n=e}finally{try{i||null==o.return||o.return()}finally{if(u)throw n}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return f(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return f(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function w(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(w=function(){return!!e})()}function g(e,t){var r,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(i,"next",{value:c(0)}),u(i,"throw",{value:c(1)}),u(i,"return",{value:c(2)}),"function"==typeof Symbol&&u(i,Symbol.iterator,{value:function(){return this}}),i;function c(u){return function(c){var l=[u,c];if(r)throw TypeError("Generator is already executing.");for(;i&&(i=0,l[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&l[0]?n.return:l[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,l[1])).done)return o;switch(n=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return a.label++,{value:l[1],done:!1};case 5:a.label++,n=l[1],l=[0];continue;case 7:l=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){a=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){a.label=l[1];break}if(6===l[0]&&a.label<o[1]){a.label=o[1],o=l;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(l);break}o[2]&&a.ops.pop(),a.trys.pop();continue}l=t.call(e,a)}catch(e){l=[6,e],n=0}finally{r=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}function P(){var u=s().t,c=(0,t.useFlowContext)(),l=(0,i.useNavigate)(),f=m(n.Form.useForm(),1)[0],p=m((0,o.useState)(!1),2),b=p[0],h=p[1],y=m((0,o.useState)(""),2),v=y[0],w=y[1],P=(0,r.useMemoizedFn)(function(e,t){return d(function(){var e,r,n,o,a,i,u,l,s,f,p,d,b;return g(this,function(h){switch(h.label){case 0:if("string"!=typeof t||!t)return[2];i=(null==(a=null==(n=c.app)||null==(r=n.pm)||null==(e=r.get)?void 0:e.call(r,$))||null==(o=a.getPasswordValidators)?void 0:o.call(a))||[],u=!0,l=!1,s=void 0,h.label=1;case 1:h.trys.push([1,6,7,8]),f=i[Symbol.iterator](),h.label=2;case 2:if(u=(p=f.next()).done)return[3,5];return[4,(0,p.value)(t,{username:void 0})];case 3:if(d=h.sent())throw Error(d);h.label=4;case 4:return u=!0,[3,2];case 5:return[3,8];case 6:return b=h.sent(),l=!0,s=b,[3,8];case 7:try{u||null==f.return||f.return()}finally{if(l)throw s}return[7];case 8:return[2]}})})()}),x=(0,r.useMemoizedFn)(function(){return d(function(){var e,t,r,n,o,a;return g(this,function(i){switch(i.label){case 0:return[4,f.validateFields()];case 1:e=i.sent(),w(""),h(!0),i.label=2;case 2:return i.trys.push([2,4,5,6]),[4,c.api.resource("auth").changePassword({values:e})];case 3:return i.sent(),f.resetFields(),l("/signin"),[3,6];case 4:throw w((null==(t=i.sent())||null==(a=t.response)||null==(o=a.data)||null==(n=o.errors)||null==(r=n[0])?void 0:r.message)||(null==t?void 0:t.message)||String(t)),t;case 5:return h(!1),[7];case 6:return[2]}})})()});return a().createElement(e.DrawerFormLayout,{title:u("Change password"),onSubmit:x,submitting:b,submitText:u("Submit"),cancelText:u("Cancel")},a().createElement(n.Form,{form:f,layout:"vertical"},v?a().createElement(n.Alert,{type:"error",showIcon:!0,message:v,style:{marginBottom:16}}):null,a().createElement(n.Form.Item,{name:"oldPassword",label:u("Old password"),rules:[{required:!0,message:u("Please enter the old password")}]},a().createElement(e.PasswordInput,{autoComplete:"current-password"})),a().createElement(n.Form.Item,{name:"newPassword",label:u("New password"),rules:[{required:!0,message:u("Please enter the new password")},{validator:P}]},a().createElement(e.PasswordInput,{autoComplete:"new-password",checkStrength:!0})),a().createElement(n.Form.Item,{name:"confirmPassword",label:u("Confirm password"),dependencies:["newPassword"],rules:[{required:!0,message:u("Please confirm the new password")},function(e){var t=e.getFieldValue;return{validator:function(e,r){return r&&t("newPassword")!==r?Promise.reject(Error(u("Password mismatch"))):Promise.resolve()}}}]},a().createElement(e.PasswordInput,{autoComplete:"new-password",checkStrength:!0}))))}var x=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function r(){var e,t,n;if(!(this instanceof r))throw TypeError("Cannot call a class as a function");return t=r,n=arguments,t=y(t),h(e=function(e,t){var r;if(t&&("object"==((r=t)&&"u">typeof Symbol&&r.constructor===Symbol?"symbol":typeof r)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,w()?Reflect.construct(t,n||[],y(this).constructor):t.apply(this,n)),"section","profile"),h(e,"sort",100),h(e,"label","Change password"),e}return r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),e&&v(r,e),t=[{key:"prepare",value:function(){return d(function(){var e,t,r;return g(this,function(n){switch(n.label){case 0:return[4,this.context.systemSettings.load()];case 1:return r=null==(t=n.sent())||null==(e=t.data)?void 0:e.enableChangePassword,this.ready=!1!==r,[2]}})}).call(this)}},{key:"onClick",value:function(){return d(function(){return g(this,function(e){return this.context.viewer.drawer({width:"50%",closable:!0,content:function(){return a().createElement(P,null)}}),[2]})}).call(this)}}],function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(r.prototype,t),r}(e.UserCenterActionItemModel);function O(e,t,r,n,o,a,i){try{var u=e[a](i),c=u.value}catch(e){r(e);return}u.done?t(c):Promise.resolve(c).then(n,o)}function S(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var a=e.apply(t,r);function i(e){O(a,n,o,i,u,"next",e)}function u(e){O(a,n,o,i,u,"throw",e)}i(void 0)})}}function j(e,t,r){return t=T(t),function(e,t){var r;if(t&&("object"==((r=t)&&"u">typeof Symbol&&r.constructor===Symbol?"symbol":typeof r)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e,A()?Reflect.construct(t,r||[],T(e).constructor):t.apply(e,r))}function _(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}function k(e,t,r){return(k=A()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var o=new(Function.bind.apply(e,n));return r&&q(o,r.prototype),o}).apply(null,arguments)}function E(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function C(e,t,r){return t&&E(e.prototype,t),r&&E(e,r),e}function I(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function T(e){return(T=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function M(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&&q(e,t)}function q(e,t){return(q=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function F(e){var t="function"==typeof Map?new Map:void 0;return(F=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return k(e,arguments,T(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),q(r,e)})(e)}function A(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(A=function(){return!!e})()}function V(e,t){var r,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(i,"next",{value:c(0)}),u(i,"throw",{value:c(1)}),u(i,"return",{value:c(2)}),"function"==typeof Symbol&&u(i,Symbol.iterator,{value:function(){return this}}),i;function c(u){return function(c){var l=[u,c];if(r)throw TypeError("Generator is already executing.");for(;i&&(i=0,l[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&l[0]?n.return:l[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,l[1])).done)return o;switch(n=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return a.label++,{value:l[1],done:!1};case 5:a.label++,n=l[1],l=[0];continue;case 7:l=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){a=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){a.label=l[1];break}if(6===l[0]&&a.label<o[1]){a.label=o[1],o=l;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(l);break}o[2]&&a.ops.pop(),a.trys.pop();continue}l=t.call(e,a)}catch(e){l=[6,e],n=0}finally{r=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}h(x,"itemId","change-password");var R=function(e){function t(){var e;return _(this,t),e=j(this,t,arguments),I(e,"section","profile"),I(e,"sort",0),e}return M(t,e),C(t,[{key:"prepare",value:function(){return S(function(){var e;return V(this,function(t){return e=this.context.user||{},this.label=e.nickname||e.username||e.email||"",this.value=void 0,this.description=void 0,this.ready=!!this.label,[2]})}).call(this)}}]),t}(e.UserCenterTextItemModel);I(R,"itemId","current-user-summary");var U=function(t){function r(){var e;return _(this,r),e=j(this,r,arguments),I(e,"section","danger"),I(e,"sort",1e3),I(e,"label","Sign out"),e}return M(r,t),C(r,[{key:"onClick",value:function(){return S(function(){var t,r,n,o;return V(this,function(a){switch(a.label){case 0:return[4,this.context.api.auth.signOut()];case 1:if(n=a.sent(),o=(0,e.resolveV2SigninRedirect)(null==n||null==(r=n.data)||null==(t=r.data)?void 0:t.redirect,this.context.app))return window.location.replace(o),[2];return(0,e.redirectToV2Signin)(this.context.app,(0,e.getCurrentV2RedirectPath)(this.context.app,window.location),{replace:!0}),[2]}})}).call(this)}}]),r}(e.UserCenterActionItemModel);I(U,"itemId","sign-out");var $=function(e){function t(){var e;return _(this,t),e=j(this,t,arguments),I(e,"passwordValidators",new Map),e}return M(t,e),C(t,[{key:"registerPasswordValidator",value:function(e,t){this.passwordValidators.set(e,t)}},{key:"unregisterPasswordValidator",value:function(e){this.passwordValidators.delete(e)}},{key:"getPasswordValidators",value:function(){return Array.from(this.passwordValidators.values())}},{key:"load",value:function(){return S(function(){return V(this,function(e){return this.app.flowEngine.registerModels({ChangePasswordItemModel:x,CurrentUserSummaryItemModel:R,SignOutItemModel:U}),[2]})}).call(this)}}]),t}(F(e.Plugin)),B=$}(),b}()});
@@ -7,30 +7,4 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
  export declare const NAMESPACE = "users";
10
- export declare const usersLocaleResources: {
11
- 'en-US': {
12
- "Add user": string;
13
- "Add users": string;
14
- "Allow change password": string;
15
- "Allow edit profile": string;
16
- "Are you sure you want to remove it?": string;
17
- "Random password": string;
18
- "Remove user": string;
19
- "User profile is not allowed to be edited": string;
20
- "Users & Permissions": string;
21
- "Users manager": string;
22
- };
23
- 'zh-CN': {
24
- "Add user": string;
25
- "Add users": string;
26
- "Allow change password": string;
27
- "Allow edit profile": string;
28
- "Are you sure you want to remove it?": string;
29
- "Random password": string;
30
- "Remove user": string;
31
- "User profile is not allowed to be edited": string;
32
- "Users & Permissions": string;
33
- "Users manager": string;
34
- };
35
- };
36
10
  export declare function useUsersTranslation(): import("react-i18next").UseTranslationResponse<("users" | "client")[], undefined>;
@@ -7,7 +7,20 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
  import { Plugin } from '@nocobase/client-v2';
10
+ /**
11
+ * Async password validator contributed by another plugin (typically `@nocobase/plugin-password-policy`). Receives the candidate password and an optional `username` (matching v1's `verifyPasswordRules` third argument). Resolve with `null` / `undefined` for valid input, or with the already-translated error message for invalid input — the validator owns its own i18n namespace so consumers don't need to know how to interpolate the policy plugin's `{{n}}` placeholders.
12
+ */
13
+ export type PasswordValidator = (value: string, ctx: {
14
+ username?: string;
15
+ }) => Promise<string | null | undefined>;
10
16
  export declare class PluginUsersClientV2 extends Plugin {
17
+ private passwordValidators;
18
+ /**
19
+ * Register a password validator under a stable name. Re-registering the same name overwrites — useful for HMR and for tests that swap in a stub. Downstream plugins should register in their `load()` after `app.pm.get(PluginUsersClientV2)` resolves.
20
+ */
21
+ registerPasswordValidator(name: string, validator: PasswordValidator): void;
22
+ unregisterPasswordValidator(name: string): void;
23
+ getPasswordValidators(): PasswordValidator[];
11
24
  load(): Promise<void>;
12
25
  }
13
26
  export default PluginUsersClientV2;
@@ -8,14 +8,9 @@
8
8
  */
9
9
  import { UserCenterActionItemModel } from '@nocobase/client-v2';
10
10
  /**
11
- * "Change password" entry in the User Center dropdown. Section `profile`
12
- * with sort 100 puts it between `CurrentUserSummaryItemModel` (sort 0)
13
- * and `SignOutItemModel` (sort 1000) — same neighborhood as v1.
11
+ * "Change password" entry in the User Center dropdown. Section `profile` with sort 100 puts it between `CurrentUserSummaryItemModel` (sort 0) and `SignOutItemModel` (sort 1000) — same neighborhood as v1.
14
12
  *
15
- * `prepare()` reads `systemSettings.enableChangePassword`; when the
16
- * admin has explicitly disabled it, `ready = false` removes the entry
17
- * from the dropdown. Undefined / true both leave the entry visible
18
- * (matches v1: only an explicit `=== false` hides it).
13
+ * `prepare()` reads `systemSettings.enableChangePassword`; when the admin has explicitly disabled it, `ready = false` removes the entry from the dropdown. Undefined / true both leave the entry visible (matches v1: only an explicit `=== false` hides it).
19
14
  */
20
15
  export declare class ChangePasswordItemModel extends UserCenterActionItemModel {
21
16
  static itemId: string;
@@ -13,20 +13,20 @@ module.exports = {
13
13
  "react-i18next": "11.18.6",
14
14
  "react-router-dom": "6.30.1",
15
15
  "react": "18.2.0",
16
- "@nocobase/client": "2.1.0-beta.36",
16
+ "@nocobase/client": "2.1.0-beta.38",
17
17
  "antd": "5.24.2",
18
18
  "@formily/core": "2.3.7",
19
- "@nocobase/plugin-acl": "2.1.0-beta.36",
19
+ "@nocobase/plugin-acl": "2.1.0-beta.38",
20
20
  "@emotion/css": "11.13.0",
21
- "@nocobase/utils": "2.1.0-beta.36",
22
- "@nocobase/client-v2": "2.1.0-beta.36",
23
- "@nocobase/database": "2.1.0-beta.36",
24
- "@nocobase/server": "2.1.0-beta.36",
25
- "@nocobase/plugin-user-data-sync": "2.1.0-beta.36",
26
- "@nocobase/plugin-ui-schema-storage": "2.1.0-beta.36",
21
+ "@nocobase/utils": "2.1.0-beta.38",
22
+ "@nocobase/client-v2": "2.1.0-beta.38",
23
+ "@nocobase/database": "2.1.0-beta.38",
24
+ "@nocobase/server": "2.1.0-beta.38",
25
+ "@nocobase/plugin-user-data-sync": "2.1.0-beta.38",
26
+ "@nocobase/plugin-ui-schema-storage": "2.1.0-beta.38",
27
27
  "lodash": "4.18.1",
28
- "@nocobase/flow-engine": "2.1.0-beta.36",
28
+ "@nocobase/flow-engine": "2.1.0-beta.38",
29
29
  "ahooks": "3.7.8",
30
- "@nocobase/actions": "2.1.0-beta.36",
30
+ "@nocobase/actions": "2.1.0-beta.38",
31
31
  "sequelize": "6.35.2"
32
32
  };
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "description": "Provides basic user model, as well as created by and updated by fields.",
7
7
  "description.ru-RU": "Предоставляет базовую модель пользователя, а также поля кем, когда «создано» и «обновлено».",
8
8
  "description.zh-CN": "提供了基础的用户模型,以及创建人和最后更新人字段。",
9
- "version": "2.1.0-beta.36",
9
+ "version": "2.1.0-beta.38",
10
10
  "license": "Apache-2.0",
11
11
  "main": "./dist/server/index.js",
12
12
  "homepage": "https://docs.nocobase.com/handbook/users",
@@ -31,7 +31,7 @@
31
31
  "@nocobase/test": "2.x",
32
32
  "@nocobase/utils": "2.x"
33
33
  },
34
- "gitHead": "397d45c744f6eb48b3a0cd785c87cbf1257c3513",
34
+ "gitHead": "d1c585108ff6e51c17b0b52bacb1a2d621d9c119",
35
35
  "keywords": [
36
36
  "Users & permissions"
37
37
  ]