@stackframe/stack 2.8.2 → 2.8.5
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/CHANGELOG.md +29 -0
- package/dist/components/api-key-dialogs.js +184 -0
- package/dist/components/api-key-dialogs.js.map +1 -0
- package/dist/components/api-key-table.js +149 -0
- package/dist/components/api-key-table.js.map +1 -0
- package/dist/components-page/account-settings/active-sessions/active-sessions-page.js +151 -0
- package/dist/components-page/account-settings/active-sessions/active-sessions-page.js.map +1 -0
- package/dist/components-page/account-settings/api-keys/api-keys-page.js +70 -0
- package/dist/components-page/account-settings/api-keys/api-keys-page.js.map +1 -0
- package/dist/components-page/account-settings/editable-text.js +75 -0
- package/dist/components-page/account-settings/editable-text.js.map +1 -0
- package/dist/components-page/account-settings/email-and-auth/email-and-auth-page.js +46 -0
- package/dist/components-page/account-settings/email-and-auth/email-and-auth-page.js.map +1 -0
- package/dist/components-page/account-settings/email-and-auth/emails-section.js +188 -0
- package/dist/components-page/account-settings/email-and-auth/emails-section.js.map +1 -0
- package/dist/components-page/account-settings/email-and-auth/mfa-section.js +146 -0
- package/dist/components-page/account-settings/email-and-auth/mfa-section.js.map +1 -0
- package/dist/components-page/account-settings/email-and-auth/otp-section.js +89 -0
- package/dist/components-page/account-settings/email-and-auth/otp-section.js.map +1 -0
- package/dist/components-page/account-settings/email-and-auth/passkey-section.js +92 -0
- package/dist/components-page/account-settings/email-and-auth/passkey-section.js.map +1 -0
- package/dist/components-page/account-settings/email-and-auth/password-section.js +181 -0
- package/dist/components-page/account-settings/email-and-auth/password-section.js.map +1 -0
- package/dist/components-page/account-settings/page-layout.js +34 -0
- package/dist/components-page/account-settings/page-layout.js.map +1 -0
- package/dist/components-page/account-settings/profile-page/profile-page.js +75 -0
- package/dist/components-page/account-settings/profile-page/profile-page.js.map +1 -0
- package/dist/components-page/account-settings/section.js +44 -0
- package/dist/components-page/account-settings/section.js.map +1 -0
- package/dist/components-page/account-settings/settings/delete-account-section.js +87 -0
- package/dist/components-page/account-settings/settings/delete-account-section.js.map +1 -0
- package/dist/components-page/account-settings/settings/settings-page.js +40 -0
- package/dist/components-page/account-settings/settings/settings-page.js.map +1 -0
- package/dist/components-page/account-settings/settings/sign-out-section.js +54 -0
- package/dist/components-page/account-settings/settings/sign-out-section.js.map +1 -0
- package/dist/components-page/account-settings/teams/leave-team-section.js +79 -0
- package/dist/components-page/account-settings/teams/leave-team-section.js.map +1 -0
- package/dist/components-page/account-settings/teams/team-api-keys-section.js +89 -0
- package/dist/components-page/account-settings/teams/team-api-keys-section.js.map +1 -0
- package/dist/components-page/account-settings/teams/team-creation-page.js +92 -0
- package/dist/components-page/account-settings/teams/team-creation-page.js.map +1 -0
- package/dist/components-page/account-settings/teams/team-display-name-section.js +57 -0
- package/dist/components-page/account-settings/teams/team-display-name-section.js.map +1 -0
- package/dist/components-page/account-settings/teams/team-member-invitation-section.js +131 -0
- package/dist/components-page/account-settings/teams/team-member-invitation-section.js.map +1 -0
- package/dist/components-page/account-settings/teams/team-member-list-section.js +61 -0
- package/dist/components-page/account-settings/teams/team-member-list-section.js.map +1 -0
- package/dist/components-page/account-settings/teams/team-page.js +50 -0
- package/dist/components-page/account-settings/teams/team-page.js.map +1 -0
- package/dist/components-page/account-settings/teams/team-profile-image-section.js +59 -0
- package/dist/components-page/account-settings/teams/team-profile-image-section.js.map +1 -0
- package/dist/components-page/account-settings/teams/team-profile-user-section.js +56 -0
- package/dist/components-page/account-settings/teams/team-profile-user-section.js.map +1 -0
- package/dist/components-page/account-settings.js +34 -1072
- package/dist/components-page/account-settings.js.map +1 -1
- package/dist/components-page/section.js +6 -0
- package/dist/components-page/section.js.map +1 -0
- package/dist/esm/components/api-key-dialogs.js +157 -0
- package/dist/esm/components/api-key-dialogs.js.map +1 -0
- package/dist/esm/components/api-key-table.js +125 -0
- package/dist/esm/components/api-key-table.js.map +1 -0
- package/dist/esm/components-page/account-settings/active-sessions/active-sessions-page.js +126 -0
- package/dist/esm/components-page/account-settings/active-sessions/active-sessions-page.js.map +1 -0
- package/dist/esm/components-page/account-settings/api-keys/api-keys-page.js +45 -0
- package/dist/esm/components-page/account-settings/api-keys/api-keys-page.js.map +1 -0
- package/dist/esm/components-page/account-settings/editable-text.js +50 -0
- package/dist/esm/components-page/account-settings/editable-text.js.map +1 -0
- package/dist/esm/components-page/account-settings/email-and-auth/email-and-auth-page.js +21 -0
- package/dist/esm/components-page/account-settings/email-and-auth/email-and-auth-page.js.map +1 -0
- package/dist/esm/components-page/account-settings/email-and-auth/emails-section.js +163 -0
- package/dist/esm/components-page/account-settings/email-and-auth/emails-section.js.map +1 -0
- package/dist/esm/components-page/account-settings/email-and-auth/mfa-section.js +111 -0
- package/dist/esm/components-page/account-settings/email-and-auth/mfa-section.js.map +1 -0
- package/dist/esm/components-page/account-settings/email-and-auth/otp-section.js +64 -0
- package/dist/esm/components-page/account-settings/email-and-auth/otp-section.js.map +1 -0
- package/dist/esm/components-page/account-settings/email-and-auth/passkey-section.js +67 -0
- package/dist/esm/components-page/account-settings/email-and-auth/passkey-section.js.map +1 -0
- package/dist/esm/components-page/account-settings/email-and-auth/password-section.js +146 -0
- package/dist/esm/components-page/account-settings/email-and-auth/password-section.js.map +1 -0
- package/dist/esm/components-page/account-settings/page-layout.js +9 -0
- package/dist/esm/components-page/account-settings/page-layout.js.map +1 -0
- package/dist/esm/components-page/account-settings/profile-page/profile-page.js +50 -0
- package/dist/esm/components-page/account-settings/profile-page/profile-page.js.map +1 -0
- package/dist/esm/components-page/account-settings/section.js +19 -0
- package/dist/esm/components-page/account-settings/section.js.map +1 -0
- package/dist/esm/components-page/account-settings/settings/delete-account-section.js +62 -0
- package/dist/esm/components-page/account-settings/settings/delete-account-section.js.map +1 -0
- package/dist/esm/components-page/account-settings/settings/settings-page.js +15 -0
- package/dist/esm/components-page/account-settings/settings/settings-page.js.map +1 -0
- package/dist/esm/components-page/account-settings/settings/sign-out-section.js +29 -0
- package/dist/esm/components-page/account-settings/settings/sign-out-section.js.map +1 -0
- package/dist/esm/components-page/account-settings/teams/leave-team-section.js +54 -0
- package/dist/esm/components-page/account-settings/teams/leave-team-section.js.map +1 -0
- package/dist/esm/components-page/account-settings/teams/team-api-keys-section.js +64 -0
- package/dist/esm/components-page/account-settings/teams/team-api-keys-section.js.map +1 -0
- package/dist/esm/components-page/account-settings/teams/team-creation-page.js +67 -0
- package/dist/esm/components-page/account-settings/teams/team-creation-page.js.map +1 -0
- package/dist/esm/components-page/account-settings/teams/team-display-name-section.js +32 -0
- package/dist/esm/components-page/account-settings/teams/team-display-name-section.js.map +1 -0
- package/dist/esm/components-page/account-settings/teams/team-member-invitation-section.js +106 -0
- package/dist/esm/components-page/account-settings/teams/team-member-invitation-section.js.map +1 -0
- package/dist/esm/components-page/account-settings/teams/team-member-list-section.js +36 -0
- package/dist/esm/components-page/account-settings/teams/team-member-list-section.js.map +1 -0
- package/dist/esm/components-page/account-settings/teams/team-page.js +25 -0
- package/dist/esm/components-page/account-settings/teams/team-page.js.map +1 -0
- package/dist/esm/components-page/account-settings/teams/team-profile-image-section.js +34 -0
- package/dist/esm/components-page/account-settings/teams/team-profile-image-section.js.map +1 -0
- package/dist/esm/components-page/account-settings/teams/team-profile-user-section.js +31 -0
- package/dist/esm/components-page/account-settings/teams/team-profile-user-section.js.map +1 -0
- package/dist/esm/components-page/account-settings.js +34 -1061
- package/dist/esm/components-page/account-settings.js.map +1 -1
- package/dist/esm/components-page/section.js +4 -0
- package/dist/esm/components-page/section.js.map +1 -0
- package/dist/esm/lib/stack-app/api-keys/index.js +14 -6
- package/dist/esm/lib/stack-app/api-keys/index.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/admin-app-impl.js +26 -23
- package/dist/esm/lib/stack-app/apps/implementations/admin-app-impl.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.js +169 -0
- package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/common.js +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/common.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/server-app-impl.js +148 -8
- package/dist/esm/lib/stack-app/apps/implementations/server-app-impl.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/interfaces/admin-app.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/interfaces/client-app.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/interfaces/server-app.js.map +1 -1
- package/dist/esm/lib/stack-app/index.js.map +1 -1
- package/dist/esm/lib/stack-app/internal-api-keys/index.js +14 -0
- package/dist/esm/lib/stack-app/internal-api-keys/index.js.map +1 -0
- package/dist/esm/lib/stack-app/projects/index.js +3 -1
- package/dist/esm/lib/stack-app/projects/index.js.map +1 -1
- package/dist/esm/lib/stack-app/teams/index.js.map +1 -1
- package/dist/esm/lib/stack-app/users/index.js.map +1 -1
- package/dist/index.d.mts +103 -35
- package/dist/index.d.ts +103 -35
- package/dist/lib/stack-app/api-keys/index.js +16 -7
- package/dist/lib/stack-app/api-keys/index.js.map +1 -1
- package/dist/lib/stack-app/apps/implementations/admin-app-impl.js +25 -22
- package/dist/lib/stack-app/apps/implementations/admin-app-impl.js.map +1 -1
- package/dist/lib/stack-app/apps/implementations/client-app-impl.js +169 -0
- package/dist/lib/stack-app/apps/implementations/client-app-impl.js.map +1 -1
- package/dist/lib/stack-app/apps/implementations/common.js +1 -1
- package/dist/lib/stack-app/apps/implementations/common.js.map +1 -1
- package/dist/lib/stack-app/apps/implementations/server-app-impl.js +148 -8
- package/dist/lib/stack-app/apps/implementations/server-app-impl.js.map +1 -1
- package/dist/lib/stack-app/apps/interfaces/admin-app.js.map +1 -1
- package/dist/lib/stack-app/apps/interfaces/client-app.js.map +1 -1
- package/dist/lib/stack-app/apps/interfaces/server-app.js.map +1 -1
- package/dist/lib/stack-app/index.js.map +1 -1
- package/dist/lib/stack-app/internal-api-keys/index.js +39 -0
- package/dist/lib/stack-app/internal-api-keys/index.js.map +1 -0
- package/dist/lib/stack-app/project-configs/index.js.map +1 -1
- package/dist/lib/stack-app/projects/index.js +3 -1
- package/dist/lib/stack-app/projects/index.js.map +1 -1
- package/dist/lib/stack-app/teams/index.js.map +1 -1
- package/dist/lib/stack-app/users/index.js.map +1 -1
- package/package.json +5 -4
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
"use strict";
|
|
3
3
|
"use client";
|
|
4
|
-
var __create = Object.create;
|
|
5
4
|
var __defProp = Object.defineProperty;
|
|
6
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
9
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
8
|
var __export = (target, all) => {
|
|
11
9
|
for (var name in all)
|
|
@@ -19,47 +17,29 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
19
17
|
}
|
|
20
18
|
return to;
|
|
21
19
|
};
|
|
22
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
28
|
-
mod
|
|
29
|
-
));
|
|
30
20
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
31
21
|
|
|
32
22
|
// src/components-page/account-settings.tsx
|
|
33
23
|
var account_settings_exports = {};
|
|
34
24
|
__export(account_settings_exports, {
|
|
35
|
-
AccountSettings: () => AccountSettings
|
|
36
|
-
EditableText: () => EditableText
|
|
25
|
+
AccountSettings: () => AccountSettings
|
|
37
26
|
});
|
|
38
27
|
module.exports = __toCommonJS(account_settings_exports);
|
|
39
|
-
var import_yup = require("@hookform/resolvers/yup");
|
|
40
|
-
var import_otp = require("@oslojs/otp");
|
|
41
|
-
var import_stack_shared = require("@stackframe/stack-shared");
|
|
42
|
-
var import_password = require("@stackframe/stack-shared/dist/helpers/password");
|
|
43
|
-
var import_use_async_callback = require("@stackframe/stack-shared/dist/hooks/use-async-callback");
|
|
44
|
-
var import_schema_fields = require("@stackframe/stack-shared/dist/schema-fields");
|
|
45
|
-
var import_crypto = require("@stackframe/stack-shared/dist/utils/crypto");
|
|
46
|
-
var import_dates = require("@stackframe/stack-shared/dist/utils/dates");
|
|
47
|
-
var import_errors = require("@stackframe/stack-shared/dist/utils/errors");
|
|
48
|
-
var import_promises = require("@stackframe/stack-shared/dist/utils/promises");
|
|
49
28
|
var import_stack_ui = require("@stackframe/stack-ui");
|
|
50
29
|
var import_lucide_react = require("lucide-react");
|
|
51
|
-
var QRCode = __toESM(require("qrcode"));
|
|
52
30
|
var import_react = require("react");
|
|
53
|
-
var import_react_hook_form = require("react-hook-form");
|
|
54
|
-
var yup = __toESM(require("yup"));
|
|
55
31
|
var import__ = require("..");
|
|
56
|
-
var import_form_warning = require("../components/elements/form-warning");
|
|
57
32
|
var import_maybe_full_page = require("../components/elements/maybe-full-page");
|
|
58
33
|
var import_sidebar_layout = require("../components/elements/sidebar-layout");
|
|
59
|
-
var import_user_avatar = require("../components/elements/user-avatar");
|
|
60
|
-
var import_profile_image_editor = require("../components/profile-image-editor");
|
|
61
34
|
var import_team_icon = require("../components/team-icon");
|
|
62
35
|
var import_translations = require("../lib/translations");
|
|
36
|
+
var import_active_sessions_page = require("./account-settings/active-sessions/active-sessions-page");
|
|
37
|
+
var import_api_keys_page = require("./account-settings/api-keys/api-keys-page");
|
|
38
|
+
var import_email_and_auth_page = require("./account-settings/email-and-auth/email-and-auth-page");
|
|
39
|
+
var import_profile_page = require("./account-settings/profile-page/profile-page");
|
|
40
|
+
var import_settings_page = require("./account-settings/settings/settings-page");
|
|
41
|
+
var import_team_creation_page = require("./account-settings/teams/team-creation-page");
|
|
42
|
+
var import_team_page = require("./account-settings/teams/team-page");
|
|
63
43
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
64
44
|
var Icon = ({ name }) => {
|
|
65
45
|
const LucideIcon = import_lucide_react.icons[name];
|
|
@@ -80,28 +60,35 @@ function AccountSettings(props) {
|
|
|
80
60
|
type: "item",
|
|
81
61
|
id: "profile",
|
|
82
62
|
icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, { name: "Contact" }),
|
|
83
|
-
content: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ProfilePage, {})
|
|
63
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_profile_page.ProfilePage, {})
|
|
84
64
|
},
|
|
85
65
|
{
|
|
86
66
|
title: t("Emails & Auth"),
|
|
87
67
|
type: "item",
|
|
88
68
|
id: "auth",
|
|
89
69
|
icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, { name: "ShieldCheck" }),
|
|
90
|
-
content: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.Suspense, { fallback: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EmailsAndAuthPageSkeleton, {}), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EmailsAndAuthPage, {}) })
|
|
70
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.Suspense, { fallback: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EmailsAndAuthPageSkeleton, {}), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_email_and_auth_page.EmailsAndAuthPage, {}) })
|
|
91
71
|
},
|
|
92
72
|
{
|
|
93
73
|
title: t("Active Sessions"),
|
|
94
74
|
type: "item",
|
|
95
75
|
id: "sessions",
|
|
96
76
|
icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, { name: "Monitor" }),
|
|
97
|
-
content: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.Suspense, { fallback: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ActiveSessionsPageSkeleton, {}), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ActiveSessionsPage, {}) })
|
|
77
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.Suspense, { fallback: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ActiveSessionsPageSkeleton, {}), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_active_sessions_page.ActiveSessionsPage, {}) })
|
|
98
78
|
},
|
|
79
|
+
...project.config.allowUserApiKeys ? [{
|
|
80
|
+
title: t("API Keys"),
|
|
81
|
+
type: "item",
|
|
82
|
+
id: "api-keys",
|
|
83
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, { name: "Key" }),
|
|
84
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.Suspense, { fallback: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ApiKeysPageSkeleton, {}), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_api_keys_page.ApiKeysPage, {}) })
|
|
85
|
+
}] : [],
|
|
99
86
|
{
|
|
100
87
|
title: t("Settings"),
|
|
101
88
|
type: "item",
|
|
102
89
|
id: "settings",
|
|
103
90
|
icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, { name: "Settings" }),
|
|
104
|
-
content: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SettingsPage, {})
|
|
91
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_settings_page.SettingsPage, {})
|
|
105
92
|
},
|
|
106
93
|
...props.extraItems?.map((item) => ({
|
|
107
94
|
title: item.title,
|
|
@@ -129,341 +116,23 @@ function AccountSettings(props) {
|
|
|
129
116
|
] }),
|
|
130
117
|
type: "item",
|
|
131
118
|
id: `team-${team.id}`,
|
|
132
|
-
content: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TeamPage, { team })
|
|
119
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.Suspense, { fallback: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TeamPageSkeleton, {}), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_team_page.TeamPage, { team }) })
|
|
133
120
|
})),
|
|
134
121
|
...project.config.clientTeamCreationEnabled ? [{
|
|
135
122
|
title: t("Create a team"),
|
|
136
123
|
icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, { name: "CirclePlus" }),
|
|
137
124
|
type: "item",
|
|
138
125
|
id: "team-creation",
|
|
139
|
-
content: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
126
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.Suspense, { fallback: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TeamCreationSkeleton, {}), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_team_creation_page.TeamCreationPage, {}) })
|
|
140
127
|
}] : []
|
|
141
128
|
].filter((p) => p.type === "divider" || p.content),
|
|
142
129
|
title: t("Account Settings")
|
|
143
130
|
}
|
|
144
131
|
) }) });
|
|
145
132
|
}
|
|
146
|
-
function Section(props) {
|
|
147
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
148
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Separator, {}),
|
|
149
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex flex-col sm:flex-row gap-2", children: [
|
|
150
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "sm:flex-1 flex flex-col justify-center", children: [
|
|
151
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Typography, { className: "font-medium", children: props.title }),
|
|
152
|
-
props.description && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Typography, { variant: "secondary", type: "footnote", children: props.description })
|
|
153
|
-
] }),
|
|
154
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "sm:flex-1 sm:items-end flex flex-col gap-2 ", children: props.children })
|
|
155
|
-
] })
|
|
156
|
-
] });
|
|
157
|
-
}
|
|
158
133
|
function PageLayout(props) {
|
|
159
134
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "flex flex-col gap-6", children: props.children });
|
|
160
135
|
}
|
|
161
|
-
function ProfilePage() {
|
|
162
|
-
const { t } = (0, import_translations.useTranslation)();
|
|
163
|
-
const user = (0, import__.useUser)({ or: "redirect" });
|
|
164
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(PageLayout, { children: [
|
|
165
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
166
|
-
Section,
|
|
167
|
-
{
|
|
168
|
-
title: t("User name"),
|
|
169
|
-
description: t("This is a display name and is not used for authentication"),
|
|
170
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
171
|
-
EditableText,
|
|
172
|
-
{
|
|
173
|
-
value: user.displayName || "",
|
|
174
|
-
onSave: async (newDisplayName) => {
|
|
175
|
-
await user.update({ displayName: newDisplayName });
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
)
|
|
179
|
-
}
|
|
180
|
-
),
|
|
181
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
182
|
-
Section,
|
|
183
|
-
{
|
|
184
|
-
title: t("Profile image"),
|
|
185
|
-
description: t("Upload your own image as your avatar"),
|
|
186
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
187
|
-
import_profile_image_editor.ProfileImageEditor,
|
|
188
|
-
{
|
|
189
|
-
user,
|
|
190
|
-
onProfileImageUrlChange: async (profileImageUrl) => {
|
|
191
|
-
await user.update({ profileImageUrl });
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
)
|
|
195
|
-
}
|
|
196
|
-
)
|
|
197
|
-
] });
|
|
198
|
-
}
|
|
199
|
-
function EmailsSection() {
|
|
200
|
-
const { t } = (0, import_translations.useTranslation)();
|
|
201
|
-
const user = (0, import__.useUser)({ or: "redirect" });
|
|
202
|
-
const contactChannels = user.useContactChannels();
|
|
203
|
-
const [addingEmail, setAddingEmail] = (0, import_react.useState)(contactChannels.length === 0);
|
|
204
|
-
const [addingEmailLoading, setAddingEmailLoading] = (0, import_react.useState)(false);
|
|
205
|
-
const [addedEmail, setAddedEmail] = (0, import_react.useState)(null);
|
|
206
|
-
const isLastEmail = contactChannels.filter((x) => x.usedForAuth && x.type === "email").length === 1;
|
|
207
|
-
(0, import_react.useEffect)(() => {
|
|
208
|
-
if (addedEmail) {
|
|
209
|
-
(0, import_promises.runAsynchronously)(async () => {
|
|
210
|
-
const cc = contactChannels.find((x) => x.value === addedEmail);
|
|
211
|
-
if (cc && !cc.isVerified) {
|
|
212
|
-
await cc.sendVerificationEmail();
|
|
213
|
-
}
|
|
214
|
-
setAddedEmail(null);
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
}, [contactChannels, addedEmail]);
|
|
218
|
-
const emailSchema = (0, import_schema_fields.yupObject)({
|
|
219
|
-
email: (0, import_schema_fields.strictEmailSchema)(t("Please enter a valid email address")).notOneOf(contactChannels.map((x) => x.value), t("Email already exists")).defined().nonEmpty(t("Email is required"))
|
|
220
|
-
});
|
|
221
|
-
const { register, handleSubmit, formState: { errors }, reset } = (0, import_react_hook_form.useForm)({
|
|
222
|
-
resolver: (0, import_yup.yupResolver)(emailSchema)
|
|
223
|
-
});
|
|
224
|
-
const onSubmit = async (data) => {
|
|
225
|
-
setAddingEmailLoading(true);
|
|
226
|
-
try {
|
|
227
|
-
await user.createContactChannel({ type: "email", value: data.email, usedForAuth: false });
|
|
228
|
-
setAddedEmail(data.email);
|
|
229
|
-
} finally {
|
|
230
|
-
setAddingEmailLoading(false);
|
|
231
|
-
}
|
|
232
|
-
setAddingEmail(false);
|
|
233
|
-
reset();
|
|
234
|
-
};
|
|
235
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
|
|
236
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex flex-col md:flex-row justify-between mb-4 gap-4", children: [
|
|
237
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Typography, { className: "font-medium", children: t("Emails") }),
|
|
238
|
-
addingEmail ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
239
|
-
"form",
|
|
240
|
-
{
|
|
241
|
-
onSubmit: (e) => {
|
|
242
|
-
e.preventDefault();
|
|
243
|
-
(0, import_promises.runAsynchronously)(handleSubmit(onSubmit));
|
|
244
|
-
},
|
|
245
|
-
className: "flex flex-col",
|
|
246
|
-
children: [
|
|
247
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex gap-2", children: [
|
|
248
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
249
|
-
import_stack_ui.Input,
|
|
250
|
-
{
|
|
251
|
-
...register("email"),
|
|
252
|
-
placeholder: t("Enter email")
|
|
253
|
-
}
|
|
254
|
-
),
|
|
255
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Button, { type: "submit", loading: addingEmailLoading, children: t("Add") }),
|
|
256
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
257
|
-
import_stack_ui.Button,
|
|
258
|
-
{
|
|
259
|
-
variant: "secondary",
|
|
260
|
-
onClick: () => {
|
|
261
|
-
setAddingEmail(false);
|
|
262
|
-
reset();
|
|
263
|
-
},
|
|
264
|
-
children: t("Cancel")
|
|
265
|
-
}
|
|
266
|
-
)
|
|
267
|
-
] }),
|
|
268
|
-
errors.email && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_form_warning.FormWarningText, { text: errors.email.message })
|
|
269
|
-
]
|
|
270
|
-
}
|
|
271
|
-
) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "flex md:justify-end", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Button, { variant: "secondary", onClick: () => setAddingEmail(true), children: t("Add an email") }) })
|
|
272
|
-
] }),
|
|
273
|
-
contactChannels.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "border rounded-md", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Table, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.TableBody, { children: contactChannels.filter((x) => x.type === "email").sort((a, b) => {
|
|
274
|
-
if (a.isPrimary !== b.isPrimary) return a.isPrimary ? -1 : 1;
|
|
275
|
-
if (a.isVerified !== b.isVerified) return a.isVerified ? -1 : 1;
|
|
276
|
-
return 0;
|
|
277
|
-
}).map((x) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_stack_ui.TableRow, { children: [
|
|
278
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.TableCell, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex flex-col md:flex-row gap-2 md:gap-4", children: [
|
|
279
|
-
x.value,
|
|
280
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex gap-2", children: [
|
|
281
|
-
x.isPrimary ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Badge, { children: t("Primary") }) : null,
|
|
282
|
-
!x.isVerified ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Badge, { variant: "destructive", children: t("Unverified") }) : null,
|
|
283
|
-
x.usedForAuth ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Badge, { variant: "outline", children: t("Used for sign-in") }) : null
|
|
284
|
-
] })
|
|
285
|
-
] }) }),
|
|
286
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.TableCell, { className: "flex justify-end", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.ActionCell, { items: [
|
|
287
|
-
...!x.isVerified ? [{
|
|
288
|
-
item: t("Send verification email"),
|
|
289
|
-
onClick: async () => {
|
|
290
|
-
await x.sendVerificationEmail();
|
|
291
|
-
}
|
|
292
|
-
}] : [],
|
|
293
|
-
...!x.isPrimary && x.isVerified ? [{
|
|
294
|
-
item: t("Set as primary"),
|
|
295
|
-
onClick: async () => {
|
|
296
|
-
await x.update({ isPrimary: true });
|
|
297
|
-
}
|
|
298
|
-
}] : !x.isPrimary ? [{
|
|
299
|
-
item: t("Set as primary"),
|
|
300
|
-
onClick: async () => {
|
|
301
|
-
},
|
|
302
|
-
disabled: true,
|
|
303
|
-
disabledTooltip: t("Please verify your email first")
|
|
304
|
-
}] : [],
|
|
305
|
-
...!x.usedForAuth && x.isVerified ? [{
|
|
306
|
-
item: t("Use for sign-in"),
|
|
307
|
-
onClick: async () => {
|
|
308
|
-
try {
|
|
309
|
-
await x.update({ usedForAuth: true });
|
|
310
|
-
} catch (e) {
|
|
311
|
-
if (e instanceof import_stack_shared.KnownErrors.ContactChannelAlreadyUsedForAuthBySomeoneElse) {
|
|
312
|
-
alert(t("This email is already used for sign-in by another user."));
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
}] : [],
|
|
317
|
-
...x.usedForAuth && !isLastEmail ? [{
|
|
318
|
-
item: t("Stop using for sign-in"),
|
|
319
|
-
onClick: async () => {
|
|
320
|
-
await x.update({ usedForAuth: false });
|
|
321
|
-
}
|
|
322
|
-
}] : x.usedForAuth ? [{
|
|
323
|
-
item: t("Stop using for sign-in"),
|
|
324
|
-
onClick: async () => {
|
|
325
|
-
},
|
|
326
|
-
disabled: true,
|
|
327
|
-
disabledTooltip: t("You can not remove your last sign-in email")
|
|
328
|
-
}] : [],
|
|
329
|
-
...!isLastEmail || !x.usedForAuth ? [{
|
|
330
|
-
item: t("Remove"),
|
|
331
|
-
onClick: async () => {
|
|
332
|
-
await x.delete();
|
|
333
|
-
},
|
|
334
|
-
danger: true
|
|
335
|
-
}] : [{
|
|
336
|
-
item: t("Remove"),
|
|
337
|
-
onClick: async () => {
|
|
338
|
-
},
|
|
339
|
-
disabled: true,
|
|
340
|
-
disabledTooltip: t("You can not remove your last sign-in email")
|
|
341
|
-
}]
|
|
342
|
-
] }) })
|
|
343
|
-
] }, x.id)) }) }) }) : null
|
|
344
|
-
] });
|
|
345
|
-
}
|
|
346
|
-
function EmailsAndAuthPage() {
|
|
347
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(PageLayout, { children: [
|
|
348
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(EmailsSection, {}),
|
|
349
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(PasswordSection, {}),
|
|
350
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(PasskeySection, {}),
|
|
351
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(OtpSection, {}),
|
|
352
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(MfaSection, {})
|
|
353
|
-
] });
|
|
354
|
-
}
|
|
355
|
-
function ActiveSessionsPage() {
|
|
356
|
-
const { t } = (0, import_translations.useTranslation)();
|
|
357
|
-
const user = (0, import__.useUser)({ or: "throw" });
|
|
358
|
-
const [isLoading, setIsLoading] = (0, import_react.useState)(true);
|
|
359
|
-
const [isRevokingAll, setIsRevokingAll] = (0, import_react.useState)(false);
|
|
360
|
-
const [sessions, setSessions] = (0, import_react.useState)([]);
|
|
361
|
-
const [showConfirmRevokeAll, setShowConfirmRevokeAll] = (0, import_react.useState)(false);
|
|
362
|
-
(0, import_react.useEffect)(() => {
|
|
363
|
-
(0, import_promises.runAsynchronously)(async () => {
|
|
364
|
-
setIsLoading(true);
|
|
365
|
-
const sessionsData = await user.getActiveSessions();
|
|
366
|
-
const enhancedSessions = sessionsData;
|
|
367
|
-
setSessions(enhancedSessions);
|
|
368
|
-
setIsLoading(false);
|
|
369
|
-
});
|
|
370
|
-
}, [user]);
|
|
371
|
-
const handleRevokeSession = async (sessionId) => {
|
|
372
|
-
try {
|
|
373
|
-
await user.revokeSession(sessionId);
|
|
374
|
-
setSessions(sessions.filter((session) => session.id !== sessionId));
|
|
375
|
-
} catch (error) {
|
|
376
|
-
(0, import_errors.captureError)("Failed to revoke session", { sessionId, error });
|
|
377
|
-
throw error;
|
|
378
|
-
}
|
|
379
|
-
};
|
|
380
|
-
const handleRevokeAllSessions = async () => {
|
|
381
|
-
setIsRevokingAll(true);
|
|
382
|
-
try {
|
|
383
|
-
const deletionPromises = sessions.filter((session) => !session.isCurrentSession).map((session) => user.revokeSession(session.id));
|
|
384
|
-
await Promise.all(deletionPromises);
|
|
385
|
-
setSessions((prevSessions) => prevSessions.filter((session) => session.isCurrentSession));
|
|
386
|
-
} catch (error) {
|
|
387
|
-
(0, import_errors.captureError)("Failed to revoke all sessions", { error, sessionIds: sessions.map((session) => session.id) });
|
|
388
|
-
throw error;
|
|
389
|
-
} finally {
|
|
390
|
-
setIsRevokingAll(false);
|
|
391
|
-
setShowConfirmRevokeAll(false);
|
|
392
|
-
}
|
|
393
|
-
};
|
|
394
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PageLayout, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
|
|
395
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex justify-between items-center mb-2", children: [
|
|
396
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Typography, { className: "font-medium", children: t("Active Sessions") }),
|
|
397
|
-
sessions.filter((s) => !s.isCurrentSession).length > 0 && !isLoading && (showConfirmRevokeAll ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex gap-2", children: [
|
|
398
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
399
|
-
import_stack_ui.Button,
|
|
400
|
-
{
|
|
401
|
-
variant: "destructive",
|
|
402
|
-
size: "sm",
|
|
403
|
-
loading: isRevokingAll,
|
|
404
|
-
onClick: handleRevokeAllSessions,
|
|
405
|
-
children: t("Confirm")
|
|
406
|
-
}
|
|
407
|
-
),
|
|
408
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
409
|
-
import_stack_ui.Button,
|
|
410
|
-
{
|
|
411
|
-
variant: "secondary",
|
|
412
|
-
size: "sm",
|
|
413
|
-
disabled: isRevokingAll,
|
|
414
|
-
onClick: () => setShowConfirmRevokeAll(false),
|
|
415
|
-
children: t("Cancel")
|
|
416
|
-
}
|
|
417
|
-
)
|
|
418
|
-
] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
419
|
-
import_stack_ui.Button,
|
|
420
|
-
{
|
|
421
|
-
variant: "outline",
|
|
422
|
-
size: "sm",
|
|
423
|
-
onClick: () => setShowConfirmRevokeAll(true),
|
|
424
|
-
children: t("Revoke All Other Sessions")
|
|
425
|
-
}
|
|
426
|
-
))
|
|
427
|
-
] }),
|
|
428
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Typography, { variant: "secondary", type: "footnote", className: "mb-4", children: t("These are devices where you're currently logged in. You can revoke access to end a session.") }),
|
|
429
|
-
isLoading ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Skeleton, { className: "h-[300px] w-full rounded-md" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "border rounded-md", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_stack_ui.Table, { children: [
|
|
430
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.TableHeader, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_stack_ui.TableRow, { children: [
|
|
431
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.TableHead, { className: "w-[200px]", children: t("Session") }),
|
|
432
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.TableHead, { className: "w-[150px]", children: t("IP Address") }),
|
|
433
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.TableHead, { className: "w-[150px]", children: t("Location") }),
|
|
434
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.TableHead, { className: "w-[150px]", children: t("Last used") }),
|
|
435
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.TableHead, { className: "w-[80px]" })
|
|
436
|
-
] }) }),
|
|
437
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.TableBody, { children: sessions.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.TableRow, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.TableCell, { colSpan: 5, className: "text-center py-6", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Typography, { variant: "secondary", children: t("No active sessions found") }) }) }) : sessions.map((session) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_stack_ui.TableRow, { children: [
|
|
438
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.TableCell, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex flex-col", children: [
|
|
439
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Typography, { children: session.isCurrentSession ? t("Current Session") : t("Other Session") }),
|
|
440
|
-
session.isImpersonation && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Badge, { variant: "secondary", className: "w-fit mt-1", children: t("Impersonation") }),
|
|
441
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Typography, { variant: "secondary", type: "footnote", children: t("Signed in {time}", { time: new Date(session.createdAt).toLocaleDateString() }) })
|
|
442
|
-
] }) }),
|
|
443
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.TableCell, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Typography, { children: session.geoInfo?.ip || t("-") }) }),
|
|
444
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.TableCell, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Typography, { children: session.geoInfo?.cityName || t("Unknown") }) }),
|
|
445
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.TableCell, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex flex-col", children: [
|
|
446
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Typography, { children: session.lastUsedAt ? (0, import_dates.fromNow)(new Date(session.lastUsedAt)) : t("Never") }),
|
|
447
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Typography, { variant: "secondary", type: "footnote", title: session.lastUsedAt ? new Date(session.lastUsedAt).toLocaleString() : "", children: session.lastUsedAt ? new Date(session.lastUsedAt).toLocaleDateString() : "" })
|
|
448
|
-
] }) }),
|
|
449
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.TableCell, { align: "right", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
450
|
-
import_stack_ui.ActionCell,
|
|
451
|
-
{
|
|
452
|
-
items: [
|
|
453
|
-
{
|
|
454
|
-
item: t("Revoke"),
|
|
455
|
-
onClick: () => handleRevokeSession(session.id),
|
|
456
|
-
danger: true,
|
|
457
|
-
disabled: session.isCurrentSession,
|
|
458
|
-
disabledTooltip: session.isCurrentSession ? t("You cannot revoke your current session") : void 0
|
|
459
|
-
}
|
|
460
|
-
]
|
|
461
|
-
}
|
|
462
|
-
) })
|
|
463
|
-
] }, session.id)) })
|
|
464
|
-
] }) })
|
|
465
|
-
] }) });
|
|
466
|
-
}
|
|
467
136
|
function EmailsAndAuthPageSkeleton() {
|
|
468
137
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(PageLayout, { children: [
|
|
469
138
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Skeleton, { className: "h-9 w-full mt-1" }),
|
|
@@ -479,735 +148,28 @@ function ActiveSessionsPageSkeleton() {
|
|
|
479
148
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Skeleton, { className: "h-[200px] w-full mt-1 rounded-md" })
|
|
480
149
|
] });
|
|
481
150
|
}
|
|
482
|
-
function
|
|
483
|
-
const { t } = (0, import_translations.useTranslation)();
|
|
484
|
-
const user = (0, import__.useUser)({ or: "throw" });
|
|
485
|
-
const stackApp = (0, import__.useStackApp)();
|
|
486
|
-
const project = stackApp.useProject();
|
|
487
|
-
const contactChannels = user.useContactChannels();
|
|
488
|
-
const hasPasskey = user.passkeyAuthEnabled;
|
|
489
|
-
const isLastAuth = user.passkeyAuthEnabled && !user.hasPassword && user.oauthProviders.length === 0 && !user.otpAuthEnabled;
|
|
490
|
-
const [showConfirmationModal, setShowConfirmationModal] = (0, import_react.useState)(false);
|
|
491
|
-
const hasValidEmail = contactChannels.filter((x) => x.type === "email" && x.isVerified && x.usedForAuth).length > 0;
|
|
492
|
-
if (!project.config.passkeyEnabled) {
|
|
493
|
-
return null;
|
|
494
|
-
}
|
|
495
|
-
const handleDeletePasskey = async () => {
|
|
496
|
-
await user.update({ passkeyAuthEnabled: false });
|
|
497
|
-
setShowConfirmationModal(false);
|
|
498
|
-
};
|
|
499
|
-
const handleAddNewPasskey = async () => {
|
|
500
|
-
await user.registerPasskey();
|
|
501
|
-
};
|
|
502
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Section, { title: t("Passkey"), description: hasPasskey ? t("Passkey registered") : t("Register a passkey"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex md:justify-end gap-2", children: [
|
|
503
|
-
!hasValidEmail && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Typography, { variant: "secondary", type: "label", children: t("To enable Passkey sign-in, please add a verified sign-in email.") }),
|
|
504
|
-
hasValidEmail && hasPasskey && isLastAuth && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Typography, { variant: "secondary", type: "label", children: t("Passkey sign-in is enabled and cannot be disabled as it is currently the only sign-in method") }),
|
|
505
|
-
!hasPasskey && hasValidEmail && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Button, { onClick: handleAddNewPasskey, variant: "secondary", children: t("Add new passkey") }) }),
|
|
506
|
-
hasValidEmail && hasPasskey && !isLastAuth && !showConfirmationModal && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
507
|
-
import_stack_ui.Button,
|
|
508
|
-
{
|
|
509
|
-
variant: "secondary",
|
|
510
|
-
onClick: () => setShowConfirmationModal(true),
|
|
511
|
-
children: t("Delete Passkey")
|
|
512
|
-
}
|
|
513
|
-
),
|
|
514
|
-
hasValidEmail && hasPasskey && !isLastAuth && showConfirmationModal && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex flex-col gap-2", children: [
|
|
515
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Typography, { variant: "destructive", children: t("Are you sure you want to disable Passkey sign-in? You will not be able to sign in with your passkey anymore.") }),
|
|
516
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex gap-2", children: [
|
|
517
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
518
|
-
import_stack_ui.Button,
|
|
519
|
-
{
|
|
520
|
-
variant: "destructive",
|
|
521
|
-
onClick: handleDeletePasskey,
|
|
522
|
-
children: t("Disable")
|
|
523
|
-
}
|
|
524
|
-
),
|
|
525
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
526
|
-
import_stack_ui.Button,
|
|
527
|
-
{
|
|
528
|
-
variant: "secondary",
|
|
529
|
-
onClick: () => setShowConfirmationModal(false),
|
|
530
|
-
children: t("Cancel")
|
|
531
|
-
}
|
|
532
|
-
)
|
|
533
|
-
] })
|
|
534
|
-
] })
|
|
535
|
-
] }) }) });
|
|
536
|
-
}
|
|
537
|
-
function OtpSection() {
|
|
538
|
-
const { t } = (0, import_translations.useTranslation)();
|
|
539
|
-
const user = (0, import__.useUser)({ or: "throw" });
|
|
540
|
-
const project = (0, import__.useStackApp)().useProject();
|
|
541
|
-
const contactChannels = user.useContactChannels();
|
|
542
|
-
const isLastAuth = user.otpAuthEnabled && !user.hasPassword && user.oauthProviders.length === 0 && !user.passkeyAuthEnabled;
|
|
543
|
-
const [disabling, setDisabling] = (0, import_react.useState)(false);
|
|
544
|
-
const hasValidEmail = contactChannels.filter((x) => x.type === "email" && x.isVerified && x.usedForAuth).length > 0;
|
|
545
|
-
if (!project.config.magicLinkEnabled) {
|
|
546
|
-
return null;
|
|
547
|
-
}
|
|
548
|
-
const handleDisableOTP = async () => {
|
|
549
|
-
await user.update({ otpAuthEnabled: false });
|
|
550
|
-
setDisabling(false);
|
|
551
|
-
};
|
|
552
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Section, { title: t("OTP sign-in"), description: user.otpAuthEnabled ? t("OTP/magic link sign-in is currently enabled.") : t("Enable sign-in via magic link or OTP sent to your sign-in emails."), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "flex md:justify-end", children: hasValidEmail ? user.otpAuthEnabled ? !isLastAuth ? !disabling ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
553
|
-
import_stack_ui.Button,
|
|
554
|
-
{
|
|
555
|
-
variant: "secondary",
|
|
556
|
-
onClick: () => setDisabling(true),
|
|
557
|
-
children: t("Disable OTP")
|
|
558
|
-
}
|
|
559
|
-
) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex flex-col gap-2", children: [
|
|
560
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Typography, { variant: "destructive", children: t("Are you sure you want to disable OTP sign-in? You will not be able to sign in with only emails anymore.") }),
|
|
561
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex gap-2", children: [
|
|
562
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
563
|
-
import_stack_ui.Button,
|
|
564
|
-
{
|
|
565
|
-
variant: "destructive",
|
|
566
|
-
onClick: handleDisableOTP,
|
|
567
|
-
children: t("Disable")
|
|
568
|
-
}
|
|
569
|
-
),
|
|
570
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
571
|
-
import_stack_ui.Button,
|
|
572
|
-
{
|
|
573
|
-
variant: "secondary",
|
|
574
|
-
onClick: () => setDisabling(false),
|
|
575
|
-
children: t("Cancel")
|
|
576
|
-
}
|
|
577
|
-
)
|
|
578
|
-
] })
|
|
579
|
-
] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Typography, { variant: "secondary", type: "label", children: t("OTP sign-in is enabled and cannot be disabled as it is currently the only sign-in method") }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
580
|
-
import_stack_ui.Button,
|
|
581
|
-
{
|
|
582
|
-
variant: "secondary",
|
|
583
|
-
onClick: async () => {
|
|
584
|
-
await user.update({ otpAuthEnabled: true });
|
|
585
|
-
},
|
|
586
|
-
children: t("Enable OTP")
|
|
587
|
-
}
|
|
588
|
-
) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Typography, { variant: "secondary", type: "label", children: t("To enable OTP sign-in, please add a verified sign-in email.") }) }) });
|
|
589
|
-
}
|
|
590
|
-
function SettingsPage() {
|
|
151
|
+
function ApiKeysPageSkeleton() {
|
|
591
152
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(PageLayout, { children: [
|
|
592
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
593
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
153
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Skeleton, { className: "h-9 w-full mt-1" }),
|
|
154
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Skeleton, { className: "h-[200px] w-full mt-1 rounded-md" })
|
|
594
155
|
] });
|
|
595
156
|
}
|
|
596
|
-
function
|
|
597
|
-
const { t } = (0, import_translations.useTranslation)();
|
|
598
|
-
const user = (0, import__.useUser)({ or: "throw" });
|
|
599
|
-
const contactChannels = user.useContactChannels();
|
|
600
|
-
const [changingPassword, setChangingPassword] = (0, import_react.useState)(false);
|
|
601
|
-
const [loading, setLoading] = (0, import_react.useState)(false);
|
|
602
|
-
const project = (0, import__.useStackApp)().useProject();
|
|
603
|
-
const passwordSchema = (0, import_schema_fields.yupObject)({
|
|
604
|
-
oldPassword: user.hasPassword ? import_schema_fields.passwordSchema.defined().nonEmpty(t("Please enter your old password")) : (0, import_schema_fields.yupString)(),
|
|
605
|
-
newPassword: import_schema_fields.passwordSchema.defined().nonEmpty(t("Please enter your password")).test({
|
|
606
|
-
name: "is-valid-password",
|
|
607
|
-
test: (value, ctx) => {
|
|
608
|
-
const error = (0, import_password.getPasswordError)(value);
|
|
609
|
-
if (error) {
|
|
610
|
-
return ctx.createError({ message: error.message });
|
|
611
|
-
} else {
|
|
612
|
-
return true;
|
|
613
|
-
}
|
|
614
|
-
}
|
|
615
|
-
}),
|
|
616
|
-
newPasswordRepeat: (0, import_schema_fields.yupString)().nullable().oneOf([yup.ref("newPassword"), "", null], t("Passwords do not match")).defined().nonEmpty(t("Please repeat your password"))
|
|
617
|
-
});
|
|
618
|
-
const { register, handleSubmit, setError, formState: { errors }, clearErrors, reset } = (0, import_react_hook_form.useForm)({
|
|
619
|
-
resolver: (0, import_yup.yupResolver)(passwordSchema)
|
|
620
|
-
});
|
|
621
|
-
const hasValidEmail = contactChannels.filter((x) => x.type === "email" && x.usedForAuth).length > 0;
|
|
622
|
-
const onSubmit = async (data) => {
|
|
623
|
-
setLoading(true);
|
|
624
|
-
try {
|
|
625
|
-
const { oldPassword, newPassword } = data;
|
|
626
|
-
const error = user.hasPassword ? await user.updatePassword({ oldPassword, newPassword }) : await user.setPassword({ password: newPassword });
|
|
627
|
-
if (error) {
|
|
628
|
-
setError("oldPassword", { type: "manual", message: t("Incorrect password") });
|
|
629
|
-
} else {
|
|
630
|
-
reset();
|
|
631
|
-
setChangingPassword(false);
|
|
632
|
-
}
|
|
633
|
-
} finally {
|
|
634
|
-
setLoading(false);
|
|
635
|
-
}
|
|
636
|
-
};
|
|
637
|
-
const registerPassword = register("newPassword");
|
|
638
|
-
const registerPasswordRepeat = register("newPasswordRepeat");
|
|
639
|
-
if (!project.config.credentialEnabled) {
|
|
640
|
-
return null;
|
|
641
|
-
}
|
|
642
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
643
|
-
Section,
|
|
644
|
-
{
|
|
645
|
-
title: t("Password"),
|
|
646
|
-
description: user.hasPassword ? t("Update your password") : t("Set a password for your account"),
|
|
647
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "flex flex-col gap-4", children: !changingPassword ? hasValidEmail ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
648
|
-
import_stack_ui.Button,
|
|
649
|
-
{
|
|
650
|
-
variant: "secondary",
|
|
651
|
-
onClick: () => setChangingPassword(true),
|
|
652
|
-
children: user.hasPassword ? t("Update password") : t("Set password")
|
|
653
|
-
}
|
|
654
|
-
) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Typography, { variant: "secondary", type: "label", children: t("To set a password, please add a sign-in email.") }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
655
|
-
"form",
|
|
656
|
-
{
|
|
657
|
-
onSubmit: (e) => (0, import_promises.runAsynchronouslyWithAlert)(handleSubmit(onSubmit)(e)),
|
|
658
|
-
noValidate: true,
|
|
659
|
-
children: [
|
|
660
|
-
user.hasPassword && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
661
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Label, { htmlFor: "old-password", className: "mb-1", children: t("Old password") }),
|
|
662
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
663
|
-
import_stack_ui.Input,
|
|
664
|
-
{
|
|
665
|
-
id: "old-password",
|
|
666
|
-
type: "password",
|
|
667
|
-
autoComplete: "current-password",
|
|
668
|
-
...register("oldPassword")
|
|
669
|
-
}
|
|
670
|
-
),
|
|
671
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_form_warning.FormWarningText, { text: errors.oldPassword?.message?.toString() })
|
|
672
|
-
] }),
|
|
673
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Label, { htmlFor: "new-password", className: "mt-4 mb-1", children: t("New password") }),
|
|
674
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
675
|
-
import_stack_ui.PasswordInput,
|
|
676
|
-
{
|
|
677
|
-
id: "new-password",
|
|
678
|
-
autoComplete: "new-password",
|
|
679
|
-
...registerPassword,
|
|
680
|
-
onChange: (e) => {
|
|
681
|
-
clearErrors("newPassword");
|
|
682
|
-
clearErrors("newPasswordRepeat");
|
|
683
|
-
(0, import_promises.runAsynchronously)(registerPassword.onChange(e));
|
|
684
|
-
}
|
|
685
|
-
}
|
|
686
|
-
),
|
|
687
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_form_warning.FormWarningText, { text: errors.newPassword?.message?.toString() }),
|
|
688
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Label, { htmlFor: "repeat-password", className: "mt-4 mb-1", children: t("Repeat new password") }),
|
|
689
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
690
|
-
import_stack_ui.PasswordInput,
|
|
691
|
-
{
|
|
692
|
-
id: "repeat-password",
|
|
693
|
-
autoComplete: "new-password",
|
|
694
|
-
...registerPasswordRepeat,
|
|
695
|
-
onChange: (e) => {
|
|
696
|
-
clearErrors("newPassword");
|
|
697
|
-
clearErrors("newPasswordRepeat");
|
|
698
|
-
(0, import_promises.runAsynchronously)(registerPasswordRepeat.onChange(e));
|
|
699
|
-
}
|
|
700
|
-
}
|
|
701
|
-
),
|
|
702
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_form_warning.FormWarningText, { text: errors.newPasswordRepeat?.message?.toString() }),
|
|
703
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "mt-6 flex gap-4", children: [
|
|
704
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Button, { type: "submit", loading, children: user.hasPassword ? t("Update Password") : t("Set Password") }),
|
|
705
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
706
|
-
import_stack_ui.Button,
|
|
707
|
-
{
|
|
708
|
-
variant: "secondary",
|
|
709
|
-
onClick: () => {
|
|
710
|
-
setChangingPassword(false);
|
|
711
|
-
reset();
|
|
712
|
-
},
|
|
713
|
-
children: t("Cancel")
|
|
714
|
-
}
|
|
715
|
-
)
|
|
716
|
-
] })
|
|
717
|
-
]
|
|
718
|
-
}
|
|
719
|
-
) })
|
|
720
|
-
}
|
|
721
|
-
);
|
|
722
|
-
}
|
|
723
|
-
function MfaSection() {
|
|
724
|
-
const { t } = (0, import_translations.useTranslation)();
|
|
725
|
-
const project = (0, import__.useStackApp)().useProject();
|
|
726
|
-
const user = (0, import__.useUser)({ or: "throw" });
|
|
727
|
-
const [generatedSecret, setGeneratedSecret] = (0, import_react.useState)(null);
|
|
728
|
-
const [qrCodeUrl, setQrCodeUrl] = (0, import_react.useState)(null);
|
|
729
|
-
const [mfaCode, setMfaCode] = (0, import_react.useState)("");
|
|
730
|
-
const [isMaybeWrong, setIsMaybeWrong] = (0, import_react.useState)(false);
|
|
731
|
-
const isEnabled = user.isMultiFactorRequired;
|
|
732
|
-
const [handleSubmit, isLoading] = (0, import_use_async_callback.useAsyncCallback)(async () => {
|
|
733
|
-
await user.update({
|
|
734
|
-
totpMultiFactorSecret: generatedSecret
|
|
735
|
-
});
|
|
736
|
-
setGeneratedSecret(null);
|
|
737
|
-
setQrCodeUrl(null);
|
|
738
|
-
setMfaCode("");
|
|
739
|
-
}, [generatedSecret, user]);
|
|
740
|
-
(0, import_react.useEffect)(() => {
|
|
741
|
-
setIsMaybeWrong(false);
|
|
742
|
-
(0, import_promises.runAsynchronouslyWithAlert)(async () => {
|
|
743
|
-
if (generatedSecret && (0, import_otp.verifyTOTP)(generatedSecret, 30, 6, mfaCode)) {
|
|
744
|
-
await handleSubmit();
|
|
745
|
-
}
|
|
746
|
-
setIsMaybeWrong(true);
|
|
747
|
-
});
|
|
748
|
-
}, [mfaCode, generatedSecret, handleSubmit]);
|
|
749
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
750
|
-
Section,
|
|
751
|
-
{
|
|
752
|
-
title: t("Multi-factor authentication"),
|
|
753
|
-
description: isEnabled ? t("Multi-factor authentication is currently enabled.") : t("Multi-factor authentication is currently disabled."),
|
|
754
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex flex-col gap-4", children: [
|
|
755
|
-
!isEnabled && generatedSecret && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
756
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Typography, { children: t("Scan this QR code with your authenticator app:") }),
|
|
757
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("img", { width: 200, height: 200, src: qrCodeUrl ?? (0, import_errors.throwErr)("TOTP QR code failed to generate"), alt: t("TOTP multi-factor authentication QR code") }),
|
|
758
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Typography, { children: t("Then, enter your six-digit MFA code:") }),
|
|
759
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
760
|
-
import_stack_ui.Input,
|
|
761
|
-
{
|
|
762
|
-
value: mfaCode,
|
|
763
|
-
onChange: (e) => {
|
|
764
|
-
setIsMaybeWrong(false);
|
|
765
|
-
setMfaCode(e.target.value);
|
|
766
|
-
},
|
|
767
|
-
placeholder: "123456",
|
|
768
|
-
maxLength: 6,
|
|
769
|
-
disabled: isLoading
|
|
770
|
-
}
|
|
771
|
-
),
|
|
772
|
-
isMaybeWrong && mfaCode.length === 6 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Typography, { variant: "destructive", children: t("Incorrect code. Please try again.") }),
|
|
773
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "flex", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
774
|
-
import_stack_ui.Button,
|
|
775
|
-
{
|
|
776
|
-
variant: "secondary",
|
|
777
|
-
onClick: () => {
|
|
778
|
-
setGeneratedSecret(null);
|
|
779
|
-
setQrCodeUrl(null);
|
|
780
|
-
setMfaCode("");
|
|
781
|
-
},
|
|
782
|
-
children: t("Cancel")
|
|
783
|
-
}
|
|
784
|
-
) })
|
|
785
|
-
] }),
|
|
786
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "flex gap-2", children: isEnabled ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
787
|
-
import_stack_ui.Button,
|
|
788
|
-
{
|
|
789
|
-
variant: "secondary",
|
|
790
|
-
onClick: async () => {
|
|
791
|
-
await user.update({
|
|
792
|
-
totpMultiFactorSecret: null
|
|
793
|
-
});
|
|
794
|
-
},
|
|
795
|
-
children: t("Disable MFA")
|
|
796
|
-
}
|
|
797
|
-
) : !generatedSecret && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
798
|
-
import_stack_ui.Button,
|
|
799
|
-
{
|
|
800
|
-
variant: "secondary",
|
|
801
|
-
onClick: async () => {
|
|
802
|
-
const secret = (0, import_crypto.generateRandomValues)(new Uint8Array(20));
|
|
803
|
-
setQrCodeUrl(await generateTotpQrCode(project, user, secret));
|
|
804
|
-
setGeneratedSecret(secret);
|
|
805
|
-
},
|
|
806
|
-
children: t("Enable MFA")
|
|
807
|
-
}
|
|
808
|
-
) })
|
|
809
|
-
] })
|
|
810
|
-
}
|
|
811
|
-
);
|
|
812
|
-
}
|
|
813
|
-
async function generateTotpQrCode(project, user, secret) {
|
|
814
|
-
const uri = (0, import_otp.createTOTPKeyURI)(project.displayName, user.primaryEmail ?? user.id, secret, 30, 6);
|
|
815
|
-
return await QRCode.toDataURL(uri);
|
|
816
|
-
}
|
|
817
|
-
function SignOutSection() {
|
|
818
|
-
const { t } = (0, import_translations.useTranslation)();
|
|
819
|
-
const user = (0, import__.useUser)({ or: "throw" });
|
|
820
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
821
|
-
Section,
|
|
822
|
-
{
|
|
823
|
-
title: t("Sign out"),
|
|
824
|
-
description: t("End your current session"),
|
|
825
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
826
|
-
import_stack_ui.Button,
|
|
827
|
-
{
|
|
828
|
-
variant: "secondary",
|
|
829
|
-
onClick: () => user.signOut(),
|
|
830
|
-
children: t("Sign out")
|
|
831
|
-
}
|
|
832
|
-
) })
|
|
833
|
-
}
|
|
834
|
-
);
|
|
835
|
-
}
|
|
836
|
-
function TeamPage(props) {
|
|
157
|
+
function TeamPageSkeleton() {
|
|
837
158
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(PageLayout, { children: [
|
|
838
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
839
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
840
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
841
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
842
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(TeamDisplayNameSection, { team: props.team }),
|
|
843
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(LeaveTeamSection, { team: props.team })
|
|
844
|
-
] });
|
|
845
|
-
}
|
|
846
|
-
function LeaveTeamSection(props) {
|
|
847
|
-
const { t } = (0, import_translations.useTranslation)();
|
|
848
|
-
const user = (0, import__.useUser)({ or: "redirect" });
|
|
849
|
-
const [leaving, setLeaving] = (0, import_react.useState)(false);
|
|
850
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
851
|
-
Section,
|
|
852
|
-
{
|
|
853
|
-
title: t("Leave Team"),
|
|
854
|
-
description: t("leave this team and remove your team profile"),
|
|
855
|
-
children: !leaving ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
856
|
-
import_stack_ui.Button,
|
|
857
|
-
{
|
|
858
|
-
variant: "secondary",
|
|
859
|
-
onClick: () => setLeaving(true),
|
|
860
|
-
children: t("Leave team")
|
|
861
|
-
}
|
|
862
|
-
) }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex flex-col gap-2", children: [
|
|
863
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Typography, { variant: "destructive", children: t("Are you sure you want to leave the team?") }),
|
|
864
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex gap-2", children: [
|
|
865
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
866
|
-
import_stack_ui.Button,
|
|
867
|
-
{
|
|
868
|
-
variant: "destructive",
|
|
869
|
-
onClick: async () => {
|
|
870
|
-
await user.leaveTeam(props.team);
|
|
871
|
-
window.location.reload();
|
|
872
|
-
},
|
|
873
|
-
children: t("Leave")
|
|
874
|
-
}
|
|
875
|
-
),
|
|
876
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
877
|
-
import_stack_ui.Button,
|
|
878
|
-
{
|
|
879
|
-
variant: "secondary",
|
|
880
|
-
onClick: () => setLeaving(false),
|
|
881
|
-
children: t("Cancel")
|
|
882
|
-
}
|
|
883
|
-
)
|
|
884
|
-
] })
|
|
885
|
-
] })
|
|
886
|
-
}
|
|
887
|
-
);
|
|
888
|
-
}
|
|
889
|
-
function TeamProfileImageSection(props) {
|
|
890
|
-
const { t } = (0, import_translations.useTranslation)();
|
|
891
|
-
const user = (0, import__.useUser)({ or: "redirect" });
|
|
892
|
-
const updateTeamPermission = user.usePermission(props.team, "$update_team");
|
|
893
|
-
if (!updateTeamPermission) {
|
|
894
|
-
return null;
|
|
895
|
-
}
|
|
896
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
897
|
-
Section,
|
|
898
|
-
{
|
|
899
|
-
title: t("Team profile image"),
|
|
900
|
-
description: t("Upload an image for your team"),
|
|
901
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
902
|
-
import_profile_image_editor.ProfileImageEditor,
|
|
903
|
-
{
|
|
904
|
-
user: props.team,
|
|
905
|
-
onProfileImageUrlChange: async (profileImageUrl) => {
|
|
906
|
-
await props.team.update({ profileImageUrl });
|
|
907
|
-
}
|
|
908
|
-
}
|
|
909
|
-
)
|
|
910
|
-
}
|
|
911
|
-
);
|
|
912
|
-
}
|
|
913
|
-
function TeamDisplayNameSection(props) {
|
|
914
|
-
const { t } = (0, import_translations.useTranslation)();
|
|
915
|
-
const user = (0, import__.useUser)({ or: "redirect" });
|
|
916
|
-
const updateTeamPermission = user.usePermission(props.team, "$update_team");
|
|
917
|
-
if (!updateTeamPermission) {
|
|
918
|
-
return null;
|
|
919
|
-
}
|
|
920
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
921
|
-
Section,
|
|
922
|
-
{
|
|
923
|
-
title: t("Team display name"),
|
|
924
|
-
description: t("Change the display name of your team"),
|
|
925
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
926
|
-
EditableText,
|
|
927
|
-
{
|
|
928
|
-
value: props.team.displayName,
|
|
929
|
-
onSave: async (newDisplayName) => await props.team.update({ displayName: newDisplayName })
|
|
930
|
-
}
|
|
931
|
-
)
|
|
932
|
-
}
|
|
933
|
-
);
|
|
934
|
-
}
|
|
935
|
-
function TeamUserProfileSection(props) {
|
|
936
|
-
const { t } = (0, import_translations.useTranslation)();
|
|
937
|
-
const user = (0, import__.useUser)({ or: "redirect" });
|
|
938
|
-
const profile = user.useTeamProfile(props.team);
|
|
939
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
940
|
-
Section,
|
|
941
|
-
{
|
|
942
|
-
title: t("Team user name"),
|
|
943
|
-
description: t("Overwrite your user display name in this team"),
|
|
944
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
945
|
-
EditableText,
|
|
946
|
-
{
|
|
947
|
-
value: profile.displayName || "",
|
|
948
|
-
onSave: async (newDisplayName) => {
|
|
949
|
-
await profile.update({ displayName: newDisplayName });
|
|
950
|
-
}
|
|
951
|
-
}
|
|
952
|
-
)
|
|
953
|
-
}
|
|
954
|
-
);
|
|
955
|
-
}
|
|
956
|
-
function MemberInvitationSection(props) {
|
|
957
|
-
const user = (0, import__.useUser)({ or: "redirect" });
|
|
958
|
-
const inviteMemberPermission = user.usePermission(props.team, "$invite_members");
|
|
959
|
-
if (!inviteMemberPermission) {
|
|
960
|
-
return null;
|
|
961
|
-
}
|
|
962
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MemberInvitationSectionInner, { team: props.team });
|
|
963
|
-
}
|
|
964
|
-
function MemberInvitationsSectionInvitationsList(props) {
|
|
965
|
-
const user = (0, import__.useUser)({ or: "redirect" });
|
|
966
|
-
const { t } = (0, import_translations.useTranslation)();
|
|
967
|
-
const invitationsToShow = props.team.useInvitations();
|
|
968
|
-
const removeMemberPermission = user.usePermission(props.team, "$remove_members");
|
|
969
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_stack_ui.Table, { className: "mt-6", children: [
|
|
970
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.TableHeader, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_stack_ui.TableRow, { children: [
|
|
971
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.TableHead, { className: "w-[200px]", children: t("Outstanding invitations") }),
|
|
972
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.TableHead, { className: "w-[60px]", children: t("Expires") }),
|
|
973
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.TableHead, { className: "w-[36px] max-w-[36px]" })
|
|
974
|
-
] }) }),
|
|
975
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.TableBody, { children: invitationsToShow.map((invitation, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_stack_ui.TableRow, { children: [
|
|
976
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.TableCell, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Typography, { children: invitation.recipientEmail }) }),
|
|
977
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.TableCell, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Typography, { variant: "secondary", children: invitation.expiresAt.toLocaleString() }) }),
|
|
978
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.TableCell, { align: "right", className: "max-w-[36px]", children: removeMemberPermission && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Button, { onClick: async () => await invitation.revoke(), size: "icon", variant: "ghost", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.Trash, { className: "w-4 h-4" }) }) })
|
|
979
|
-
] }, invitation.id)) })
|
|
980
|
-
] }) });
|
|
981
|
-
}
|
|
982
|
-
function MemberInvitationSectionInner(props) {
|
|
983
|
-
const user = (0, import__.useUser)({ or: "redirect" });
|
|
984
|
-
const { t } = (0, import_translations.useTranslation)();
|
|
985
|
-
const readMemberPermission = user.usePermission(props.team, "$read_members");
|
|
986
|
-
const invitationSchema = (0, import_schema_fields.yupObject)({
|
|
987
|
-
email: (0, import_schema_fields.strictEmailSchema)(t("Please enter a valid email address")).defined().nonEmpty(t("Please enter an email address"))
|
|
988
|
-
});
|
|
989
|
-
const { register, handleSubmit, formState: { errors }, watch } = (0, import_react_hook_form.useForm)({
|
|
990
|
-
resolver: (0, import_yup.yupResolver)(invitationSchema)
|
|
991
|
-
});
|
|
992
|
-
const [loading, setLoading] = (0, import_react.useState)(false);
|
|
993
|
-
const [invitedEmail, setInvitedEmail] = (0, import_react.useState)(null);
|
|
994
|
-
const onSubmit = async (data) => {
|
|
995
|
-
setLoading(true);
|
|
996
|
-
try {
|
|
997
|
-
await props.team.inviteUser({ email: data.email });
|
|
998
|
-
setInvitedEmail(data.email);
|
|
999
|
-
} finally {
|
|
1000
|
-
setLoading(false);
|
|
1001
|
-
}
|
|
1002
|
-
};
|
|
1003
|
-
(0, import_react.useEffect)(() => {
|
|
1004
|
-
setInvitedEmail(null);
|
|
1005
|
-
}, [watch("email")]);
|
|
1006
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
1007
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1008
|
-
Section,
|
|
1009
|
-
{
|
|
1010
|
-
title: t("Invite member"),
|
|
1011
|
-
description: t("Invite a user to your team through email"),
|
|
1012
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1013
|
-
"form",
|
|
1014
|
-
{
|
|
1015
|
-
onSubmit: (e) => (0, import_promises.runAsynchronouslyWithAlert)(handleSubmit(onSubmit)(e)),
|
|
1016
|
-
noValidate: true,
|
|
1017
|
-
className: "w-full",
|
|
1018
|
-
children: [
|
|
1019
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex flex-col gap-4 sm:flex-row w-full", children: [
|
|
1020
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1021
|
-
import_stack_ui.Input,
|
|
1022
|
-
{
|
|
1023
|
-
placeholder: t("Email"),
|
|
1024
|
-
...register("email")
|
|
1025
|
-
}
|
|
1026
|
-
),
|
|
1027
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Button, { type: "submit", loading, children: t("Invite User") })
|
|
1028
|
-
] }),
|
|
1029
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_form_warning.FormWarningText, { text: errors.email?.message?.toString() }),
|
|
1030
|
-
invitedEmail && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_stack_ui.Typography, { type: "label", variant: "secondary", children: [
|
|
1031
|
-
"Invited ",
|
|
1032
|
-
invitedEmail
|
|
1033
|
-
] })
|
|
1034
|
-
]
|
|
1035
|
-
}
|
|
1036
|
-
)
|
|
1037
|
-
}
|
|
1038
|
-
),
|
|
1039
|
-
readMemberPermission && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MemberInvitationsSectionInvitationsList, { team: props.team })
|
|
159
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Skeleton, { className: "h-9 w-full mt-1" }),
|
|
160
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Skeleton, { className: "h-9 w-full mt-1" }),
|
|
161
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Skeleton, { className: "h-9 w-full mt-1" }),
|
|
162
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Skeleton, { className: "h-[200px] w-full mt-1 rounded-md" })
|
|
1040
163
|
] });
|
|
1041
164
|
}
|
|
1042
|
-
function
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
if (!readMemberPermission && !inviteMemberPermission) {
|
|
1047
|
-
return null;
|
|
1048
|
-
}
|
|
1049
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MemberListSectionInner, { team: props.team });
|
|
1050
|
-
}
|
|
1051
|
-
function MemberListSectionInner(props) {
|
|
1052
|
-
const { t } = (0, import_translations.useTranslation)();
|
|
1053
|
-
const users = props.team.useUsers();
|
|
1054
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
|
|
1055
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Typography, { className: "font-medium mb-2", children: t("Members") }),
|
|
1056
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "border rounded-md", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_stack_ui.Table, { children: [
|
|
1057
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.TableHeader, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_stack_ui.TableRow, { children: [
|
|
1058
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.TableHead, { className: "w-[100px]", children: t("User") }),
|
|
1059
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.TableHead, { className: "w-[200px]", children: t("Name") })
|
|
1060
|
-
] }) }),
|
|
1061
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.TableBody, { children: users.map(({ id, teamProfile }, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_stack_ui.TableRow, { children: [
|
|
1062
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.TableCell, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_user_avatar.UserAvatar, { user: teamProfile }) }),
|
|
1063
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.TableCell, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Typography, { children: teamProfile.displayName }) })
|
|
1064
|
-
] }, id)) })
|
|
1065
|
-
] }) })
|
|
165
|
+
function TeamCreationSkeleton() {
|
|
166
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(PageLayout, { children: [
|
|
167
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Skeleton, { className: "h-9 w-full mt-1" }),
|
|
168
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Skeleton, { className: "h-9 w-full mt-1" })
|
|
1066
169
|
] });
|
|
1067
170
|
}
|
|
1068
|
-
function TeamCreation() {
|
|
1069
|
-
const { t } = (0, import_translations.useTranslation)();
|
|
1070
|
-
const teamCreationSchema = (0, import_schema_fields.yupObject)({
|
|
1071
|
-
displayName: (0, import_schema_fields.yupString)().defined().nonEmpty(t("Please enter a team name"))
|
|
1072
|
-
});
|
|
1073
|
-
const { register, handleSubmit, formState: { errors } } = (0, import_react_hook_form.useForm)({
|
|
1074
|
-
resolver: (0, import_yup.yupResolver)(teamCreationSchema)
|
|
1075
|
-
});
|
|
1076
|
-
const app = (0, import__.useStackApp)();
|
|
1077
|
-
const project = app.useProject();
|
|
1078
|
-
const user = (0, import__.useUser)({ or: "redirect" });
|
|
1079
|
-
const navigate = app.useNavigate();
|
|
1080
|
-
const [loading, setLoading] = (0, import_react.useState)(false);
|
|
1081
|
-
if (!project.config.clientTeamCreationEnabled) {
|
|
1082
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.MessageCard, { title: t("Team creation is not enabled") });
|
|
1083
|
-
}
|
|
1084
|
-
const onSubmit = async (data) => {
|
|
1085
|
-
setLoading(true);
|
|
1086
|
-
let team;
|
|
1087
|
-
try {
|
|
1088
|
-
team = await user.createTeam({ displayName: data.displayName });
|
|
1089
|
-
} finally {
|
|
1090
|
-
setLoading(false);
|
|
1091
|
-
}
|
|
1092
|
-
navigate(`#team-${team.id}`);
|
|
1093
|
-
};
|
|
1094
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PageLayout, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Section, { title: t("Create a Team"), description: t("Enter a display name for your new team"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1095
|
-
"form",
|
|
1096
|
-
{
|
|
1097
|
-
onSubmit: (e) => (0, import_promises.runAsynchronouslyWithAlert)(handleSubmit(onSubmit)(e)),
|
|
1098
|
-
noValidate: true,
|
|
1099
|
-
className: "flex gap-2 flex-col sm:flex-row",
|
|
1100
|
-
children: [
|
|
1101
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex flex-col flex-1", children: [
|
|
1102
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1103
|
-
import_stack_ui.Input,
|
|
1104
|
-
{
|
|
1105
|
-
id: "displayName",
|
|
1106
|
-
type: "text",
|
|
1107
|
-
...register("displayName")
|
|
1108
|
-
}
|
|
1109
|
-
),
|
|
1110
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_form_warning.FormWarningText, { text: errors.displayName?.message?.toString() })
|
|
1111
|
-
] }),
|
|
1112
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Button, { type: "submit", loading, children: t("Create") })
|
|
1113
|
-
]
|
|
1114
|
-
}
|
|
1115
|
-
) }) });
|
|
1116
|
-
}
|
|
1117
|
-
function DeleteAccountSection() {
|
|
1118
|
-
const { t } = (0, import_translations.useTranslation)();
|
|
1119
|
-
const user = (0, import__.useUser)({ or: "redirect" });
|
|
1120
|
-
const app = (0, import__.useStackApp)();
|
|
1121
|
-
const project = app.useProject();
|
|
1122
|
-
const [deleting, setDeleting] = (0, import_react.useState)(false);
|
|
1123
|
-
if (!project.config.clientUserDeletionEnabled) {
|
|
1124
|
-
return null;
|
|
1125
|
-
}
|
|
1126
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1127
|
-
Section,
|
|
1128
|
-
{
|
|
1129
|
-
title: t("Delete Account"),
|
|
1130
|
-
description: t("Permanently remove your account and all associated data"),
|
|
1131
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "stack-scope flex flex-col items-stretch", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Accordion, { type: "single", collapsible: true, className: "w-full", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_stack_ui.AccordionItem, { value: "item-1", children: [
|
|
1132
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.AccordionTrigger, { children: t("Danger zone") }),
|
|
1133
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.AccordionContent, { children: !deleting ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1134
|
-
import_stack_ui.Button,
|
|
1135
|
-
{
|
|
1136
|
-
variant: "destructive",
|
|
1137
|
-
onClick: () => setDeleting(true),
|
|
1138
|
-
children: t("Delete account")
|
|
1139
|
-
}
|
|
1140
|
-
) }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex flex-col gap-2", children: [
|
|
1141
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Typography, { variant: "destructive", children: t("Are you sure you want to delete your account? This action is IRREVERSIBLE and will delete ALL associated data.") }),
|
|
1142
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex gap-2", children: [
|
|
1143
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1144
|
-
import_stack_ui.Button,
|
|
1145
|
-
{
|
|
1146
|
-
variant: "destructive",
|
|
1147
|
-
onClick: async () => {
|
|
1148
|
-
await user.delete();
|
|
1149
|
-
await app.redirectToHome();
|
|
1150
|
-
},
|
|
1151
|
-
children: t("Delete Account")
|
|
1152
|
-
}
|
|
1153
|
-
),
|
|
1154
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1155
|
-
import_stack_ui.Button,
|
|
1156
|
-
{
|
|
1157
|
-
variant: "secondary",
|
|
1158
|
-
onClick: () => setDeleting(false),
|
|
1159
|
-
children: t("Cancel")
|
|
1160
|
-
}
|
|
1161
|
-
)
|
|
1162
|
-
] })
|
|
1163
|
-
] }) })
|
|
1164
|
-
] }) }) })
|
|
1165
|
-
}
|
|
1166
|
-
);
|
|
1167
|
-
}
|
|
1168
|
-
function EditableText(props) {
|
|
1169
|
-
const [editing, setEditing] = (0, import_react.useState)(false);
|
|
1170
|
-
const [editingValue, setEditingValue] = (0, import_react.useState)(props.value);
|
|
1171
|
-
const { t } = (0, import_translations.useTranslation)();
|
|
1172
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "flex items-center gap-2", children: editing ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
1173
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1174
|
-
import_stack_ui.Input,
|
|
1175
|
-
{
|
|
1176
|
-
value: editingValue,
|
|
1177
|
-
onChange: (e) => setEditingValue(e.target.value)
|
|
1178
|
-
}
|
|
1179
|
-
),
|
|
1180
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1181
|
-
import_stack_ui.Button,
|
|
1182
|
-
{
|
|
1183
|
-
size: "sm",
|
|
1184
|
-
onClick: async () => {
|
|
1185
|
-
await props.onSave?.(editingValue);
|
|
1186
|
-
setEditing(false);
|
|
1187
|
-
},
|
|
1188
|
-
children: t("Save")
|
|
1189
|
-
}
|
|
1190
|
-
),
|
|
1191
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1192
|
-
import_stack_ui.Button,
|
|
1193
|
-
{
|
|
1194
|
-
size: "sm",
|
|
1195
|
-
variant: "secondary",
|
|
1196
|
-
onClick: () => {
|
|
1197
|
-
setEditingValue(props.value);
|
|
1198
|
-
setEditing(false);
|
|
1199
|
-
},
|
|
1200
|
-
children: t("Cancel")
|
|
1201
|
-
}
|
|
1202
|
-
)
|
|
1203
|
-
] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
1204
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Typography, { children: props.value }),
|
|
1205
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stack_ui.Button, { onClick: () => setEditing(true), size: "icon", variant: "ghost", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.Edit, { className: "w-4 h-4" }) })
|
|
1206
|
-
] }) });
|
|
1207
|
-
}
|
|
1208
171
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1209
172
|
0 && (module.exports = {
|
|
1210
|
-
AccountSettings
|
|
1211
|
-
EditableText
|
|
173
|
+
AccountSettings
|
|
1212
174
|
});
|
|
1213
175
|
//# sourceMappingURL=account-settings.js.map
|