@webiny/cognito 6.5.0 → 6.5.1-beta.0
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/admin/Extension.js +9 -0
- package/admin/Extension.js.map +1 -1
- package/admin/features/users/checkEmail/CheckEmailGateway.d.ts +11 -0
- package/admin/features/users/checkEmail/CheckEmailGateway.js +44 -0
- package/admin/features/users/checkEmail/CheckEmailGateway.js.map +1 -0
- package/admin/features/users/checkEmail/CheckEmailUseCase.d.ts +10 -0
- package/admin/features/users/checkEmail/CheckEmailUseCase.js +18 -0
- package/admin/features/users/checkEmail/CheckEmailUseCase.js.map +1 -0
- package/admin/features/users/checkEmail/abstractions/CheckEmailGateway.d.ts +14 -0
- package/admin/features/users/checkEmail/abstractions/CheckEmailGateway.js +5 -0
- package/admin/features/users/checkEmail/abstractions/CheckEmailGateway.js.map +1 -0
- package/admin/features/users/checkEmail/abstractions/CheckEmailUseCase.d.ts +9 -0
- package/admin/features/users/checkEmail/abstractions/CheckEmailUseCase.js +5 -0
- package/admin/features/users/checkEmail/abstractions/CheckEmailUseCase.js.map +1 -0
- package/admin/features/users/checkEmail/abstractions/index.d.ts +2 -0
- package/admin/features/users/checkEmail/abstractions/index.js +2 -0
- package/admin/features/users/checkEmail/feature.d.ts +3 -0
- package/admin/features/users/checkEmail/feature.js +19 -0
- package/admin/features/users/checkEmail/feature.js.map +1 -0
- package/admin/features/users/checkEmail/index.d.ts +2 -0
- package/admin/features/users/checkEmail/index.js +2 -0
- package/admin/features/users/createUser/CreateUserGateway.js +2 -1
- package/admin/features/users/createUser/CreateUserGateway.js.map +1 -1
- package/admin/features/users/createUser/CreateUserUseCase.test.d.ts +1 -0
- package/admin/features/users/createUser/CreateUserUseCase.test.js +65 -0
- package/admin/features/users/createUser/CreateUserUseCase.test.js.map +1 -0
- package/admin/features/users/linkUser/LinkUserGateway.d.ts +11 -0
- package/admin/features/users/linkUser/LinkUserGateway.js +50 -0
- package/admin/features/users/linkUser/LinkUserGateway.js.map +1 -0
- package/admin/features/users/linkUser/LinkUserUseCase.d.ts +10 -0
- package/admin/features/users/linkUser/LinkUserUseCase.js +18 -0
- package/admin/features/users/linkUser/LinkUserUseCase.js.map +1 -0
- package/admin/features/users/linkUser/abstractions/LinkUserGateway.d.ts +18 -0
- package/admin/features/users/linkUser/abstractions/LinkUserGateway.js +5 -0
- package/admin/features/users/linkUser/abstractions/LinkUserGateway.js.map +1 -0
- package/admin/features/users/linkUser/abstractions/LinkUserUseCase.d.ts +15 -0
- package/admin/features/users/linkUser/abstractions/LinkUserUseCase.js +5 -0
- package/admin/features/users/linkUser/abstractions/LinkUserUseCase.js.map +1 -0
- package/admin/features/users/linkUser/abstractions/index.d.ts +2 -0
- package/admin/features/users/linkUser/abstractions/index.js +2 -0
- package/admin/features/users/linkUser/feature.d.ts +3 -0
- package/admin/features/users/linkUser/feature.js +19 -0
- package/admin/features/users/linkUser/feature.js.map +1 -0
- package/admin/features/users/linkUser/index.d.ts +2 -0
- package/admin/features/users/linkUser/index.js +2 -0
- package/admin/features/users/shared/AdminUsersError.d.ts +13 -0
- package/admin/features/users/shared/AdminUsersError.js +11 -0
- package/admin/features/users/shared/AdminUsersError.js.map +1 -0
- package/admin/presentation/Cognito/CognitoLoginScreen.js +9 -1
- package/admin/presentation/Cognito/CognitoLoginScreen.js.map +1 -1
- package/admin/presentation/Cognito/CognitoPresenter.d.ts +10 -1
- package/admin/presentation/Cognito/CognitoPresenter.js +50 -4
- package/admin/presentation/Cognito/CognitoPresenter.js.map +1 -1
- package/admin/presentation/Cognito/CognitoPresenter.test.d.ts +1 -0
- package/admin/presentation/Cognito/CognitoPresenter.test.js +180 -0
- package/admin/presentation/Cognito/CognitoPresenter.test.js.map +1 -0
- package/admin/presentation/Cognito/abstractions.d.ts +8 -1
- package/admin/presentation/Cognito/abstractions.js.map +1 -1
- package/admin/presentation/Cognito/components/NoTenantAccess.d.ts +23 -0
- package/admin/presentation/Cognito/components/NoTenantAccess.js +10 -0
- package/admin/presentation/Cognito/components/NoTenantAccess.js.map +1 -0
- package/admin/presentation/Cognito/components/SelectTenant.d.ts +26 -0
- package/admin/presentation/Cognito/components/SelectTenant.js +15 -0
- package/admin/presentation/Cognito/components/SelectTenant.js.map +1 -0
- package/admin/presentation/Cognito/components/index.d.ts +38 -0
- package/admin/presentation/Cognito/components/index.js +4 -0
- package/admin/presentation/Cognito/components/index.js.map +1 -1
- package/admin/presentation/users/UserForm/UserFormPresenter.d.ts +30 -0
- package/admin/presentation/users/UserForm/UserFormPresenter.js +118 -0
- package/admin/presentation/users/UserForm/UserFormPresenter.js.map +1 -0
- package/admin/presentation/users/UserForm/UserFormPresenter.test.d.ts +1 -0
- package/admin/presentation/users/UserForm/UserFormPresenter.test.js +248 -0
- package/admin/presentation/users/UserForm/UserFormPresenter.test.js.map +1 -0
- package/admin/presentation/users/UserForm/abstractions.d.ts +52 -0
- package/admin/presentation/users/UserForm/abstractions.js +5 -0
- package/admin/presentation/users/UserForm/abstractions.js.map +1 -0
- package/admin/presentation/users/UserForm/feature.d.ts +7 -0
- package/admin/presentation/users/UserForm/feature.js +17 -0
- package/admin/presentation/users/UserForm/feature.js.map +1 -0
- package/admin/ui/views/Users/UsersForm.d.ts +3 -1
- package/admin/ui/views/Users/UsersForm.js +43 -20
- package/admin/ui/views/Users/UsersForm.js.map +1 -1
- package/admin/ui/views/Users/components/LinkAccountAlert.d.ts +10 -0
- package/admin/ui/views/Users/components/LinkAccountAlert.js +17 -0
- package/admin/ui/views/Users/components/LinkAccountAlert.js.map +1 -0
- package/admin/ui/views/Users/hooks/useUserForm.d.ts +1 -0
- package/admin/ui/views/Users/hooks/useUserForm.js +31 -18
- package/admin/ui/views/Users/hooks/useUserForm.js.map +1 -1
- package/api/CognitoApiFeature.js +4 -0
- package/api/CognitoApiFeature.js.map +1 -1
- package/api/domain/errors.d.ts +49 -0
- package/api/domain/errors.js +53 -1
- package/api/domain/errors.js.map +1 -1
- package/api/features/CheckEmail/CheckEmailUseCase.d.ts +16 -0
- package/api/features/CheckEmail/CheckEmailUseCase.js +47 -0
- package/api/features/CheckEmail/CheckEmailUseCase.js.map +1 -0
- package/api/features/CheckEmail/abstractions.d.ts +29 -0
- package/api/features/CheckEmail/abstractions.js +5 -0
- package/api/features/CheckEmail/abstractions.js.map +1 -0
- package/api/features/CheckEmail/feature.d.ts +4 -0
- package/api/features/CheckEmail/feature.js +11 -0
- package/api/features/CheckEmail/feature.js.map +1 -0
- package/api/features/CheckEmail/index.d.ts +2 -0
- package/api/features/CheckEmail/index.js +2 -0
- package/api/features/CognitoService/CognitoService.d.ts +1 -1
- package/api/features/CognitoService/CognitoService.js +11 -5
- package/api/features/CognitoService/CognitoService.js.map +1 -1
- package/api/features/CognitoService/abstractions.d.ts +8 -2
- package/api/features/CognitoService/abstractions.js.map +1 -1
- package/api/features/CreateUser/CreateUserUseCase.d.ts +1 -2
- package/api/features/CreateUser/CreateUserUseCase.js +3 -3
- package/api/features/CreateUser/CreateUserUseCase.js.map +1 -1
- package/api/features/CreateUser/abstractions.d.ts +3 -1
- package/api/features/CreateUser/abstractions.js.map +1 -1
- package/api/features/DeleteUser/DeleteUserUseCase.d.ts +3 -1
- package/api/features/DeleteUser/DeleteUserUseCase.js +11 -2
- package/api/features/DeleteUser/DeleteUserUseCase.js.map +1 -1
- package/api/features/DeleteUser/abstractions.d.ts +2 -0
- package/api/features/DeleteUser/abstractions.js.map +1 -1
- package/api/features/LinkUser/LinkUserUseCase.d.ts +22 -0
- package/api/features/LinkUser/LinkUserUseCase.js +83 -0
- package/api/features/LinkUser/LinkUserUseCase.js.map +1 -0
- package/api/features/LinkUser/abstractions.d.ts +36 -0
- package/api/features/LinkUser/abstractions.js +5 -0
- package/api/features/LinkUser/abstractions.js.map +1 -0
- package/api/features/LinkUser/feature.d.ts +4 -0
- package/api/features/LinkUser/feature.js +11 -0
- package/api/features/LinkUser/feature.js.map +1 -0
- package/api/features/LinkUser/index.d.ts +2 -0
- package/api/features/LinkUser/index.js +2 -0
- package/api/features/UpdateUser/UpdateUserUseCase.d.ts +14 -1
- package/api/features/UpdateUser/UpdateUserUseCase.js +93 -4
- package/api/features/UpdateUser/UpdateUserUseCase.js.map +1 -1
- package/api/features/UpdateUser/abstractions.d.ts +7 -1
- package/api/features/UpdateUser/abstractions.js.map +1 -1
- package/api/features/UserInstaller/UserInstaller.d.ts +3 -1
- package/api/features/UserInstaller/UserInstaller.js +18 -3
- package/api/features/UserInstaller/UserInstaller.js.map +1 -1
- package/api/graphql/user.gql.js +68 -0
- package/api/graphql/user.gql.js.map +1 -1
- package/package.json +17 -17
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The New User form: creates a user, or links an account from another tenant.
|
|
3
|
+
* Needs the CreateUser, LinkUser and CheckEmail features.
|
|
4
|
+
*/
|
|
5
|
+
export declare const UserFormFeature: import("@webiny/feature/admin").FeatureDefinition<{
|
|
6
|
+
presenter: import("./abstractions.js").IUserFormPresenter;
|
|
7
|
+
}, []>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/admin";
|
|
2
|
+
import { UserFormPresenter } from "./abstractions.js";
|
|
3
|
+
import { UserFormPresenter as external_UserFormPresenter_js_UserFormPresenter } from "./UserFormPresenter.js";
|
|
4
|
+
const UserFormFeature = createFeature({
|
|
5
|
+
name: "Cognito/Users/UserForm",
|
|
6
|
+
register (container) {
|
|
7
|
+
container.register(external_UserFormPresenter_js_UserFormPresenter);
|
|
8
|
+
},
|
|
9
|
+
resolve (container) {
|
|
10
|
+
return {
|
|
11
|
+
presenter: container.resolve(UserFormPresenter)
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
export { UserFormFeature };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin/presentation/users/UserForm/feature.js","sources":["../../../../../src/admin/presentation/users/UserForm/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/admin\";\nimport { UserFormPresenter as PresenterAbstraction } from \"./abstractions.js\";\nimport { UserFormPresenter } from \"./UserFormPresenter.js\";\n\n/**\n * The New User form: creates a user, or links an account from another tenant.\n * Needs the CreateUser, LinkUser and CheckEmail features.\n */\nexport const UserFormFeature = createFeature({\n name: \"Cognito/Users/UserForm\",\n register(container) {\n container.register(UserFormPresenter);\n },\n resolve(container) {\n return {\n presenter: container.resolve(PresenterAbstraction)\n };\n }\n});\n"],"names":["UserFormFeature","createFeature","container","UserFormPresenter","PresenterAbstraction"],"mappings":";;;AAQO,MAAMA,kBAAkBC,cAAc;IACzC,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;IACvB;IACA,SAAQD,SAAS;QACb,OAAO;YACH,WAAWA,UAAU,OAAO,CAACE;QACjC;IACJ;AACJ"}
|
|
@@ -2,4 +2,6 @@ import React from "react";
|
|
|
2
2
|
export interface UserFormProps {
|
|
3
3
|
teams: boolean;
|
|
4
4
|
}
|
|
5
|
-
export declare const UserForm: ({ teams }: UserFormProps) => React.JSX.Element
|
|
5
|
+
export declare const UserForm: (({ teams }: UserFormProps) => React.JSX.Element) & React.NamedExoticComponent<UserFormProps> & {
|
|
6
|
+
readonly type: ({ teams }: UserFormProps) => React.JSX.Element;
|
|
7
|
+
};
|
|
@@ -2,7 +2,7 @@ import react, { useMemo } from "react";
|
|
|
2
2
|
import { i18n } from "@webiny/app/i18n/index.js";
|
|
3
3
|
import { Form } from "@webiny/form";
|
|
4
4
|
import { validation as validation_validation } from "@webiny/validation";
|
|
5
|
-
import { EmptyView, RolesMultiAutocomplete, SimpleForm, SimpleFormContent, SimpleFormFooter, SimpleFormHeader, TeamsMultiAutocomplete, useAuthentication, useRouter } from "@webiny/app-admin";
|
|
5
|
+
import { EmptyView, RolesMultiAutocomplete, SimpleForm, SimpleFormContent, SimpleFormFooter, SimpleFormHeader, TeamsMultiAutocomplete, createReactiveComponent, useAuthentication, useRouter } from "@webiny/app-admin";
|
|
6
6
|
import { ReactComponent } from "@webiny/icons/add.svg";
|
|
7
7
|
import { ReactComponent as gpp_maybe_svg_ReactComponent } from "@webiny/icons/gpp_maybe.svg";
|
|
8
8
|
import { ReactComponent as admin_panel_settings_svg_ReactComponent } from "@webiny/icons/admin_panel_settings.svg";
|
|
@@ -10,11 +10,12 @@ import { ReactComponent as settings_svg_ReactComponent } from "@webiny/icons/set
|
|
|
10
10
|
import { Accordion, Alert, Button, Grid, Input, Link, OverlayLoader } from "@webiny/admin-ui";
|
|
11
11
|
import { config } from "@webiny/app/config.js";
|
|
12
12
|
import { AvatarImage } from "../../components/AvatarImage/index.js";
|
|
13
|
+
import { LinkAccountAlert } from "./components/LinkAccountAlert.js";
|
|
13
14
|
import { useUserForm } from "./hooks/useUserForm.js";
|
|
14
15
|
import { usePasswordValidator } from "../../../presentation/shared/usePasswordValidator.js";
|
|
15
16
|
import { Routes } from "../../../routes.js";
|
|
16
17
|
const t = i18n.ns("app-security-admin-users/account-form");
|
|
17
|
-
const UserForm = ({ teams })=>{
|
|
18
|
+
const UserForm = createReactiveComponent(({ teams })=>{
|
|
18
19
|
const { identity } = useAuthentication();
|
|
19
20
|
const userForm = useUserForm();
|
|
20
21
|
const passwordValidator = usePasswordValidator();
|
|
@@ -28,6 +29,25 @@ const UserForm = ({ teams })=>{
|
|
|
28
29
|
], [
|
|
29
30
|
teams
|
|
30
31
|
]);
|
|
32
|
+
const { newUserForm } = userForm;
|
|
33
|
+
const isLinking = isNewUser && "link" === newUserForm.vm.mode;
|
|
34
|
+
const emailValidators = useMemo(()=>{
|
|
35
|
+
const validators = [
|
|
36
|
+
validation_validation.create("required,email")
|
|
37
|
+
];
|
|
38
|
+
if (!isNewUser) return validators;
|
|
39
|
+
const emailIsAvailable = async (value)=>{
|
|
40
|
+
await newUserForm.checkEmail(value);
|
|
41
|
+
if (newUserForm.vm.emailError) throw new Error(newUserForm.vm.emailError);
|
|
42
|
+
};
|
|
43
|
+
return [
|
|
44
|
+
...validators,
|
|
45
|
+
emailIsAvailable
|
|
46
|
+
];
|
|
47
|
+
}, [
|
|
48
|
+
isNewUser,
|
|
49
|
+
newUserForm
|
|
50
|
+
]);
|
|
31
51
|
const accountLink = getLink(Routes.Users.Account);
|
|
32
52
|
if (userForm.showEmptyView) return /*#__PURE__*/ react.createElement(EmptyView, {
|
|
33
53
|
icon: /*#__PURE__*/ react.createElement(settings_svg_ReactComponent, null),
|
|
@@ -46,7 +66,7 @@ const UserForm = ({ teams })=>{
|
|
|
46
66
|
onSubmit: userForm.onSubmit
|
|
47
67
|
}, ({ data, form, Bind })=>/*#__PURE__*/ react.createElement(SimpleForm, {
|
|
48
68
|
size: "lg"
|
|
49
|
-
}, userForm.loading && /*#__PURE__*/ react.createElement(OverlayLoader, null), /*#__PURE__*/ react.createElement("div", {
|
|
69
|
+
}, userForm.loading && /*#__PURE__*/ react.createElement(OverlayLoader, null), isLinking ? null : /*#__PURE__*/ react.createElement("div", {
|
|
50
70
|
className: "mb-xl"
|
|
51
71
|
}, /*#__PURE__*/ react.createElement(Bind, {
|
|
52
72
|
name: "avatar"
|
|
@@ -62,7 +82,10 @@ const UserForm = ({ teams })=>{
|
|
|
62
82
|
}, /*#__PURE__*/ react.createElement(Alert, {
|
|
63
83
|
type: "info",
|
|
64
84
|
title: "External User"
|
|
65
|
-
}, "This user is an external user and cannot be edited."))),
|
|
85
|
+
}, "This user is an external user and cannot be edited."))), /*#__PURE__*/ react.createElement(LinkAccountAlert, {
|
|
86
|
+
presenter: newUserForm,
|
|
87
|
+
isNewUser: isNewUser
|
|
88
|
+
}), isSelf && /*#__PURE__*/ react.createElement(Grid, {
|
|
66
89
|
className: "mb-lg"
|
|
67
90
|
}, /*#__PURE__*/ react.createElement(Grid.Column, {
|
|
68
91
|
span: 12
|
|
@@ -80,6 +103,18 @@ const UserForm = ({ teams })=>{
|
|
|
80
103
|
defaultOpen: true
|
|
81
104
|
}, /*#__PURE__*/ react.createElement(Grid, null, /*#__PURE__*/ react.createElement(Grid.Column, {
|
|
82
105
|
span: 12
|
|
106
|
+
}, /*#__PURE__*/ react.createElement(Bind, {
|
|
107
|
+
name: "email",
|
|
108
|
+
validators: emailValidators
|
|
109
|
+
}, /*#__PURE__*/ react.createElement(Input, {
|
|
110
|
+
value: data.email,
|
|
111
|
+
label: t`Email`,
|
|
112
|
+
disabled: emailIsDisabled || isDisabled,
|
|
113
|
+
"data-testid": "account.email",
|
|
114
|
+
autoComplete: "new-password",
|
|
115
|
+
description: "Email is your unique identifier used to login!"
|
|
116
|
+
}))), isLinking ? null : /*#__PURE__*/ react.createElement(Grid.Column, {
|
|
117
|
+
span: 12
|
|
83
118
|
}, /*#__PURE__*/ react.createElement(Bind, {
|
|
84
119
|
name: "firstName",
|
|
85
120
|
validators: validation_validation.create("required")
|
|
@@ -87,7 +122,7 @@ const UserForm = ({ teams })=>{
|
|
|
87
122
|
label: t`First Name`,
|
|
88
123
|
disabled: isDisabled,
|
|
89
124
|
"data-testid": "account.firstname"
|
|
90
|
-
}))), /*#__PURE__*/ react.createElement(Grid.Column, {
|
|
125
|
+
}))), isLinking ? null : /*#__PURE__*/ react.createElement(Grid.Column, {
|
|
91
126
|
span: 12
|
|
92
127
|
}, /*#__PURE__*/ react.createElement(Bind, {
|
|
93
128
|
name: "lastName",
|
|
@@ -96,19 +131,7 @@ const UserForm = ({ teams })=>{
|
|
|
96
131
|
label: t`Last Name`,
|
|
97
132
|
disabled: isDisabled,
|
|
98
133
|
"data-testid": "account.lastname"
|
|
99
|
-
}))), /*#__PURE__*/ react.createElement(Grid.Column, {
|
|
100
|
-
span: 12
|
|
101
|
-
}, /*#__PURE__*/ react.createElement(Bind, {
|
|
102
|
-
name: "email",
|
|
103
|
-
validators: validation_validation.create("required,email")
|
|
104
|
-
}, /*#__PURE__*/ react.createElement(Input, {
|
|
105
|
-
value: data.email,
|
|
106
|
-
label: t`Email`,
|
|
107
|
-
disabled: emailIsDisabled || isDisabled,
|
|
108
|
-
"data-testid": "account.email",
|
|
109
|
-
autoComplete: "new-password",
|
|
110
|
-
description: "Email is your unique identifier used to login!"
|
|
111
|
-
}))), /*#__PURE__*/ react.createElement(Grid.Column, {
|
|
134
|
+
}))), isLinking ? null : /*#__PURE__*/ react.createElement(Grid.Column, {
|
|
112
135
|
span: 12
|
|
113
136
|
}, /*#__PURE__*/ react.createElement(Bind, {
|
|
114
137
|
name: "password",
|
|
@@ -159,11 +182,11 @@ const UserForm = ({ teams })=>{
|
|
|
159
182
|
onClick: userForm.cancelEditing
|
|
160
183
|
}), /*#__PURE__*/ react.createElement(Button, {
|
|
161
184
|
variant: "primary",
|
|
162
|
-
text: isNewUser ? t`Create user` : t`Update user`,
|
|
185
|
+
text: isLinking ? t`Link existing user` : isNewUser ? t`Create user` : t`Update user`,
|
|
163
186
|
disabled: isDisabled,
|
|
164
187
|
onClick: form.submit
|
|
165
188
|
}))));
|
|
166
|
-
};
|
|
189
|
+
});
|
|
167
190
|
export { UserForm };
|
|
168
191
|
|
|
169
192
|
//# sourceMappingURL=UsersForm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin/ui/views/Users/UsersForm.js","sources":["../../../../../src/admin/ui/views/Users/UsersForm.tsx"],"sourcesContent":["import React, { useMemo } from \"react\";\nimport { i18n } from \"@webiny/app/i18n/index.js\";\nimport { Form } from \"@webiny/form\";\nimport { validation } from \"@webiny/validation\";\nimport {\n SimpleForm,\n SimpleFormHeader,\n SimpleFormFooter,\n SimpleFormContent,\n EmptyView,\n RolesMultiAutocomplete,\n TeamsMultiAutocomplete,\n useAuthentication,\n useRouter\n} from \"@webiny/app-admin\";\nimport { ReactComponent as AddIcon } from \"@webiny/icons/add.svg\";\nimport { ReactComponent as SecurityIcon } from \"@webiny/icons/gpp_maybe.svg\";\nimport { ReactComponent as SecurityTeamsIcon } from \"@webiny/icons/admin_panel_settings.svg\";\nimport { ReactComponent as SettingsIcon } from \"@webiny/icons/settings.svg\";\nimport { Accordion, Alert, OverlayLoader, Button, Input, Grid, Link } from \"@webiny/admin-ui\";\nimport { config as appConfig } from \"@webiny/app/config.js\";\nimport { AvatarImage } from \"../../components/AvatarImage/index.js\";\nimport { useUserForm } from \"~/admin/ui/views/Users/hooks/useUserForm.js\";\nimport { usePasswordValidator } from \"~/admin/presentation/shared/usePasswordValidator.js\";\nimport { Routes } from \"~/admin/routes.js\";\n\nconst t = i18n.ns(\"app-security-admin-users/account-form\");\n\nexport interface UserFormProps {\n teams: boolean;\n}\n\nexport const UserForm = ({ teams }: UserFormProps) => {\n const { identity } = useAuthentication();\n const userForm = useUserForm();\n const passwordValidator = usePasswordValidator();\n const { getLink } = useRouter();\n\n const isExternal = userForm.user?.external === true;\n const formTitle = userForm.isNewUser ? \"New User\" : userForm.fullName;\n const isNewUser = userForm.isNewUser;\n\n const emailIsDisabled = appConfig.getKey(\n \"ADMIN_USER_CAN_CHANGE_EMAIL\",\n process.env.REACT_APP_ADMIN_USER_CAN_CHANGE_EMAIL === \"false\"\n );\n\n const groupValidators = useMemo(() => {\n return teams ? [] : [validation.create(\"required\")];\n }, [teams]);\n\n const accountLink = getLink(Routes.Users.Account);\n\n // Render \"No content\" selected view.\n if (userForm.showEmptyView) {\n return (\n <EmptyView\n icon={<SettingsIcon />}\n title={t`Click on the left side list to display user details or create a...`}\n action={\n <Button\n icon={<AddIcon />}\n text={t`New User`}\n data-testid=\"new-record-button\"\n onClick={userForm.createUser}\n />\n }\n />\n );\n }\n\n const isSelf = userForm.user?.id === identity.id;\n const isDisabled = isExternal || isSelf;\n\n return (\n <Form data={userForm.user} onSubmit={userForm.onSubmit}>\n {({ data, form, Bind }) => (\n <SimpleForm size={\"lg\"}>\n {userForm.loading && <OverlayLoader />}\n <div className={\"mb-xl\"}>\n <Bind name=\"avatar\">\n <AvatarImage round disabled={isDisabled} />\n </Bind>\n </div>\n <SimpleFormHeader title={formTitle} />\n <SimpleFormContent>\n {isExternal && (\n <Grid className={\"mb-lg\"}>\n <Grid.Column span={12}>\n <Alert type={\"info\"} title={\"External User\"}>\n This user is an external user and cannot be edited.\n </Alert>\n </Grid.Column>\n </Grid>\n )}\n {isSelf && (\n <Grid className={\"mb-lg\"}>\n <Grid.Column span={12}>\n <Alert type={\"info\"} title={\"Own Profile\"}>\n You cannot edit your own profile using this form. Please use\n the <Link to={accountLink}>account settings</Link> instead.\n </Alert>\n </Grid.Column>\n </Grid>\n )}\n <Accordion variant={\"underline\"}>\n <Accordion.Item\n title={\"Bio\"}\n description={\"Account information\"}\n icon={<SettingsIcon />}\n defaultOpen={true}\n >\n <Grid>\n <Grid.Column span={12}>\n <Bind\n name=\"firstName\"\n validators={validation.create(\"required\")}\n >\n <Input\n label={t`First Name`}\n disabled={isDisabled}\n data-testid=\"account.firstname\"\n />\n </Bind>\n </Grid.Column>\n <Grid.Column span={12}>\n <Bind\n name=\"lastName\"\n validators={validation.create(\"required\")}\n >\n <Input\n label={t`Last Name`}\n disabled={isDisabled}\n data-testid=\"account.lastname\"\n />\n </Bind>\n </Grid.Column>\n <Grid.Column span={12}>\n <Bind\n name=\"email\"\n validators={validation.create(\"required,email\")}\n >\n <Input\n value={data.email}\n label={t`Email`}\n disabled={emailIsDisabled || isDisabled}\n data-testid=\"account.email\"\n autoComplete=\"new-password\"\n description={\n \"Email is your unique identifier used to login!\"\n }\n />\n </Bind>\n </Grid.Column>\n <Grid.Column span={12}>\n <Bind name=\"password\" validators={passwordValidator}>\n <Input\n autoComplete=\"new-password\"\n disabled={isDisabled}\n description={\n data.id && \"Type a new password to reset it.\"\n }\n type=\"password\"\n label={\"Password\"}\n data-testid=\"account.password\"\n />\n </Bind>\n </Grid.Column>\n </Grid>\n </Accordion.Item>\n <Accordion.Item\n title={\"Roles\"}\n description={\"Assign to security roles\"}\n icon={<SecurityIcon />}\n >\n <Grid>\n <Grid.Column span={12}>\n <Bind name={\"roles\"} validators={groupValidators}>\n {({ value, onChange, validation }) => (\n <RolesMultiAutocomplete\n values={value}\n onChange={onChange}\n validation={validation}\n label={\"Roles\"}\n data-testid=\"roles-autocomplete\"\n disabled={isDisabled}\n />\n )}\n </Bind>\n </Grid.Column>\n </Grid>\n </Accordion.Item>\n {teams ? (\n <Accordion.Item\n title={\"Teams\"}\n description={\"Assign to teams\"}\n icon={<SecurityTeamsIcon />}\n >\n <Grid>\n <Grid.Column span={12}>\n <Bind name={\"teams\"}>\n {({ value, onChange, validation }) => (\n <TeamsMultiAutocomplete\n values={value}\n onChange={onChange}\n validation={validation}\n label={\"Teams\"}\n data-testid=\"teams-autocomplete\"\n disabled={isDisabled}\n />\n )}\n </Bind>\n </Grid.Column>\n </Grid>\n </Accordion.Item>\n ) : null}\n </Accordion>\n </SimpleFormContent>\n <SimpleFormFooter data-testid={\"form-footer\"}>\n <Button\n variant={\"secondary\"}\n text={t`Cancel`}\n onClick={userForm.cancelEditing}\n />\n <Button\n variant={\"primary\"}\n text={isNewUser ? t`Create user` : t`Update user`}\n disabled={isDisabled}\n onClick={form.submit}\n />\n </SimpleFormFooter>\n </SimpleForm>\n )}\n </Form>\n );\n};\n"],"names":["t","i18n","UserForm","teams","identity","useAuthentication","userForm","useUserForm","passwordValidator","usePasswordValidator","getLink","useRouter","isExternal","formTitle","isNewUser","emailIsDisabled","appConfig","process","groupValidators","useMemo","validation","accountLink","Routes","EmptyView","SettingsIcon","Button","AddIcon","isSelf","isDisabled","Form","data","form","Bind","SimpleForm","OverlayLoader","AvatarImage","SimpleFormHeader","SimpleFormContent","Grid","Alert","Link","Accordion","Input","SecurityIcon","value","onChange","RolesMultiAutocomplete","SecurityTeamsIcon","TeamsMultiAutocomplete","SimpleFormFooter"],"mappings":";;;;;;;;;;;;;;;AA0BA,MAAMA,IAAIC,KAAK,EAAE,CAAC;AAMX,MAAMC,WAAW,CAAC,EAAEC,KAAK,EAAiB;IAC7C,MAAM,EAAEC,QAAQ,EAAE,GAAGC;IACrB,MAAMC,WAAWC;IACjB,MAAMC,oBAAoBC;IAC1B,MAAM,EA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ACV,aACIE,KAAK,EAAE,IAAI;YAEf,MAAK;YACL,OAAO;YACP,eAAY;8BAMhC,oBAACW,UAAU,IAAI;YACX,OAAO;YACP,aAAa;YACb,oBAAM,oBAACE,8BAAYA;yBAEnB,oBAACL,MAAIA,MAAAA,WAAAA,GACD,oBAACA,KAAK,MAAM;YAAC,MAAM;yBACf,oBAACN,MAAAA;YAAK,MAAM;YAAS,YAAYd;WAC5B,CAAC,EAAE0B,KAAK,EAAEC,QAAQ,EAAEzB,UAAU,EAAE,iBAC7B,oBAAC0B,wBAAsBA;gBACnB,QAAQF;gBACR,UAAUC;gBACV,YAAYzB;gBACZ,OAAO;gBACP,eAAY;gBACZ,UAAUQ;oBAOjCzB,QAAQ,WAARA,GACG,oBAACsC,UAAU,IAAI;YACX,OAAO;YACP,aAAa;YACb,oBAAM,oBAACM,yCAAiBA;yBAExB,oBAACT,MAAIA,MAAAA,WAAAA,GACD,oBAACA,KAAK,MAAM;YAAC,MAAM;yBACf,oBAACN,MAAAA;YAAK,MAAM;WACP,CAAC,EAAEY,KAAK,EAAEC,QAAQ,EAAEzB,UAAU,EAAE,iBAC7B,oBAAC4B,wBAAsBA;gBACnB,QAAQJ;gBACR,UAAUC;gBACV,YAAYzB;gBACZ,OAAO;gBACP,eAAY;gBACZ,UAAUQ;qBAOlC,sBAGZ,oBAACqB,kBAAgBA;YAAC,eAAa;yBAC3B,oBAACxB,QAAMA;YACH,SAAS;YACT,MAAMzB,CAAC,CAAC,MAAM,CAAC;YACf,SAASM,SAAS,aAAa;0BAEnC,oBAACmB,QAAMA;YACH,SAAS;YACT,MAAMX,YAAYd,CAAC,CAAC,WAAW,CAAC,GAAGA,CAAC,CAAC,WAAW,CAAC;YACjD,UAAU4B;YACV,SAASG,KAAK,MAAM;;AAOhD"}
|
|
1
|
+
{"version":3,"file":"admin/ui/views/Users/UsersForm.js","sources":["../../../../../src/admin/ui/views/Users/UsersForm.tsx"],"sourcesContent":["import React, { useMemo } from \"react\";\nimport { i18n } from \"@webiny/app/i18n/index.js\";\nimport { Form } from \"@webiny/form\";\nimport { validation } from \"@webiny/validation\";\nimport {\n SimpleForm,\n SimpleFormHeader,\n SimpleFormFooter,\n SimpleFormContent,\n EmptyView,\n RolesMultiAutocomplete,\n TeamsMultiAutocomplete,\n useAuthentication,\n useRouter,\n createReactiveComponent\n} from \"@webiny/app-admin\";\nimport { ReactComponent as AddIcon } from \"@webiny/icons/add.svg\";\nimport { ReactComponent as SecurityIcon } from \"@webiny/icons/gpp_maybe.svg\";\nimport { ReactComponent as SecurityTeamsIcon } from \"@webiny/icons/admin_panel_settings.svg\";\nimport { ReactComponent as SettingsIcon } from \"@webiny/icons/settings.svg\";\nimport { Accordion, Alert, OverlayLoader, Button, Input, Grid, Link } from \"@webiny/admin-ui\";\nimport { config as appConfig } from \"@webiny/app/config.js\";\nimport { AvatarImage } from \"../../components/AvatarImage/index.js\";\nimport { LinkAccountAlert } from \"./components/LinkAccountAlert.js\";\nimport { useUserForm } from \"~/admin/ui/views/Users/hooks/useUserForm.js\";\nimport { usePasswordValidator } from \"~/admin/presentation/shared/usePasswordValidator.js\";\nimport { Routes } from \"~/admin/routes.js\";\n\nconst t = i18n.ns(\"app-security-admin-users/account-form\");\n\nexport interface UserFormProps {\n teams: boolean;\n}\n\nexport const UserForm = createReactiveComponent(({ teams }: UserFormProps) => {\n const { identity } = useAuthentication();\n const userForm = useUserForm();\n const passwordValidator = usePasswordValidator();\n const { getLink } = useRouter();\n\n const isExternal = userForm.user?.external === true;\n const formTitle = userForm.isNewUser ? \"New User\" : userForm.fullName;\n const isNewUser = userForm.isNewUser;\n\n const emailIsDisabled = appConfig.getKey(\n \"ADMIN_USER_CAN_CHANGE_EMAIL\",\n process.env.REACT_APP_ADMIN_USER_CAN_CHANGE_EMAIL === \"false\"\n );\n\n const groupValidators = useMemo(() => {\n return teams ? [] : [validation.create(\"required\")];\n }, [teams]);\n\n const { newUserForm } = userForm;\n const isLinking = isNewUser && newUserForm.vm.mode === \"link\";\n\n const emailValidators = useMemo(() => {\n const validators = [validation.create(\"required,email\")];\n if (!isNewUser) {\n return validators;\n }\n\n // Leaving the field checks whether the email is new, in this tenant, or in another one.\n const emailIsAvailable = async (value: string) => {\n await newUserForm.checkEmail(value);\n if (newUserForm.vm.emailError) {\n throw new Error(newUserForm.vm.emailError);\n }\n };\n\n return [...validators, emailIsAvailable];\n }, [isNewUser, newUserForm]);\n\n const accountLink = getLink(Routes.Users.Account);\n\n // Render \"No content\" selected view.\n if (userForm.showEmptyView) {\n return (\n <EmptyView\n icon={<SettingsIcon />}\n title={t`Click on the left side list to display user details or create a...`}\n action={\n <Button\n icon={<AddIcon />}\n text={t`New User`}\n data-testid=\"new-record-button\"\n onClick={userForm.createUser}\n />\n }\n />\n );\n }\n\n const isSelf = userForm.user?.id === identity.id;\n const isDisabled = isExternal || isSelf;\n\n return (\n <Form data={userForm.user} onSubmit={userForm.onSubmit}>\n {({ data, form, Bind }) => (\n <SimpleForm size={\"lg\"}>\n {userForm.loading && <OverlayLoader />}\n {isLinking ? null : (\n <div className={\"mb-xl\"}>\n <Bind name=\"avatar\">\n <AvatarImage round disabled={isDisabled} />\n </Bind>\n </div>\n )}\n <SimpleFormHeader title={formTitle} />\n <SimpleFormContent>\n {isExternal && (\n <Grid className={\"mb-lg\"}>\n <Grid.Column span={12}>\n <Alert type={\"info\"} title={\"External User\"}>\n This user is an external user and cannot be edited.\n </Alert>\n </Grid.Column>\n </Grid>\n )}\n <LinkAccountAlert presenter={newUserForm} isNewUser={isNewUser} />\n {isSelf && (\n <Grid className={\"mb-lg\"}>\n <Grid.Column span={12}>\n <Alert type={\"info\"} title={\"Own Profile\"}>\n You cannot edit your own profile using this form. Please use\n the <Link to={accountLink}>account settings</Link> instead.\n </Alert>\n </Grid.Column>\n </Grid>\n )}\n <Accordion variant={\"underline\"}>\n <Accordion.Item\n title={\"Bio\"}\n description={\"Account information\"}\n icon={<SettingsIcon />}\n defaultOpen={true}\n >\n <Grid>\n <Grid.Column span={12}>\n <Bind name=\"email\" validators={emailValidators}>\n <Input\n value={data.email}\n label={t`Email`}\n disabled={emailIsDisabled || isDisabled}\n data-testid=\"account.email\"\n autoComplete=\"new-password\"\n description={\n \"Email is your unique identifier used to login!\"\n }\n />\n </Bind>\n </Grid.Column>\n {isLinking ? null : (\n <Grid.Column span={12}>\n <Bind\n name=\"firstName\"\n validators={validation.create(\"required\")}\n >\n <Input\n label={t`First Name`}\n disabled={isDisabled}\n data-testid=\"account.firstname\"\n />\n </Bind>\n </Grid.Column>\n )}\n {isLinking ? null : (\n <Grid.Column span={12}>\n <Bind\n name=\"lastName\"\n validators={validation.create(\"required\")}\n >\n <Input\n label={t`Last Name`}\n disabled={isDisabled}\n data-testid=\"account.lastname\"\n />\n </Bind>\n </Grid.Column>\n )}\n {isLinking ? null : (\n <Grid.Column span={12}>\n <Bind name=\"password\" validators={passwordValidator}>\n <Input\n autoComplete=\"new-password\"\n disabled={isDisabled}\n description={\n data.id &&\n \"Type a new password to reset it.\"\n }\n type=\"password\"\n label={\"Password\"}\n data-testid=\"account.password\"\n />\n </Bind>\n </Grid.Column>\n )}\n </Grid>\n </Accordion.Item>\n <Accordion.Item\n title={\"Roles\"}\n description={\"Assign to security roles\"}\n icon={<SecurityIcon />}\n >\n <Grid>\n <Grid.Column span={12}>\n <Bind name={\"roles\"} validators={groupValidators}>\n {({ value, onChange, validation }) => (\n <RolesMultiAutocomplete\n values={value}\n onChange={onChange}\n validation={validation}\n label={\"Roles\"}\n data-testid=\"roles-autocomplete\"\n disabled={isDisabled}\n />\n )}\n </Bind>\n </Grid.Column>\n </Grid>\n </Accordion.Item>\n {teams ? (\n <Accordion.Item\n title={\"Teams\"}\n description={\"Assign to teams\"}\n icon={<SecurityTeamsIcon />}\n >\n <Grid>\n <Grid.Column span={12}>\n <Bind name={\"teams\"}>\n {({ value, onChange, validation }) => (\n <TeamsMultiAutocomplete\n values={value}\n onChange={onChange}\n validation={validation}\n label={\"Teams\"}\n data-testid=\"teams-autocomplete\"\n disabled={isDisabled}\n />\n )}\n </Bind>\n </Grid.Column>\n </Grid>\n </Accordion.Item>\n ) : null}\n </Accordion>\n </SimpleFormContent>\n <SimpleFormFooter data-testid={\"form-footer\"}>\n <Button\n variant={\"secondary\"}\n text={t`Cancel`}\n onClick={userForm.cancelEditing}\n />\n <Button\n variant={\"primary\"}\n text={\n isLinking\n ? t`Link existing user`\n : isNewUser\n ? t`Create user`\n : t`Update user`\n }\n disabled={isDisabled}\n onClick={form.submit}\n />\n </SimpleFormFooter>\n </SimpleForm>\n )}\n </Form>\n );\n});\n"],"names":["t","i18n","UserForm","createReactiveComponent","teams","identity","useAuthentication","userForm","useUserForm","passwordValidator","usePasswordValidator","getLink","useRouter","isExternal","formTitle","isNewUser","emailIsDisabled","appConfig","process","groupValidators","useMemo","validation","newUserForm","isLinking","emailValidators","validators","emailIsAvailable","value","Error","accountLink","Routes","EmptyView","SettingsIcon","Button","AddIcon","isSelf","isDisabled","Form","data","form","Bind","SimpleForm","OverlayLoader","AvatarImage","SimpleFormHeader","SimpleFormContent","Grid","Alert","LinkAccountAlert","Link","Accordion","Input","SecurityIcon","onChange","RolesMultiAutocomplete","SecurityTeamsIcon","TeamsMultiAutocomplete","SimpleFormFooter"],"mappings":";;;;;;;;;;;;;;;;AA4BA,MAAMA,IAAIC,KAAK,EAAE,CAAC;AAMX,MAAMC,WAAWC,wBAAwB,CAAC,EAAEC,KAAK,EAAiB;IACrE,MAAM,EAAEC,QAAQ,EAAE,GAAGC;IACrB,MAAMC,WAAWC;IACjB,MAAMC,oBAAoBC;IAC1B,MAAM,EAAEC,OAAO,EAAE,GAAGC;IAEpB,MAAMC,aAAaN,SAAS,IAAI,EAAE,aAAa;IAC/C,MAAMO,YAAYP,SAAS,SAAS,GAAG,aAAaA,SAAS,QAAQ;IACrE,MAAMQ,YAAYR,SAAS,SAAS;IAEpC,MAAMS,kBAAkBC,OAAAA,MAAgB,CACpC,+BACAC,AAAsD,YAAtDA,QAAQ,GAA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AAMjC,CAAC,CAAC,MAAM,CAAC;YACf,SAASO,SAAS,aAAa;0BAEnC,oBAAC0B,QAAMA;YACH,SAAS;YACT,MACIV,YACMvB,CAAC,CAAC,kBAAkB,CAAC,GACrBe,YACEf,CAAC,CAAC,WAAW,CAAC,GACdA,CAAC,CAAC,WAAW,CAAC;YAE1B,UAAUoC;YACV,SAASG,KAAK,MAAM;;AAOhD"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { UserFormPresenter } from "../../../../../admin/presentation/users/UserForm/abstractions.js";
|
|
3
|
+
interface LinkAccountAlertProps {
|
|
4
|
+
presenter: UserFormPresenter.Interface;
|
|
5
|
+
isNewUser: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare const LinkAccountAlert: (({ presenter, isNewUser }: LinkAccountAlertProps) => React.JSX.Element | null) & React.NamedExoticComponent<LinkAccountAlertProps> & {
|
|
8
|
+
readonly type: ({ presenter, isNewUser }: LinkAccountAlertProps) => React.JSX.Element | null;
|
|
9
|
+
};
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import react from "react";
|
|
2
|
+
import { createReactiveComponent } from "@webiny/app-admin";
|
|
3
|
+
import { Alert, Grid } from "@webiny/admin-ui";
|
|
4
|
+
const LinkAccountAlert = createReactiveComponent(({ presenter, isNewUser })=>{
|
|
5
|
+
if (!isNewUser || "link" !== presenter.vm.mode) return null;
|
|
6
|
+
return /*#__PURE__*/ react.createElement(Grid, {
|
|
7
|
+
className: "mb-lg"
|
|
8
|
+
}, /*#__PURE__*/ react.createElement(Grid.Column, {
|
|
9
|
+
span: 12
|
|
10
|
+
}, /*#__PURE__*/ react.createElement(Alert, {
|
|
11
|
+
type: "info",
|
|
12
|
+
title: "Account in another tenant"
|
|
13
|
+
}, "This email already has an account in another tenant. Link it to give this person access here. They keep their name and password.")));
|
|
14
|
+
});
|
|
15
|
+
export { LinkAccountAlert };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=LinkAccountAlert.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin/ui/views/Users/components/LinkAccountAlert.js","sources":["../../../../../../src/admin/ui/views/Users/components/LinkAccountAlert.tsx"],"sourcesContent":["import React from \"react\";\nimport { createReactiveComponent } from \"@webiny/app-admin\";\nimport { Alert, Grid } from \"@webiny/admin-ui\";\nimport type { UserFormPresenter } from \"~/admin/presentation/users/UserForm/abstractions.js\";\n\ninterface LinkAccountAlertProps {\n presenter: UserFormPresenter.Interface;\n isNewUser: boolean;\n}\n\nexport const LinkAccountAlert = createReactiveComponent(\n ({ presenter, isNewUser }: LinkAccountAlertProps) => {\n if (!isNewUser || presenter.vm.mode !== \"link\") {\n return null;\n }\n\n return (\n <Grid className={\"mb-lg\"}>\n <Grid.Column span={12}>\n <Alert type={\"info\"} title={\"Account in another tenant\"}>\n This email already has an account in another tenant. Link it to give this\n person access here. They keep their name and password.\n </Alert>\n </Grid.Column>\n </Grid>\n );\n }\n);\n"],"names":["LinkAccountAlert","createReactiveComponent","presenter","isNewUser","Grid","Alert"],"mappings":";;;AAUO,MAAMA,mBAAmBC,wBAC5B,CAAC,EAAEC,SAAS,EAAEC,SAAS,EAAyB;IAC5C,IAAI,CAACA,aAAaD,AAAsB,WAAtBA,UAAU,EAAE,CAAC,IAAI,EAC/B,OAAO;IAGX,OAAO,WAAP,GACI,oBAACE,MAAIA;QAAC,WAAW;qBACb,oBAACA,KAAK,MAAM;QAAC,MAAM;qBACf,oBAACC,OAAKA;QAAC,MAAM;QAAQ,OAAO;OAA6B;AAOzE"}
|
|
@@ -19,6 +19,7 @@ export declare function useUserForm(): {
|
|
|
19
19
|
user: IGetUserGatewayResult | undefined;
|
|
20
20
|
onSubmit: SubmitUserCallable;
|
|
21
21
|
isNewUser: boolean;
|
|
22
|
+
newUserForm: import("../../../../presentation/users/UserForm/abstractions").IUserFormPresenter;
|
|
22
23
|
fullName: string;
|
|
23
24
|
showEmptyView: boolean;
|
|
24
25
|
createUser(): void;
|
|
@@ -4,8 +4,8 @@ import omit from "lodash/omit.js";
|
|
|
4
4
|
import { useFeature } from "@webiny/app";
|
|
5
5
|
import { useRoute, useRouter } from "@webiny/app-admin";
|
|
6
6
|
import { GetUserFeature } from "../../../../features/users/getUser/index.js";
|
|
7
|
-
import { CreateUserFeature } from "../../../../features/users/createUser/index.js";
|
|
8
7
|
import { UpdateUserFeature } from "../../../../features/users/updateUser/index.js";
|
|
8
|
+
import { UserFormFeature } from "../../../../presentation/users/UserForm/feature.js";
|
|
9
9
|
import { Routes } from "../../../../routes.js";
|
|
10
10
|
import { useToast } from "@webiny/admin-ui";
|
|
11
11
|
function useUserForm() {
|
|
@@ -13,13 +13,18 @@ function useUserForm() {
|
|
|
13
13
|
const { route } = useRoute(Routes.Users.List);
|
|
14
14
|
const toast = useToast();
|
|
15
15
|
const { useCase: getUser } = useFeature(GetUserFeature);
|
|
16
|
-
const { useCase: createUser } = useFeature(CreateUserFeature);
|
|
17
16
|
const { useCase: updateUser } = useFeature(UpdateUserFeature);
|
|
17
|
+
const { presenter: newUserForm } = useFeature(UserFormFeature);
|
|
18
18
|
const id = route.params.id;
|
|
19
19
|
const newUser = true === route.params.new;
|
|
20
20
|
const [user, setUser] = useState(void 0);
|
|
21
21
|
const [userLoading, setUserLoading] = useState(false);
|
|
22
22
|
const [mutationLoading, setMutationLoading] = useState(false);
|
|
23
|
+
useEffect(()=>{
|
|
24
|
+
if (newUser) newUserForm.reset();
|
|
25
|
+
}, [
|
|
26
|
+
newUser
|
|
27
|
+
]);
|
|
23
28
|
useEffect(()=>{
|
|
24
29
|
if (!id) return;
|
|
25
30
|
setUserLoading(true);
|
|
@@ -40,26 +45,33 @@ function useUserForm() {
|
|
|
40
45
|
}, [
|
|
41
46
|
id
|
|
42
47
|
]);
|
|
43
|
-
const loading = userLoading || mutationLoading;
|
|
48
|
+
const loading = userLoading || mutationLoading || newUserForm.vm.saving;
|
|
44
49
|
const onSubmit = useCallback(async (data)=>{
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if (
|
|
48
|
-
const resultUser = await createUser.execute({
|
|
49
|
-
data
|
|
50
|
-
});
|
|
50
|
+
if (newUser) {
|
|
51
|
+
const result = await newUserForm.submit(data);
|
|
52
|
+
if ("created" === result.type || "linked" === result.type) {
|
|
51
53
|
goToRoute(Routes.Users.List, {
|
|
52
|
-
id:
|
|
54
|
+
id: result.user.id
|
|
53
55
|
});
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
await updateUser.execute({
|
|
57
|
-
id: userId,
|
|
58
|
-
data: omit(rest, [
|
|
59
|
-
"external"
|
|
60
|
-
])
|
|
56
|
+
toast.showSuccessToast({
|
|
57
|
+
title: "linked" === result.type ? "User linked to this tenant." : "User saved successfully."
|
|
61
58
|
});
|
|
62
|
-
}
|
|
59
|
+
} else if ("failed" === result.type) toast.showWarningToast({
|
|
60
|
+
title: "Error creating user",
|
|
61
|
+
description: result.message,
|
|
62
|
+
duration: 1 / 0
|
|
63
|
+
});
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
setMutationLoading(true);
|
|
67
|
+
try {
|
|
68
|
+
const { id: userId, ...rest } = data;
|
|
69
|
+
await updateUser.execute({
|
|
70
|
+
id: userId,
|
|
71
|
+
data: omit(rest, [
|
|
72
|
+
"external"
|
|
73
|
+
])
|
|
74
|
+
});
|
|
63
75
|
toast.showSuccessToast({
|
|
64
76
|
title: "User saved successfully."
|
|
65
77
|
});
|
|
@@ -84,6 +96,7 @@ function useUserForm() {
|
|
|
84
96
|
user,
|
|
85
97
|
onSubmit,
|
|
86
98
|
isNewUser: newUser,
|
|
99
|
+
newUserForm,
|
|
87
100
|
fullName: `${user?.firstName || ""} ${user?.lastName || ""}`.trim(),
|
|
88
101
|
showEmptyView,
|
|
89
102
|
createUser () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin/ui/views/Users/hooks/useUserForm.js","sources":["../../../../../../src/admin/ui/views/Users/hooks/useUserForm.ts"],"sourcesContent":["import { useCallback, useEffect, useState } from \"react\";\nimport isEmpty from \"lodash/isEmpty.js\";\nimport omit from \"lodash/omit.js\";\nimport { useFeature } from \"@webiny/app\";\nimport { useRoute, useRouter } from \"@webiny/app-admin\";\nimport { GetUserFeature } from \"~/admin/features/users/getUser/index.js\";\nimport type { IGetUserGatewayResult } from \"~/admin/features/users/getUser/abstractions/GetUserGateway.js\";\nimport {
|
|
1
|
+
{"version":3,"file":"admin/ui/views/Users/hooks/useUserForm.js","sources":["../../../../../../src/admin/ui/views/Users/hooks/useUserForm.ts"],"sourcesContent":["import { useCallback, useEffect, useState } from \"react\";\nimport isEmpty from \"lodash/isEmpty.js\";\nimport omit from \"lodash/omit.js\";\nimport { useFeature } from \"@webiny/app\";\nimport { useRoute, useRouter } from \"@webiny/app-admin\";\nimport { GetUserFeature } from \"~/admin/features/users/getUser/index.js\";\nimport type { IGetUserGatewayResult } from \"~/admin/features/users/getUser/abstractions/GetUserGateway.js\";\nimport { UpdateUserFeature } from \"~/admin/features/users/updateUser/index.js\";\nimport { UserFormFeature } from \"~/admin/presentation/users/UserForm/feature.js\";\nimport { Routes } from \"~/admin/routes.js\";\nimport { useToast } from \"@webiny/admin-ui\";\n\ninterface SubmitUserCallableParams {\n id?: string;\n firstName: string;\n lastName: string;\n email: string;\n password?: string;\n avatar: {\n src?: string;\n };\n external?: boolean;\n}\n\ninterface SubmitUserCallable {\n (data: SubmitUserCallableParams): Promise<void>;\n}\n\nexport function useUserForm() {\n const { goToRoute } = useRouter();\n const { route } = useRoute(Routes.Users.List);\n const toast = useToast();\n\n const { useCase: getUser } = useFeature(GetUserFeature);\n const { useCase: updateUser } = useFeature(UpdateUserFeature);\n const { presenter: newUserForm } = useFeature(UserFormFeature);\n\n const id = route.params.id;\n const newUser = route.params.new === true;\n\n const [user, setUser] = useState<IGetUserGatewayResult | undefined>(undefined);\n const [userLoading, setUserLoading] = useState(false);\n const [mutationLoading, setMutationLoading] = useState(false);\n\n useEffect(() => {\n if (newUser) {\n newUserForm.reset();\n }\n }, [newUser]);\n\n useEffect(() => {\n if (!id) {\n return;\n }\n setUserLoading(true);\n getUser\n .execute({ id })\n .then(data => {\n setUser(data);\n setUserLoading(false);\n })\n .catch(error => {\n goToRoute(Routes.Users.List);\n toast.showWarningToast({\n title: \"Error loading user profile\",\n description: error.message,\n duration: Infinity\n });\n setUserLoading(false);\n });\n }, [id]);\n\n const loading = userLoading || mutationLoading || newUserForm.vm.saving;\n\n const onSubmit = useCallback<SubmitUserCallable>(\n async data => {\n if (newUser) {\n const result = await newUserForm.submit(data);\n if (result.type === \"created\" || result.type === \"linked\") {\n goToRoute(Routes.Users.List, { id: result.user.id });\n toast.showSuccessToast({\n title:\n result.type === \"linked\"\n ? \"User linked to this tenant.\"\n : \"User saved successfully.\"\n });\n } else if (result.type === \"failed\") {\n toast.showWarningToast({\n title: \"Error creating user\",\n description: result.message,\n duration: Infinity\n });\n }\n // `linkRequired`: the form now shows the link alert instead.\n return;\n }\n\n setMutationLoading(true);\n\n try {\n const { id: userId, ...rest } = data;\n await updateUser.execute({\n id: userId as string,\n data: omit(rest, [\"external\"])\n });\n\n toast.showSuccessToast({\n title: \"User saved successfully.\"\n });\n } catch (error) {\n const message = error instanceof Error ? error.message : \"Unknown error\";\n toast.showWarningToast({\n title: \"Error updating user profile\",\n description: message,\n duration: Infinity\n });\n } finally {\n setMutationLoading(false);\n }\n },\n [id, newUser]\n );\n\n const showEmptyView = !newUser && !userLoading && isEmpty(user);\n\n return {\n id,\n loading,\n user,\n onSubmit,\n isNewUser: newUser,\n newUserForm,\n fullName: `${user?.firstName || \"\"} ${user?.lastName || \"\"}`.trim(),\n showEmptyView,\n createUser() {\n goToRoute(Routes.Users.List, { new: true });\n },\n cancelEditing() {\n goToRoute(Routes.Users.List);\n }\n };\n}\n"],"names":["useUserForm","goToRoute","useRouter","route","useRoute","Routes","toast","useToast","getUser","useFeature","GetUserFeature","updateUser","UpdateUserFeature","newUserForm","UserFormFeature","id","newUser","user","setUser","useState","undefined","userLoading","setUserLoading","mutationLoading","setMutationLoading","useEffect","data","error","Infinity","loading","onSubmit","useCallback","result","userId","rest","omit","message","Error","showEmptyView","isEmpty"],"mappings":";;;;;;;;;;AA4BO,SAASA;IACZ,MAAM,EAAEC,SAAS,EAAE,GAAGC;IACtB,MAAM,EAAEC,KAAK,EAAE,GAAGC,SAASC,OAAO,KAAK,CAAC,IAAI;IAC5C,MAAMC,QAAQC;IAEd,MAAM,EAAE,SAASC,OAAO,EAAE,GAAGC,WAAWC;IACxC,MAAM,EAAE,SAASC,UAAU,EAAE,GAAGF,WAAWG;IAC3C,MAAM,EAAE,WAAWC,WAAW,EAAE,GAAGJ,WAAWK;IAE9C,MAAMC,KAAKZ,MAAM,MAAM,CAAC,EAAE;IAC1B,MAAMa,UAAUb,AAAqB,SAArBA,MAAM,MAAM,CAAC,GAAG;IAEhC,MAAM,CAACc,MAAMC,QAAQ,GAAGC,SAA4CC;IACpE,MAAM,CAACC,aAAaC,eAAe,GAAGH,SAAS;IAC/C,MAAM,CAACI,iBAAiBC,mBAAmB,GAAGL,SAAS;IAEvDM,UAAU;QACN,IAAIT,SACAH,YAAY,KAAK;IAEzB,GAAG;QAACG;KAAQ;IAEZS,UAAU;QACN,IAAI,CAACV,IACD;QAEJO,eAAe;QACfd,QACK,OAAO,CAAC;YAAEO;QAAG,GACb,IAAI,CAACW,CAAAA;YACFR,QAAQQ;YACRJ,eAAe;QACnB,GACC,KAAK,CAACK,CAAAA;YACH1B,UAAUI,OAAO,KAAK,CAAC,IAAI;YAC3BC,MAAM,gBAAgB,CAAC;gBACnB,OAAO;gBACP,aAAaqB,MAAM,OAAO;gBAC1B,UAAUC,KAAQ;YACtB;YACAN,eAAe;QACnB;IACR,GAAG;QAACP;KAAG;IAEP,MAAMc,UAAUR,eAAeE,mBAAmBV,YAAY,EAAE,CAAC,MAAM;IAEvE,MAAMiB,WAAWC,YACb,OAAML;QACF,IAAIV,S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AAO,KAAK,CAAC,IAAI;QAC/B;IACJ;AACJ"}
|
package/api/CognitoApiFeature.js
CHANGED
|
@@ -5,6 +5,8 @@ import { CognitoIdpFeature } from "./features/CognitoIdp/index.js";
|
|
|
5
5
|
import { CreateUserFeature } from "./features/CreateUser/index.js";
|
|
6
6
|
import { UpdateUserFeature } from "./features/UpdateUser/index.js";
|
|
7
7
|
import { DeleteUserFeature } from "./features/DeleteUser/index.js";
|
|
8
|
+
import { LinkUserFeature } from "./features/LinkUser/index.js";
|
|
9
|
+
import { CheckEmailFeature } from "./features/CheckEmail/index.js";
|
|
8
10
|
import { CognitoServiceFeature } from "./features/CognitoService/feature.js";
|
|
9
11
|
const CognitoApiFeature = createFeature({
|
|
10
12
|
name: "CognitoApiFeature",
|
|
@@ -12,6 +14,8 @@ const CognitoApiFeature = createFeature({
|
|
|
12
14
|
CreateUserFeature.register(container);
|
|
13
15
|
UpdateUserFeature.register(container);
|
|
14
16
|
DeleteUserFeature.register(container);
|
|
17
|
+
LinkUserFeature.register(container);
|
|
18
|
+
CheckEmailFeature.register(container);
|
|
15
19
|
UserInstallerFeature.register(container);
|
|
16
20
|
CognitoIdpFeature.register(container);
|
|
17
21
|
CognitoServiceFeature.register(container, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api/CognitoApiFeature.js","sources":["../../src/api/CognitoApiFeature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { AdminUsersSchema } from \"~/api/graphql/user.gql.js\";\nimport { UserInstallerFeature } from \"./features/UserInstaller/feature.js\";\nimport { CognitoIdpFeature } from \"./features/CognitoIdp/index.js\";\nimport { CreateUserFeature } from \"./features/CreateUser/index.js\";\nimport { UpdateUserFeature } from \"./features/UpdateUser/index.js\";\nimport { DeleteUserFeature } from \"./features/DeleteUser/index.js\";\nimport { CognitoServiceFeature } from \"~/api/features/CognitoService/feature.js\";\n\nexport const CognitoApiFeature = createFeature({\n name: \"CognitoApiFeature\",\n register(container) {\n // Register features\n CreateUserFeature.register(container);\n UpdateUserFeature.register(container);\n DeleteUserFeature.register(container);\n UserInstallerFeature.register(container);\n CognitoIdpFeature.register(container);\n CognitoServiceFeature.register(container, {\n region: String(process.env.COGNITO_REGION),\n userPoolId: String(process.env.COGNITO_USER_POOL_ID)\n });\n\n // Register GraphQL schema\n container.register(AdminUsersSchema);\n }\n});\n"],"names":["CognitoApiFeature","createFeature","container","CreateUserFeature","UpdateUserFeature","DeleteUserFeature","UserInstallerFeature","CognitoIdpFeature","CognitoServiceFeature","String","process","AdminUsersSchema"],"mappings":"
|
|
1
|
+
{"version":3,"file":"api/CognitoApiFeature.js","sources":["../../src/api/CognitoApiFeature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { AdminUsersSchema } from \"~/api/graphql/user.gql.js\";\nimport { UserInstallerFeature } from \"./features/UserInstaller/feature.js\";\nimport { CognitoIdpFeature } from \"./features/CognitoIdp/index.js\";\nimport { CreateUserFeature } from \"./features/CreateUser/index.js\";\nimport { UpdateUserFeature } from \"./features/UpdateUser/index.js\";\nimport { DeleteUserFeature } from \"./features/DeleteUser/index.js\";\nimport { LinkUserFeature } from \"./features/LinkUser/index.js\";\nimport { CheckEmailFeature } from \"./features/CheckEmail/index.js\";\nimport { CognitoServiceFeature } from \"~/api/features/CognitoService/feature.js\";\n\nexport const CognitoApiFeature = createFeature({\n name: \"CognitoApiFeature\",\n register(container) {\n // Register features\n CreateUserFeature.register(container);\n UpdateUserFeature.register(container);\n DeleteUserFeature.register(container);\n LinkUserFeature.register(container);\n CheckEmailFeature.register(container);\n UserInstallerFeature.register(container);\n CognitoIdpFeature.register(container);\n CognitoServiceFeature.register(container, {\n region: String(process.env.COGNITO_REGION),\n userPoolId: String(process.env.COGNITO_USER_POOL_ID)\n });\n\n // Register GraphQL schema\n container.register(AdminUsersSchema);\n }\n});\n"],"names":["CognitoApiFeature","createFeature","container","CreateUserFeature","UpdateUserFeature","DeleteUserFeature","LinkUserFeature","CheckEmailFeature","UserInstallerFeature","CognitoIdpFeature","CognitoServiceFeature","String","process","AdminUsersSchema"],"mappings":";;;;;;;;;;AAWO,MAAMA,oBAAoBC,cAAc;IAC3C,MAAM;IACN,UAASC,SAAS;QAEdC,kBAAkB,QAAQ,CAACD;QAC3BE,kBAAkB,QAAQ,CAACF;QAC3BG,kBAAkB,QAAQ,CAACH;QAC3BI,gBAAgB,QAAQ,CAACJ;QACzBK,kBAAkB,QAAQ,CAACL;QAC3BM,qBAAqB,QAAQ,CAACN;QAC9BO,kBAAkB,QAAQ,CAACP;QAC3BQ,sBAAsB,QAAQ,CAACR,WAAW;YACtC,QAAQS,OAAOC,QAAQ,GAAG,CAAC,cAAc;YACzC,YAAYD,OAAOC,QAAQ,GAAG,CAAC,oBAAoB;QACvD;QAGAV,UAAU,QAAQ,CAACW;IACvB;AACJ"}
|
package/api/domain/errors.d.ts
CHANGED
|
@@ -8,6 +8,34 @@ export declare class CognitoAccountExistsError extends BaseError<{
|
|
|
8
8
|
readonly code: "Cognito/Account/Exists";
|
|
9
9
|
constructor(email: string);
|
|
10
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* Error when creating a user whose email already has an account in another tenant:
|
|
13
|
+
* that account has to be linked to this tenant instead
|
|
14
|
+
*/
|
|
15
|
+
export declare class CognitoAccountInOtherTenantError extends BaseError<{
|
|
16
|
+
email: string;
|
|
17
|
+
}> {
|
|
18
|
+
readonly code: "Cognito/Account/ExistsInOtherTenant";
|
|
19
|
+
constructor(email: string);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Error when linking an email that has no account in the Cognito User Pool
|
|
23
|
+
*/
|
|
24
|
+
export declare class CognitoAccountNotFoundError extends BaseError<{
|
|
25
|
+
email: string;
|
|
26
|
+
}> {
|
|
27
|
+
readonly code: "Cognito/Account/NotFound";
|
|
28
|
+
constructor(email: string);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Error when loading an account from the Cognito User Pool fails
|
|
32
|
+
*/
|
|
33
|
+
export declare class CognitoGetUserError extends BaseError<{
|
|
34
|
+
error: Error;
|
|
35
|
+
}> {
|
|
36
|
+
readonly code: "Cognito/User/Get";
|
|
37
|
+
constructor(error: Error);
|
|
38
|
+
}
|
|
11
39
|
/**
|
|
12
40
|
* Error when creating a user in Cognito fails
|
|
13
41
|
*/
|
|
@@ -26,6 +54,18 @@ export declare class CognitoUpdateUserError extends BaseError<{
|
|
|
26
54
|
readonly code: "Cognito/User/Update";
|
|
27
55
|
constructor(error: Error);
|
|
28
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Error when updating a user fails and some tenants' records can't be put back,
|
|
59
|
+
* so those records no longer match the Cognito account
|
|
60
|
+
*/
|
|
61
|
+
export declare class CognitoUpdateRollbackError extends BaseError<{
|
|
62
|
+
error: Error;
|
|
63
|
+
tenants: string[];
|
|
64
|
+
rollbackErrors: Error[];
|
|
65
|
+
}> {
|
|
66
|
+
readonly code: "Cognito/User/UpdateRollback";
|
|
67
|
+
constructor(error: Error, tenants: string[], rollbackErrors: Error[]);
|
|
68
|
+
}
|
|
29
69
|
/**
|
|
30
70
|
* Error when deleting a user from Cognito fails
|
|
31
71
|
*/
|
|
@@ -35,3 +75,12 @@ export declare class CognitoDeleteUserError extends BaseError<{
|
|
|
35
75
|
readonly code: "Cognito/User/Delete";
|
|
36
76
|
constructor(error: Error);
|
|
37
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* Error when an administrator changes the sign-in details of an account that other tenants share
|
|
80
|
+
*/
|
|
81
|
+
export declare class CognitoSharedAccountError extends BaseError<{
|
|
82
|
+
id: string;
|
|
83
|
+
}> {
|
|
84
|
+
readonly code: "Cognito/Account/Shared";
|
|
85
|
+
constructor(id: string);
|
|
86
|
+
}
|
package/api/domain/errors.js
CHANGED
|
@@ -9,6 +9,36 @@ class CognitoAccountExistsError extends BaseError {
|
|
|
9
9
|
}), this.code = "Cognito/Account/Exists";
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
|
+
class CognitoAccountInOtherTenantError extends BaseError {
|
|
13
|
+
constructor(email){
|
|
14
|
+
super({
|
|
15
|
+
message: "This email already has an account in another tenant. Link it instead.",
|
|
16
|
+
data: {
|
|
17
|
+
email
|
|
18
|
+
}
|
|
19
|
+
}), this.code = "Cognito/Account/ExistsInOtherTenant";
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
class CognitoAccountNotFoundError extends BaseError {
|
|
23
|
+
constructor(email){
|
|
24
|
+
super({
|
|
25
|
+
message: "There's no account with this email.",
|
|
26
|
+
data: {
|
|
27
|
+
email
|
|
28
|
+
}
|
|
29
|
+
}), this.code = "Cognito/Account/NotFound";
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
class CognitoGetUserError extends BaseError {
|
|
33
|
+
constructor(error){
|
|
34
|
+
super({
|
|
35
|
+
message: `Failed to load the account from Cognito: ${error.message}`,
|
|
36
|
+
data: {
|
|
37
|
+
error
|
|
38
|
+
}
|
|
39
|
+
}), this.code = "Cognito/User/Get";
|
|
40
|
+
}
|
|
41
|
+
}
|
|
12
42
|
class CognitoCreateUserError extends BaseError {
|
|
13
43
|
constructor(error){
|
|
14
44
|
super({
|
|
@@ -29,6 +59,18 @@ class CognitoUpdateUserError extends BaseError {
|
|
|
29
59
|
}), this.code = "Cognito/User/Update";
|
|
30
60
|
}
|
|
31
61
|
}
|
|
62
|
+
class CognitoUpdateRollbackError extends BaseError {
|
|
63
|
+
constructor(error, tenants, rollbackErrors){
|
|
64
|
+
super({
|
|
65
|
+
message: `Failed to update user: ${error.message}. The user's records in tenants ${tenants.join(", ")} could not be restored and no longer match the Cognito account.`,
|
|
66
|
+
data: {
|
|
67
|
+
error,
|
|
68
|
+
tenants,
|
|
69
|
+
rollbackErrors
|
|
70
|
+
}
|
|
71
|
+
}), this.code = "Cognito/User/UpdateRollback";
|
|
72
|
+
}
|
|
73
|
+
}
|
|
32
74
|
class CognitoDeleteUserError extends BaseError {
|
|
33
75
|
constructor(error){
|
|
34
76
|
super({
|
|
@@ -39,6 +81,16 @@ class CognitoDeleteUserError extends BaseError {
|
|
|
39
81
|
}), this.code = "Cognito/User/Delete";
|
|
40
82
|
}
|
|
41
83
|
}
|
|
42
|
-
|
|
84
|
+
class CognitoSharedAccountError extends BaseError {
|
|
85
|
+
constructor(id){
|
|
86
|
+
super({
|
|
87
|
+
message: "This person's account is also used in other tenants, so only they can change its name, email and password.",
|
|
88
|
+
data: {
|
|
89
|
+
id
|
|
90
|
+
}
|
|
91
|
+
}), this.code = "Cognito/Account/Shared";
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
export { CognitoAccountExistsError, CognitoAccountInOtherTenantError, CognitoAccountNotFoundError, CognitoCreateUserError, CognitoDeleteUserError, CognitoGetUserError, CognitoSharedAccountError, CognitoUpdateRollbackError, CognitoUpdateUserError };
|
|
43
95
|
|
|
44
96
|
//# sourceMappingURL=errors.js.map
|