@zango-core/appbuilder 1.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ConfigurePage-DRzSb06z.js +29 -0
- package/dist/ConfigurePage-DRzSb06z.js.map +1 -0
- package/dist/LoginPageWithRoleSelection-xTr_eIWh.js +662 -0
- package/dist/LoginPageWithRoleSelection-xTr_eIWh.js.map +1 -0
- package/dist/PageTypeRegistry-5269IpiS.js +53 -0
- package/dist/PageTypeRegistry-5269IpiS.js.map +1 -0
- package/dist/index.framework-B8SMzgN1.js +28005 -0
- package/dist/index.framework-B8SMzgN1.js.map +1 -0
- package/dist/types/App.d.ts +14 -0
- package/dist/types/__tests__/mocks/data/appInitData.d.ts +197 -0
- package/dist/types/__tests__/mocks/data/authConfigData.d.ts +356 -0
- package/dist/types/__tests__/mocks/externalPackages.d.ts +42 -0
- package/dist/types/__tests__/mocks/handlers/appInit.handlers.d.ts +3 -0
- package/dist/types/__tests__/mocks/handlers/auth.handlers.d.ts +1 -0
- package/dist/types/__tests__/mocks/handlers/index.d.ts +5 -0
- package/dist/types/__tests__/mocks/handlers/profile.handlers.d.ts +15 -0
- package/dist/types/__tests__/mocks/handlers/session.handlers.d.ts +2 -0
- package/dist/types/__tests__/setup/setupDOMMatchers.d.ts +0 -0
- package/dist/types/__tests__/setup/setupMSW.d.ts +1 -0
- package/dist/types/__tests__/setup/setupTests.d.ts +34 -0
- package/dist/types/__tests__/utils/mockRouterUtils.d.ts +62 -0
- package/dist/types/__tests__/utils/renderWithProviders.d.ts +22 -0
- package/dist/types/__tests__/utils/waitForHelpers.d.ts +36 -0
- package/dist/types/auth/components/AuthMobileShell.d.ts +8 -0
- package/dist/types/auth/components/AuthProvider.d.ts +30 -0
- package/dist/types/auth/components/DynamicLoginForm.d.ts +9 -0
- package/dist/types/auth/components/ForgotPasswordForm.d.ts +11 -0
- package/dist/types/auth/components/LoginForm.d.ts +7 -0
- package/dist/types/auth/components/LoginRouter.d.ts +197 -0
- package/dist/types/auth/components/OAuthCallback.d.ts +19 -0
- package/dist/types/auth/components/OTPForm.d.ts +11 -0
- package/dist/types/auth/components/OTPInput.d.ts +8 -0
- package/dist/types/auth/components/PasswordResetRequired.d.ts +23 -0
- package/dist/types/auth/components/ProviderButton.d.ts +17 -0
- package/dist/types/auth/components/ResetPasswordForm.d.ts +12 -0
- package/dist/types/auth/components/RoleSelection.d.ts +25 -0
- package/dist/types/auth/components/SecondFactorAuth.d.ts +21 -0
- package/dist/types/auth/components/composable/OTPLoginForm.d.ts +17 -0
- package/dist/types/auth/components/composable/PasswordLoginForm.d.ts +17 -0
- package/dist/types/auth/components/composable/SSOButtons.d.ts +61 -0
- package/dist/types/auth/components/composable/index.d.ts +42 -0
- package/dist/types/auth/contexts/LoginContext.d.ts +6 -0
- package/dist/types/auth/hocs/withMultiStepAuth.d.ts +35 -0
- package/dist/types/auth/index.d.ts +23 -0
- package/dist/types/auth/pages/CompleteAuthFlow.d.ts +24 -0
- package/dist/types/auth/pages/LoginPage.d.ts +8 -0
- package/dist/types/auth/pages/LoginPageWithRoleSelection.d.ts +13 -0
- package/dist/types/auth/pages/OAuthCallbackPage.d.ts +17 -0
- package/dist/types/auth/pages/SAMLCallbackPage.d.ts +16 -0
- package/dist/types/auth/services/authService.d.ts +87 -0
- package/dist/types/auth/services/internal/apiClients.d.ts +9 -0
- package/dist/types/auth/services/internal/authState.d.ts +12 -0
- package/dist/types/auth/services/internal/errorHelper.d.ts +1 -0
- package/dist/types/auth/services/internal/oauthSamlService.d.ts +46 -0
- package/dist/types/auth/services/internal/passwordValidator.d.ts +17 -0
- package/dist/types/auth/services/network/api.d.ts +1629 -0
- package/dist/types/auth/services/network/base.d.ts +31 -0
- package/dist/types/auth/services/network/configuration.d.ts +74 -0
- package/dist/types/auth/services/network/index.d.ts +13 -0
- package/dist/types/auth/stores/index.d.ts +1 -0
- package/dist/types/auth/stores/useAuthStore.d.ts +6 -0
- package/dist/types/auth/types/index.d.ts +57 -0
- package/dist/types/auth/utils/authFlowHandler.d.ts +72 -0
- package/dist/types/auth/utils/authUtils.d.ts +21 -0
- package/dist/types/auth/utils/validators.d.ts +18 -0
- package/dist/types/components/ErrorBoundary.d.ts +23 -0
- package/dist/types/components/ErrorFallback.d.ts +8 -0
- package/dist/types/components/index.d.ts +1 -0
- package/dist/types/components/ui/avatar.d.ts +11 -0
- package/dist/types/components/ui/button.d.ts +10 -0
- package/dist/types/components/ui/collapsible.d.ts +5 -0
- package/dist/types/components/ui/dialog.d.ts +13 -0
- package/dist/types/components/ui/dropdown-menu.d.ts +10 -0
- package/dist/types/components/ui/empty.d.ts +8 -0
- package/dist/types/components/ui/index.d.ts +12 -0
- package/dist/types/components/ui/input.d.ts +3 -0
- package/dist/types/components/ui/separator.d.ts +4 -0
- package/dist/types/components/ui/sheet.d.ts +14 -0
- package/dist/types/components/ui/sidebar.d.ts +69 -0
- package/dist/types/components/ui/skeleton.d.ts +2 -0
- package/dist/types/components/ui/tooltip.d.ts +7 -0
- package/dist/types/framework/ZangoApp.d.ts +19 -0
- package/dist/types/framework/components/CachedLogo.d.ts +9 -0
- package/dist/types/framework/components/CustomPageFallback.d.ts +13 -0
- package/dist/types/framework/components/CustomPageLoader.d.ts +10 -0
- package/dist/types/framework/components/DocumentHead.d.ts +5 -0
- package/dist/types/framework/components/RouteErrorBoundary.d.ts +16 -0
- package/dist/types/framework/components/SessionSecurityDialog.d.ts +10 -0
- package/dist/types/framework/components/SessionSecurityProvider.d.ts +8 -0
- package/dist/types/framework/components/SmartLink.d.ts +13 -0
- package/dist/types/framework/components/layout/AppSidebar.d.ts +36 -0
- package/dist/types/framework/components/layout/Breadcrumbs.d.ts +2 -0
- package/dist/types/framework/components/layout/CommandPalette.d.ts +2 -0
- package/dist/types/framework/components/layout/Layout.d.ts +2 -0
- package/dist/types/framework/components/layout/Navbar.d.ts +9 -0
- package/dist/types/framework/components/layout/NavbarIcon.d.ts +12 -0
- package/dist/types/framework/components/layout/Topbar.d.ts +50 -0
- package/dist/types/framework/components/layout/UserProfileDrawer.d.ts +7 -0
- package/dist/types/framework/components/layout/profile/PasswordCard.d.ts +18 -0
- package/dist/types/framework/components/layout/profile/PersonalInfoCard.d.ts +12 -0
- package/dist/types/framework/components/layout/profile/ProfileRail.d.ts +23 -0
- package/dist/types/framework/components/layout/profile/SessionsCard.d.ts +8 -0
- package/dist/types/framework/components/layout/profile/TokensCard.d.ts +11 -0
- package/dist/types/framework/components/layout/profile/TwoFactorCard.d.ts +7 -0
- package/dist/types/framework/config/defaultLayoutConfig.d.ts +34 -0
- package/dist/types/framework/constants/routes.d.ts +5 -0
- package/dist/types/framework/contexts/AppContext.d.ts +57 -0
- package/dist/types/framework/contexts/AuthConfigContext.d.ts +22 -0
- package/dist/types/framework/hooks/useProfileData.d.ts +73 -0
- package/dist/types/framework/hooks/useRoutes.d.ts +10 -0
- package/dist/types/framework/hooks/useSessionSecurity.d.ts +17 -0
- package/dist/types/framework/hooks/useSmartNavigation.d.ts +15 -0
- package/dist/types/framework/index.d.ts +35 -0
- package/dist/types/framework/pages/ConfigurePage.d.ts +2 -0
- package/dist/types/framework/pages/CrudPage.d.ts +6 -0
- package/dist/types/framework/pages/LoginPage.d.ts +5 -0
- package/dist/types/framework/pages/LogoutPage.d.ts +2 -0
- package/dist/types/framework/pages/NotFoundPage.d.ts +6 -0
- package/dist/types/framework/pages/TrainingPage.d.ts +6 -0
- package/dist/types/framework/routing/PageTypeRegistry.d.ts +43 -0
- package/dist/types/framework/routing/PageTypeRouter.d.ts +12 -0
- package/dist/types/framework/routing/dynamicPageRegistry.d.ts +41 -0
- package/dist/types/framework/routing/getRenderComponent.d.ts +6 -0
- package/dist/types/framework/types/layout.types.d.ts +107 -0
- package/dist/types/framework/utils/apiConfig.d.ts +41 -0
- package/dist/types/framework/utils/apiInterceptor.d.ts +12 -0
- package/dist/types/framework/utils/apiUrlUtils.d.ts +9 -0
- package/dist/types/framework/utils/authThemeUtils.d.ts +64 -0
- package/dist/types/framework/utils/colorUtils.d.ts +53 -0
- package/dist/types/framework/utils/cookieUtils.d.ts +20 -0
- package/dist/types/framework/utils/csrf.d.ts +27 -0
- package/dist/types/framework/utils/logoCache.d.ts +21 -0
- package/dist/types/framework/utils/logoutUtils.d.ts +15 -0
- package/dist/types/framework/utils/redirectUtils.d.ts +48 -0
- package/dist/types/framework/utils/safeRedirect.d.ts +21 -0
- package/dist/types/framework/utils/storageKeys.d.ts +44 -0
- package/dist/types/framework/utils/storageSanitizer.d.ts +20 -0
- package/dist/types/hooks/index.d.ts +2 -0
- package/dist/types/hooks/queries/index.d.ts +4 -0
- package/dist/types/hooks/queries/useAppInitQuery.d.ts +1 -0
- package/dist/types/hooks/queries/useAuthConfigQuery.d.ts +1 -0
- package/dist/types/hooks/queries/useProfileQuery.d.ts +8 -0
- package/dist/types/hooks/useBreakpoint.d.ts +2 -0
- package/dist/types/hooks/useMobile.d.ts +1 -0
- package/dist/types/index.d.ts +0 -0
- package/dist/types/index.framework.d.ts +39 -0
- package/dist/types/index.zango.d.ts +12 -0
- package/dist/types/lib/index.d.ts +1 -0
- package/dist/types/lib/utils.d.ts +2 -0
- package/dist/types/schemas/appInit.schema.d.ts +61 -0
- package/dist/types/schemas/index.d.ts +10 -0
- package/dist/types/schemas/profile.schema.d.ts +18 -0
- package/dist/types/schemas/route.schema.d.ts +9 -0
- package/dist/types/schemas/session.schema.d.ts +8 -0
- package/dist/types/schemas/theme.schema.d.ts +27 -0
- package/dist/types/services/api/index.d.ts +2 -0
- package/dist/types/services/api.d.ts +109 -0
- package/dist/types/services/index.d.ts +7 -0
- package/dist/types/services/legacyAdapter.d.ts +10 -0
- package/dist/types/services/logger.d.ts +32 -0
- package/dist/types/services/normalizeResponse.d.ts +29 -0
- package/dist/types/types/auth.d.ts +103 -0
- package/dist/types/types/common.d.ts +343 -0
- package/dist/types/types/index.d.ts +278 -0
- package/dist/zango-appbuilder.js +99 -0
- package/dist/zango-appbuilder.js.map +1 -0
- package/dist/zango-appbuilder.umd.cjs +247 -0
- package/dist/zango-appbuilder.umd.cjs.map +1 -0
- package/package.json +140 -0
|
@@ -0,0 +1,662 @@
|
|
|
1
|
+
import { jsx as e, jsxs as n, Fragment as ge } from "react/jsx-runtime";
|
|
2
|
+
import { Spin as ie, Button as J, FormItem as N, PasswordInput as te, toast as j, Alert as ce, Divider as Y, Tabs as ke, Form as ye, Input as we, Checkbox as ve, Select as Ae, Space as Te, Layout as Q, Card as fe } from "@zango-core/components";
|
|
3
|
+
import Me, { useState as u, useCallback as me, useEffect as ne, useRef as Fe, useLayoutEffect as Ue } from "react";
|
|
4
|
+
import { b as ue, c as he, g as Ne, d as Pe, e as _e, f as a, l as se, O as oe, P as M, M as Ie, S as qe, p as de, h as De, u as Ce, i as Se, j as je, k as xe, m as Be, n as Ke, o as We, s as pe, q as be, A as Ee, r as $e } from "./index.framework-B8SMzgN1.js";
|
|
5
|
+
import { Link as Le, useSearchParams as ze } from "react-router-dom";
|
|
6
|
+
const Ve = ({ onLogin: g, showRememberMe: y = !0 }) => {
|
|
7
|
+
const [h, m] = u(!1), [B, f] = u(null), [, l] = u(null), [O, P] = u("email"), [i, R] = u(!1), [F, k] = u(0), [U, A] = u(!1), [V, r] = u(!1), [p, _] = u(""), [K, I] = u(""), { authConfig: d } = ue(), { getLoginConfig: o, getMessagesConfig: c, getProvidersConfig: q, authConfig: W } = he(), $ = W || d, G = Ne($), X = Pe($), le = _e($), Z = me(async () => {
|
|
8
|
+
try {
|
|
9
|
+
return await a.isAuthenticated();
|
|
10
|
+
} catch {
|
|
11
|
+
return !1;
|
|
12
|
+
}
|
|
13
|
+
}, []);
|
|
14
|
+
if (ne(() => {
|
|
15
|
+
if (d) {
|
|
16
|
+
const s = a.isPasswordLoginEnabled() ? "password" : a.isOTPLoginEnabled() ? "otp" : null;
|
|
17
|
+
s && l(s);
|
|
18
|
+
const t = a.getAllowedUsernamesForMethod(s ?? "password");
|
|
19
|
+
if (t && t.length > 0) {
|
|
20
|
+
const x = t.includes("email"), S = t.includes("mobile");
|
|
21
|
+
x ? P("email") : S && P("mobile");
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}, [d]), ne(() => {
|
|
25
|
+
(async () => {
|
|
26
|
+
const t = await Z();
|
|
27
|
+
A(t);
|
|
28
|
+
})();
|
|
29
|
+
}, [Z]), !d)
|
|
30
|
+
return /* @__PURE__ */ e("div", { className: "flex justify-center items-center min-h-loading-min-h", children: /* @__PURE__ */ e(ie, { size: "large" }) });
|
|
31
|
+
const ae = (s) => {
|
|
32
|
+
const t = c();
|
|
33
|
+
return s === "email" ? [
|
|
34
|
+
{
|
|
35
|
+
required: !0,
|
|
36
|
+
message: t?.validation?.required || "Please enter your email address"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
type: "email",
|
|
40
|
+
message: t?.validation?.invalidEmail || "Please enter a valid email address!"
|
|
41
|
+
}
|
|
42
|
+
] : s === "mobile" ? [
|
|
43
|
+
{
|
|
44
|
+
required: !0,
|
|
45
|
+
message: t?.validation?.required || "Please input your mobile number!"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
pattern: /^\+\d{7,15}$/,
|
|
49
|
+
message: t?.validation?.invalidMobile || "Please enter a valid mobile number with country code (e.g., +919876543210)"
|
|
50
|
+
}
|
|
51
|
+
] : [
|
|
52
|
+
{
|
|
53
|
+
required: !0,
|
|
54
|
+
message: t?.validation?.required || "Please enter your email address"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
type: "email",
|
|
58
|
+
message: t?.validation?.invalidEmail || "Please enter a valid email address!"
|
|
59
|
+
}
|
|
60
|
+
];
|
|
61
|
+
}, ee = (s) => {
|
|
62
|
+
!["Backspace", "Delete", "Tab", "Enter", "ArrowLeft", "ArrowRight"].includes(s.key) && !s.ctrlKey && !s.metaKey && !/[0-9+]/.test(s.key) && s.preventDefault();
|
|
63
|
+
}, re = async (s) => {
|
|
64
|
+
m(!0), f(null);
|
|
65
|
+
try {
|
|
66
|
+
const t = a.getAllowedUsernames(), x = t.includes("email"), S = t.includes("mobile"), E = x && S ? O : x ? "email" : "mobile", D = {
|
|
67
|
+
email: E === "email" ? s.username : void 0,
|
|
68
|
+
phone: E === "mobile" ? s.username : void 0,
|
|
69
|
+
password: s.password,
|
|
70
|
+
remember_me: s.remember || !1
|
|
71
|
+
};
|
|
72
|
+
await g(D);
|
|
73
|
+
} catch (t) {
|
|
74
|
+
const x = c(), S = (t instanceof Error ? t.message : null) || x?.errors?.loginFailed || "Login failed. Please try again.";
|
|
75
|
+
f(S);
|
|
76
|
+
} finally {
|
|
77
|
+
m(!1);
|
|
78
|
+
}
|
|
79
|
+
}, w = async (s) => {
|
|
80
|
+
await g(s);
|
|
81
|
+
}, C = async () => {
|
|
82
|
+
m(!0);
|
|
83
|
+
try {
|
|
84
|
+
await a.logout(), j.success("Logged out successfully"), A(!1);
|
|
85
|
+
} catch (s) {
|
|
86
|
+
j.error(s instanceof Error ? s.message : "Failed to logout");
|
|
87
|
+
} finally {
|
|
88
|
+
m(!1);
|
|
89
|
+
}
|
|
90
|
+
}, T = async () => {
|
|
91
|
+
if (!p || !K) {
|
|
92
|
+
j.error("Please fill in all password fields");
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
if (p !== K) {
|
|
96
|
+
j.error("Passwords do not match");
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
if (p.length < 8) {
|
|
100
|
+
j.error("Password must be at least 8 characters long");
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
m(!0);
|
|
104
|
+
try {
|
|
105
|
+
await a.setPassword(p), j.success("Password changed successfully!"), r(!1), _(""), I("");
|
|
106
|
+
} catch (s) {
|
|
107
|
+
j.error(s instanceof Error ? s.message : "Failed to change password");
|
|
108
|
+
} finally {
|
|
109
|
+
m(!1);
|
|
110
|
+
}
|
|
111
|
+
}, z = (s) => {
|
|
112
|
+
const t = o(), x = c();
|
|
113
|
+
return /* @__PURE__ */ n(
|
|
114
|
+
ye,
|
|
115
|
+
{
|
|
116
|
+
name: `${s}-password-login`,
|
|
117
|
+
className: "w-full",
|
|
118
|
+
onFinish: re,
|
|
119
|
+
layout: "vertical",
|
|
120
|
+
initialValues: { remember: !1 },
|
|
121
|
+
children: [
|
|
122
|
+
B && /* @__PURE__ */ e(ce, { message: B, type: "error", showIcon: !0, closable: !0, onClose: () => f(null), className: "mb-4" }),
|
|
123
|
+
/* @__PURE__ */ e(N, { name: "username", rules: ae(s), children: /* @__PURE__ */ e(
|
|
124
|
+
we,
|
|
125
|
+
{
|
|
126
|
+
placeholder: s === "email" ? t?.formPlaceholders?.email || "Enter your email address" : t?.formPlaceholders?.mobile || "Enter your mobile number (+919876543210)",
|
|
127
|
+
autoComplete: s === "email" ? "email" : "tel",
|
|
128
|
+
onKeyDown: s === "mobile" ? ee : void 0
|
|
129
|
+
}
|
|
130
|
+
) }),
|
|
131
|
+
/* @__PURE__ */ e(
|
|
132
|
+
N,
|
|
133
|
+
{
|
|
134
|
+
name: "password",
|
|
135
|
+
rules: [
|
|
136
|
+
{
|
|
137
|
+
required: !0,
|
|
138
|
+
// validation.required is worded for the identifier field, so it
|
|
139
|
+
// must not be reused under the password input.
|
|
140
|
+
message: x?.validation?.passwordRequired || "Please input your password!"
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
...de(
|
|
144
|
+
d?.password_policy ?? null
|
|
145
|
+
),
|
|
146
|
+
message: x?.validation?.passwordTooShort || de(
|
|
147
|
+
d?.password_policy ?? null
|
|
148
|
+
).message
|
|
149
|
+
}
|
|
150
|
+
],
|
|
151
|
+
children: /* @__PURE__ */ e(
|
|
152
|
+
te,
|
|
153
|
+
{
|
|
154
|
+
placeholder: t?.formPlaceholders?.password || "Enter your password",
|
|
155
|
+
autoComplete: "current-password"
|
|
156
|
+
}
|
|
157
|
+
)
|
|
158
|
+
}
|
|
159
|
+
),
|
|
160
|
+
/* @__PURE__ */ e(N, { children: /* @__PURE__ */ n("div", { className: "flex justify-between items-center w-full", children: [
|
|
161
|
+
/* @__PURE__ */ e("div", { children: t?.showRememberMe !== !1 && y && a.isRememberMeEnabled() && /* @__PURE__ */ e(N, { name: "remember", valuePropName: "checked", noStyle: !0, children: /* @__PURE__ */ e("div", { className: "auth-remember-me", style: X, children: /* @__PURE__ */ e(ve, { label: t?.rememberMeText || "Remember me" }) }) }) }),
|
|
162
|
+
/* @__PURE__ */ e("div", { children: a.isForgotPasswordEnabled() && /* @__PURE__ */ e(Le, { to: "forgot-password", className: "text-sm transition-colors duration-300", style: le, children: t?.forgotPasswordText || "Forgot password?" }) })
|
|
163
|
+
] }) }),
|
|
164
|
+
/* @__PURE__ */ e(N, { children: /* @__PURE__ */ e(
|
|
165
|
+
J,
|
|
166
|
+
{
|
|
167
|
+
variant: "primary",
|
|
168
|
+
type: "submit",
|
|
169
|
+
className: "w-full text-base font-medium",
|
|
170
|
+
disabled: h,
|
|
171
|
+
fullWidth: !0,
|
|
172
|
+
children: h ? /* @__PURE__ */ n("span", { className: "inline-flex items-center gap-2", children: [
|
|
173
|
+
/* @__PURE__ */ e(De, { size: 16, className: "animate-spin" }),
|
|
174
|
+
t?.submitButtonText || "Sign in"
|
|
175
|
+
] }) : t?.submitButtonText || "Sign in"
|
|
176
|
+
}
|
|
177
|
+
) })
|
|
178
|
+
]
|
|
179
|
+
},
|
|
180
|
+
`${s}-${F}`
|
|
181
|
+
);
|
|
182
|
+
}, H = () => {
|
|
183
|
+
if (!a.isOTPLoginEnabled()) return null;
|
|
184
|
+
const s = o();
|
|
185
|
+
return i ? /* @__PURE__ */ e(oe, { onSuccess: w, onBack: () => R(!1) }) : /* @__PURE__ */ e(
|
|
186
|
+
J,
|
|
187
|
+
{
|
|
188
|
+
variant: "secondary",
|
|
189
|
+
fullWidth: !0,
|
|
190
|
+
onClick: () => R(!0),
|
|
191
|
+
className: "bg-gray-100 border-gray-300",
|
|
192
|
+
children: s?.otpButtonText || "Sign in with OTP"
|
|
193
|
+
}
|
|
194
|
+
);
|
|
195
|
+
}, Oe = () => {
|
|
196
|
+
if (!d)
|
|
197
|
+
return null;
|
|
198
|
+
const s = a.getAllowedUsernames(), t = s.includes("email"), x = s.includes("mobile"), S = a.isSSOEnabled() || a.isOIDCEnabled(), E = a.isPasswordLoginEnabled(), D = a.isOTPLoginEnabled();
|
|
199
|
+
if (!E && !D && !S)
|
|
200
|
+
return se.error("[Auth] No login method is enabled in the auth config", void 0, {
|
|
201
|
+
enabledMethods: a.getEnabledLoginMethods()
|
|
202
|
+
}), /* @__PURE__ */ e(
|
|
203
|
+
ce,
|
|
204
|
+
{
|
|
205
|
+
type: "warning",
|
|
206
|
+
showIcon: !1,
|
|
207
|
+
message: "No sign-in method is configured. Please contact your administrator."
|
|
208
|
+
}
|
|
209
|
+
);
|
|
210
|
+
if (i && D && E)
|
|
211
|
+
return /* @__PURE__ */ e("div", { className: "w-full", children: /* @__PURE__ */ e(oe, { onSuccess: w, onBack: () => R(!1) }) });
|
|
212
|
+
if (S && !E && !D)
|
|
213
|
+
return /* @__PURE__ */ n("div", { className: "w-full", children: [
|
|
214
|
+
a.isSSOEnabled() && /* @__PURE__ */ e("div", { className: "mb-4", children: /* @__PURE__ */ e("div", { className: "space-y-2", children: a.getSSOProviders().map((L) => /* @__PURE__ */ e(M, { provider: L, type: "sso" }, L.id)) }) }),
|
|
215
|
+
a.isOIDCEnabled() && /* @__PURE__ */ e("div", { className: "space-y-2", children: a.getOIDCProviders().map((L) => /* @__PURE__ */ e(M, { provider: L, type: "oidc" }, L.id)) })
|
|
216
|
+
] });
|
|
217
|
+
if (D && !E) {
|
|
218
|
+
const L = q();
|
|
219
|
+
return /* @__PURE__ */ n("div", { className: "w-full", children: [
|
|
220
|
+
/* @__PURE__ */ e(oe, { onSuccess: w }),
|
|
221
|
+
S && /* @__PURE__ */ n("div", { className: "mt-6", children: [
|
|
222
|
+
/* @__PURE__ */ e(Y, { children: L?.separatorText || "OR" }),
|
|
223
|
+
a.isSSOEnabled() && /* @__PURE__ */ e("div", { className: "mb-4", children: /* @__PURE__ */ e("div", { className: "space-y-2", children: a.getSSOProviders().map((b) => /* @__PURE__ */ e(M, { provider: b, type: "sso" }, b.id)) }) }),
|
|
224
|
+
a.isOIDCEnabled() && /* @__PURE__ */ e("div", { className: "mt-4", children: /* @__PURE__ */ e("div", { className: "space-y-2", children: a.getOIDCProviders().map((b) => /* @__PURE__ */ e(M, { provider: b, type: "oidc" }, b.id)) }) })
|
|
225
|
+
] })
|
|
226
|
+
] });
|
|
227
|
+
}
|
|
228
|
+
if (t && x && E) {
|
|
229
|
+
const L = o(), b = q();
|
|
230
|
+
return /* @__PURE__ */ e("div", { className: "w-full", children: /* @__PURE__ */ e(
|
|
231
|
+
ke,
|
|
232
|
+
{
|
|
233
|
+
className: "login-tabs",
|
|
234
|
+
activeKey: O,
|
|
235
|
+
onChange: (v) => {
|
|
236
|
+
P(v), k((Re) => Re + 1), f(null);
|
|
237
|
+
},
|
|
238
|
+
items: [
|
|
239
|
+
{
|
|
240
|
+
key: "email",
|
|
241
|
+
label: /* @__PURE__ */ n("span", { className: "flex items-center gap-1", style: G, children: [
|
|
242
|
+
/* @__PURE__ */ e(Ie, { size: 16 }),
|
|
243
|
+
L?.tabLabels?.email || "Email"
|
|
244
|
+
] }),
|
|
245
|
+
children: /* @__PURE__ */ n(ge, { children: [
|
|
246
|
+
z("email"),
|
|
247
|
+
D && E && !i && /* @__PURE__ */ n("div", { className: "mt-6", children: [
|
|
248
|
+
/* @__PURE__ */ e(Y, { children: b?.separatorText || "OR" }),
|
|
249
|
+
H()
|
|
250
|
+
] }),
|
|
251
|
+
i && H(),
|
|
252
|
+
!i && S && /* @__PURE__ */ n("div", { className: "mt-6", children: [
|
|
253
|
+
/* @__PURE__ */ e(Y, { children: b?.separatorText || "OR" }),
|
|
254
|
+
a.isSSOEnabled() && /* @__PURE__ */ e("div", { className: "mb-4", children: /* @__PURE__ */ e("div", { className: "space-y-2", children: a.getSSOProviders().map(
|
|
255
|
+
(v) => /* @__PURE__ */ e(M, { provider: v, type: "sso" }, v.id)
|
|
256
|
+
) }) }),
|
|
257
|
+
a.isOIDCEnabled() && /* @__PURE__ */ e("div", { className: "mt-4", children: /* @__PURE__ */ e("div", { className: "space-y-2", children: a.getOIDCProviders().map(
|
|
258
|
+
(v) => /* @__PURE__ */ e(M, { provider: v, type: "oidc" }, v.id)
|
|
259
|
+
) }) })
|
|
260
|
+
] })
|
|
261
|
+
] })
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
key: "mobile",
|
|
265
|
+
label: /* @__PURE__ */ n("span", { className: "flex items-center gap-1", style: G, children: [
|
|
266
|
+
/* @__PURE__ */ e(qe, { size: 16 }),
|
|
267
|
+
L?.tabLabels?.mobile || "Mobile"
|
|
268
|
+
] }),
|
|
269
|
+
children: /* @__PURE__ */ n(ge, { children: [
|
|
270
|
+
z("mobile"),
|
|
271
|
+
D && E && !i && /* @__PURE__ */ n("div", { className: "mt-6", children: [
|
|
272
|
+
/* @__PURE__ */ e(Y, { children: "OR" }),
|
|
273
|
+
H()
|
|
274
|
+
] }),
|
|
275
|
+
i && H(),
|
|
276
|
+
!i && S && /* @__PURE__ */ n("div", { className: "mt-6", children: [
|
|
277
|
+
/* @__PURE__ */ e(Y, { children: "OR" }),
|
|
278
|
+
a.isSSOEnabled() && /* @__PURE__ */ e("div", { className: "mb-4", children: /* @__PURE__ */ e("div", { className: "space-y-2", children: a.getSSOProviders().map(
|
|
279
|
+
(v) => /* @__PURE__ */ e(M, { provider: v, type: "sso" }, v.id)
|
|
280
|
+
) }) }),
|
|
281
|
+
a.isOIDCEnabled() && /* @__PURE__ */ e("div", { className: "mt-4", children: /* @__PURE__ */ e("div", { className: "space-y-2", children: a.getOIDCProviders().map(
|
|
282
|
+
(v) => /* @__PURE__ */ e(M, { provider: v, type: "oidc" }, v.id)
|
|
283
|
+
) }) })
|
|
284
|
+
] })
|
|
285
|
+
] })
|
|
286
|
+
}
|
|
287
|
+
]
|
|
288
|
+
}
|
|
289
|
+
) });
|
|
290
|
+
} else
|
|
291
|
+
return /* @__PURE__ */ n("div", { className: "w-full", children: [
|
|
292
|
+
z(t ? "email" : "mobile"),
|
|
293
|
+
D && E && !i && /* @__PURE__ */ n("div", { className: "mt-6", children: [
|
|
294
|
+
/* @__PURE__ */ e(Y, { children: "OR" }),
|
|
295
|
+
H()
|
|
296
|
+
] }),
|
|
297
|
+
i && H(),
|
|
298
|
+
!i && S && /* @__PURE__ */ n("div", { className: "mt-6", children: [
|
|
299
|
+
/* @__PURE__ */ e(Y, { children: "OR" }),
|
|
300
|
+
a.isSSOEnabled() && /* @__PURE__ */ e("div", { className: "mb-4", children: /* @__PURE__ */ e("div", { className: "space-y-2", children: a.getSSOProviders().map((b) => /* @__PURE__ */ e(M, { provider: b, type: "sso" }, b.id)) }) }),
|
|
301
|
+
a.isOIDCEnabled() && /* @__PURE__ */ e("div", { className: "mt-4", children: /* @__PURE__ */ e("div", { className: "space-y-2", children: a.getOIDCProviders().map((b) => /* @__PURE__ */ e(M, { provider: b, type: "oidc" }, b.id)) }) })
|
|
302
|
+
] })
|
|
303
|
+
] });
|
|
304
|
+
};
|
|
305
|
+
return d ? U ? /* @__PURE__ */ e("div", { className: "w-full", children: V ? /* @__PURE__ */ n("div", { className: "space-y-4", children: [
|
|
306
|
+
/* @__PURE__ */ e("h4", { className: "text-base font-medium mb-4", children: "Change Your Password" }),
|
|
307
|
+
/* @__PURE__ */ e(N, { label: "New Password", children: /* @__PURE__ */ e(
|
|
308
|
+
te,
|
|
309
|
+
{
|
|
310
|
+
value: p,
|
|
311
|
+
onChange: (s) => _(s.target.value),
|
|
312
|
+
placeholder: "Enter new password",
|
|
313
|
+
disabled: h
|
|
314
|
+
}
|
|
315
|
+
) }),
|
|
316
|
+
/* @__PURE__ */ e(N, { label: "Confirm Password", children: /* @__PURE__ */ e(
|
|
317
|
+
te,
|
|
318
|
+
{
|
|
319
|
+
value: K,
|
|
320
|
+
onChange: (s) => I(s.target.value),
|
|
321
|
+
placeholder: "Confirm new password",
|
|
322
|
+
disabled: h
|
|
323
|
+
}
|
|
324
|
+
) }),
|
|
325
|
+
/* @__PURE__ */ n("div", { className: "flex gap-2", children: [
|
|
326
|
+
/* @__PURE__ */ e(J, { type: "primary", onClick: T, loading: h, className: "flex-1", children: "Change Password" }),
|
|
327
|
+
/* @__PURE__ */ e(
|
|
328
|
+
J,
|
|
329
|
+
{
|
|
330
|
+
onClick: () => {
|
|
331
|
+
r(!1), _(""), I("");
|
|
332
|
+
},
|
|
333
|
+
disabled: h,
|
|
334
|
+
className: "flex-1",
|
|
335
|
+
children: "Cancel"
|
|
336
|
+
}
|
|
337
|
+
)
|
|
338
|
+
] })
|
|
339
|
+
] }) : /* @__PURE__ */ n("div", { className: "space-y-4", children: [
|
|
340
|
+
/* @__PURE__ */ n("div", { className: "text-center mb-4", children: [
|
|
341
|
+
/* @__PURE__ */ e("h3", { className: "text-lg font-medium", style: G, children: "Already Logged In" }),
|
|
342
|
+
/* @__PURE__ */ e("p", { className: "text-sm mt-2", style: X, children: "You are currently logged in." })
|
|
343
|
+
] }),
|
|
344
|
+
/* @__PURE__ */ e(J, { block: !0, onClick: () => r(!0), children: "Change Password" }),
|
|
345
|
+
/* @__PURE__ */ e(J, { block: !0, danger: !0, onClick: C, loading: h, children: "Logout" })
|
|
346
|
+
] }) }) : Oe() : /* @__PURE__ */ e("div", { className: "flex justify-center items-center min-h-loading-min-h", children: /* @__PURE__ */ e(ie, { size: "large" }) });
|
|
347
|
+
}, Ye = ({ onLogin: g, showRememberMe: y = !0, showForgotPassword: h = !0 }) => {
|
|
348
|
+
const [m, B] = u(!1), [f] = u(0), [l, O] = u("email"), { authConfig: P } = ue();
|
|
349
|
+
ne(() => {
|
|
350
|
+
if (P) {
|
|
351
|
+
const r = a.getAllowedUsernames();
|
|
352
|
+
r && r.length > 0 && O(r[0]);
|
|
353
|
+
}
|
|
354
|
+
}, [P]);
|
|
355
|
+
const i = async (r) => {
|
|
356
|
+
B(!0);
|
|
357
|
+
try {
|
|
358
|
+
if (g) {
|
|
359
|
+
const p = {
|
|
360
|
+
email: l === "email" ? r.username : void 0,
|
|
361
|
+
phone: l === "mobile" ? r.username : void 0,
|
|
362
|
+
username: r.username,
|
|
363
|
+
password: r.password,
|
|
364
|
+
remember_me: r.remember || !1
|
|
365
|
+
};
|
|
366
|
+
await g(p);
|
|
367
|
+
}
|
|
368
|
+
} catch (p) {
|
|
369
|
+
j.error(p instanceof Error ? p.message : "Login failed. Please try again.");
|
|
370
|
+
} finally {
|
|
371
|
+
B(!1);
|
|
372
|
+
}
|
|
373
|
+
}, R = () => {
|
|
374
|
+
switch (l) {
|
|
375
|
+
case "email":
|
|
376
|
+
return "Email address";
|
|
377
|
+
case "mobile":
|
|
378
|
+
return "Phone number";
|
|
379
|
+
case "username":
|
|
380
|
+
return "Username";
|
|
381
|
+
default:
|
|
382
|
+
return "Username";
|
|
383
|
+
}
|
|
384
|
+
}, F = () => {
|
|
385
|
+
const r = [{ required: !0, message: `Please input your ${l}!` }];
|
|
386
|
+
switch (l) {
|
|
387
|
+
case "email":
|
|
388
|
+
return [...r, { type: "email", message: "Please enter a valid email address!" }];
|
|
389
|
+
case "mobile":
|
|
390
|
+
return [...r, { pattern: /^\+?[1-9]\d{1,14}$/, message: "Please enter a valid phone number!" }];
|
|
391
|
+
case "username":
|
|
392
|
+
return [...r, { min: 3, message: "Username must be at least 3 characters long" }];
|
|
393
|
+
default:
|
|
394
|
+
return r;
|
|
395
|
+
}
|
|
396
|
+
};
|
|
397
|
+
if (!P)
|
|
398
|
+
return /* @__PURE__ */ e("div", { className: "flex justify-center items-center min-h-loading-min-h", children: "Loading..." });
|
|
399
|
+
const k = a.getAllowedUsernames(), U = k.length > 1, A = a.isRememberMeEnabled(), V = a.isForgotPasswordEnabled();
|
|
400
|
+
return /* @__PURE__ */ n(
|
|
401
|
+
ye,
|
|
402
|
+
{
|
|
403
|
+
name: "login",
|
|
404
|
+
className: "w-full space-y-4",
|
|
405
|
+
initialValues: { remember: !1 },
|
|
406
|
+
onFinish: (r) => i(r),
|
|
407
|
+
autoComplete: "off",
|
|
408
|
+
layout: "vertical",
|
|
409
|
+
children: [
|
|
410
|
+
U && /* @__PURE__ */ e(N, { label: "Login with", className: "mb-4", children: /* @__PURE__ */ e(
|
|
411
|
+
Ae,
|
|
412
|
+
{
|
|
413
|
+
value: l,
|
|
414
|
+
onChange: (r) => O(String(r)),
|
|
415
|
+
options: k.map((r) => ({
|
|
416
|
+
value: r,
|
|
417
|
+
label: r === "mobile" ? "Phone" : r.charAt(0).toUpperCase() + r.slice(1)
|
|
418
|
+
}))
|
|
419
|
+
}
|
|
420
|
+
) }),
|
|
421
|
+
/* @__PURE__ */ e(N, { name: "username", rules: F(), children: /* @__PURE__ */ e(
|
|
422
|
+
we,
|
|
423
|
+
{
|
|
424
|
+
className: "w-full",
|
|
425
|
+
placeholder: R(),
|
|
426
|
+
autoComplete: l === "email" ? "email" : "username"
|
|
427
|
+
}
|
|
428
|
+
) }),
|
|
429
|
+
/* @__PURE__ */ e(
|
|
430
|
+
N,
|
|
431
|
+
{
|
|
432
|
+
name: "password",
|
|
433
|
+
rules: [
|
|
434
|
+
{ required: !0, message: "Please input your password!" },
|
|
435
|
+
de(P?.password_policy)
|
|
436
|
+
],
|
|
437
|
+
children: /* @__PURE__ */ e(te, { className: "w-full", placeholder: "Password", autoComplete: "current-password" })
|
|
438
|
+
}
|
|
439
|
+
),
|
|
440
|
+
/* @__PURE__ */ e(N, { children: /* @__PURE__ */ n(Te, { className: "flex justify-between items-center w-full", children: [
|
|
441
|
+
y && A && /* @__PURE__ */ e(N, { name: "remember", valuePropName: "checked", noStyle: !0, children: /* @__PURE__ */ e(ve, { label: "Remember me" }) }),
|
|
442
|
+
h && V && /* @__PURE__ */ e(Le, { to: "forgot-password", className: "text-brand-500 text-sm hover:text-brand-600 transition-colors", children: "Forgot password?" })
|
|
443
|
+
] }) }),
|
|
444
|
+
/* @__PURE__ */ e(N, { children: /* @__PURE__ */ e(J, { variant: "primary", type: "submit", className: "w-full text-base font-medium", disabled: m, fullWidth: !0, children: "Log in" }) })
|
|
445
|
+
]
|
|
446
|
+
},
|
|
447
|
+
f
|
|
448
|
+
);
|
|
449
|
+
}, Je = ({
|
|
450
|
+
onLogin: g,
|
|
451
|
+
logo: y,
|
|
452
|
+
title: h,
|
|
453
|
+
subtitle: m,
|
|
454
|
+
apiConfig: B = {},
|
|
455
|
+
useDynamicConfig: f = !0,
|
|
456
|
+
staticConfig: l = null
|
|
457
|
+
}) => {
|
|
458
|
+
const [O] = ze(), [P, i] = u(null), [R, F] = u(f), [k, U] = u(null), A = Fe(!1), { appLogo: V, appName: r } = Ce(), p = Se(), _ = O.get("token"), K = O.get("request_id"), I = !!(_ && K);
|
|
459
|
+
Ue(() => {
|
|
460
|
+
if (A.current)
|
|
461
|
+
return;
|
|
462
|
+
const w = sessionStorage.getItem("saml_error");
|
|
463
|
+
if (w) {
|
|
464
|
+
A.current = !0, sessionStorage.removeItem("saml_error");
|
|
465
|
+
try {
|
|
466
|
+
const C = JSON.parse(w);
|
|
467
|
+
j.error(C.message, {
|
|
468
|
+
duration: 5e3
|
|
469
|
+
});
|
|
470
|
+
} catch (C) {
|
|
471
|
+
se.error("Failed to parse SAML error", C);
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
}, []);
|
|
475
|
+
const { authConfig: d, getCustomComponents: o } = he(), c = o(), q = je(d), W = xe(d), $ = Ne(d), G = Pe(d), X = Be(d), le = Ke(d), Z = c?.LoginPage, ae = c?.LoginCard, ee = me(async () => {
|
|
476
|
+
try {
|
|
477
|
+
const w = await a.getAuthConfig();
|
|
478
|
+
i(w), U(null);
|
|
479
|
+
} catch (w) {
|
|
480
|
+
se.error("Failed to fetch login methods", w), i({
|
|
481
|
+
login_methods: {
|
|
482
|
+
password: {
|
|
483
|
+
enabled: !0,
|
|
484
|
+
allowed_usernames: ["email"]
|
|
485
|
+
},
|
|
486
|
+
otp: { enabled: !1 },
|
|
487
|
+
sso: { enabled: !1 },
|
|
488
|
+
oidc: { enabled: !1 }
|
|
489
|
+
},
|
|
490
|
+
password_policy: {
|
|
491
|
+
min_length: 8,
|
|
492
|
+
reset: {
|
|
493
|
+
enabled: !0
|
|
494
|
+
}
|
|
495
|
+
},
|
|
496
|
+
session_policy: {
|
|
497
|
+
remember_me_enabled: !0,
|
|
498
|
+
remember_me_duration_days: 30
|
|
499
|
+
}
|
|
500
|
+
}), U(null), se.warn("Using default auth configuration due to config fetch failure");
|
|
501
|
+
} finally {
|
|
502
|
+
F(!1);
|
|
503
|
+
}
|
|
504
|
+
}, []);
|
|
505
|
+
if (ne(() => {
|
|
506
|
+
f && !l ? ee() : l && (i(l), F(!1));
|
|
507
|
+
}, [f, l, ee]), I)
|
|
508
|
+
return /* @__PURE__ */ e(
|
|
509
|
+
We,
|
|
510
|
+
{
|
|
511
|
+
logo: y,
|
|
512
|
+
title: h || "Processing Authentication",
|
|
513
|
+
subtitle: m || "Please wait while we complete your login",
|
|
514
|
+
onAuthComplete: (w) => {
|
|
515
|
+
const C = w?.redirect_url || "/app";
|
|
516
|
+
try {
|
|
517
|
+
const T = new URL(C, window.location.origin);
|
|
518
|
+
T.searchParams.delete("token"), T.searchParams.delete("request_id");
|
|
519
|
+
const z = T.pathname + (T.search ? T.search : "");
|
|
520
|
+
pe(z);
|
|
521
|
+
} catch {
|
|
522
|
+
pe(C);
|
|
523
|
+
}
|
|
524
|
+
},
|
|
525
|
+
roleSelectionTitle: "Select Your Role",
|
|
526
|
+
roleSelectionSubtitle: "Choose a role to continue",
|
|
527
|
+
twoFactorTitle: "Two-Factor Authentication",
|
|
528
|
+
twoFactorSubtitle: "For your security, please verify your identity",
|
|
529
|
+
passwordResetTitle: "Password Update Required",
|
|
530
|
+
passwordResetSubtitle: "Please create a new password to continue"
|
|
531
|
+
}
|
|
532
|
+
);
|
|
533
|
+
const re = () => R ? /* @__PURE__ */ e("div", { className: "flex justify-center items-center min-h-loading-min-h", children: /* @__PURE__ */ e(ie, { size: "large", tip: "Loading login methods..." }) }) : k ? /* @__PURE__ */ e(
|
|
534
|
+
ce,
|
|
535
|
+
{
|
|
536
|
+
message: "Error",
|
|
537
|
+
description: k,
|
|
538
|
+
type: "error",
|
|
539
|
+
showIcon: !0,
|
|
540
|
+
action: /* @__PURE__ */ e("button", { type: "button", onClick: ee, children: "Retry" })
|
|
541
|
+
}
|
|
542
|
+
) : P && f ? /* @__PURE__ */ e(Ve, { onLogin: g }) : /* @__PURE__ */ e(Ye, { onLogin: g });
|
|
543
|
+
return Z && !_ && !K ? /* @__PURE__ */ e(be.Provider, { value: { onLogin: g || (() => {
|
|
544
|
+
}) }, children: /* @__PURE__ */ e(Z, {}) }) : ae ? /* @__PURE__ */ e(be.Provider, { value: { onLogin: g || (() => {
|
|
545
|
+
}) }, children: /* @__PURE__ */ e(Q, { className: "min-h-screen", style: W, children: /* @__PURE__ */ e(Q.Content, { className: "flex justify-center items-center min-h-screen p-5", children: /* @__PURE__ */ e(fe, { className: "w-full max-w-md", bordered: !1, style: q, children: /* @__PURE__ */ e(ae, {}) }) }) }) }) : p ? /* @__PURE__ */ n(Ee, { appName: r, appLogo: typeof y == "string" ? y : V, children: [
|
|
546
|
+
/* @__PURE__ */ n("div", { className: "text-center mb-[22px]", children: [
|
|
547
|
+
(() => {
|
|
548
|
+
const C = (h || "Welcome Back").trim().split(/\s+/), T = C.pop(), z = C.join(" ");
|
|
549
|
+
return /* @__PURE__ */ n("h1", { className: "mb-2", style: $, children: [
|
|
550
|
+
z ? `${z} ` : "",
|
|
551
|
+
/* @__PURE__ */ n("em", { className: "accent", children: [
|
|
552
|
+
T,
|
|
553
|
+
"."
|
|
554
|
+
] })
|
|
555
|
+
] });
|
|
556
|
+
})(),
|
|
557
|
+
m && /* @__PURE__ */ e("p", { className: "text-sm", style: G, children: m })
|
|
558
|
+
] }),
|
|
559
|
+
re()
|
|
560
|
+
] }) : /* @__PURE__ */ e(Q, { className: "min-h-screen", style: W, children: /* @__PURE__ */ e(Q.Content, { className: "flex justify-center items-center min-h-screen p-5", children: /* @__PURE__ */ n(fe, { className: "w-full max-w-md", bordered: !1, style: q, children: [
|
|
561
|
+
y && /* @__PURE__ */ e("div", { className: X.className, style: X.style, children: typeof y == "string" ? /* @__PURE__ */ e(
|
|
562
|
+
"img",
|
|
563
|
+
{
|
|
564
|
+
src: y,
|
|
565
|
+
alt: d?.logo?.alt || "Logo",
|
|
566
|
+
className: "max-w-logo-max-w h-auto",
|
|
567
|
+
style: le
|
|
568
|
+
}
|
|
569
|
+
) : y }),
|
|
570
|
+
/* @__PURE__ */ n("div", { className: "text-center mb-[18px]", children: [
|
|
571
|
+
/* @__PURE__ */ e("h1", { className: "text-3xl font-semibold mb-2", style: $, children: h || "Welcome Back" }),
|
|
572
|
+
m && /* @__PURE__ */ e("p", { className: "text-base", style: G, children: m })
|
|
573
|
+
] }),
|
|
574
|
+
re()
|
|
575
|
+
] }) }) });
|
|
576
|
+
}, { Content: Ge } = Q, as = ({
|
|
577
|
+
logo: g,
|
|
578
|
+
title: y,
|
|
579
|
+
subtitle: h,
|
|
580
|
+
apiConfig: m,
|
|
581
|
+
useDynamicConfig: B = !0,
|
|
582
|
+
staticConfig: f = null,
|
|
583
|
+
onLoginSuccess: l,
|
|
584
|
+
roleSelectionTitle: O,
|
|
585
|
+
roleSelectionSubtitle: P,
|
|
586
|
+
initialAuthResult: i = null
|
|
587
|
+
}) => {
|
|
588
|
+
const { pendingAuth: R, availableRoles: F, login: k, processAuthResult: U } = ue(), [, A] = u(null), V = Se(), { appName: r, appLogo: p } = Ce(), { getCustomComponents: _ } = he(), K = _()?.LoginPage ? "custom" : _()?.LoginCard ? "card" : "default", I = me(
|
|
589
|
+
async (o) => {
|
|
590
|
+
A(null);
|
|
591
|
+
try {
|
|
592
|
+
if (o && (o.status || o.data || o.next_step || o.response)) {
|
|
593
|
+
const W = U(o);
|
|
594
|
+
if (W?.requiresRoleSelection)
|
|
595
|
+
return;
|
|
596
|
+
if (W?.autoSelectedRole) {
|
|
597
|
+
const $ = await a.selectRole(W.autoSelectedRole.id);
|
|
598
|
+
l && l($);
|
|
599
|
+
return;
|
|
600
|
+
}
|
|
601
|
+
l && l(o);
|
|
602
|
+
return;
|
|
603
|
+
}
|
|
604
|
+
const c = await k(o), q = {
|
|
605
|
+
email: o.email,
|
|
606
|
+
username: o.username,
|
|
607
|
+
phone: o.phone,
|
|
608
|
+
// Use whichever credential was provided
|
|
609
|
+
display: o.email || o.username || o.phone
|
|
610
|
+
};
|
|
611
|
+
if (c.requiresRoleSelection)
|
|
612
|
+
return;
|
|
613
|
+
l && l({ ...c, loginUser: q });
|
|
614
|
+
} catch (c) {
|
|
615
|
+
const q = c instanceof Error ? c.message : "Login failed";
|
|
616
|
+
throw A(q), c;
|
|
617
|
+
}
|
|
618
|
+
},
|
|
619
|
+
[k, U, l]
|
|
620
|
+
);
|
|
621
|
+
Me.useEffect(() => {
|
|
622
|
+
i && I(i);
|
|
623
|
+
}, [i, I]);
|
|
624
|
+
const d = async (o) => {
|
|
625
|
+
try {
|
|
626
|
+
const c = await a.selectRole(o.id);
|
|
627
|
+
l && l(c);
|
|
628
|
+
} catch (c) {
|
|
629
|
+
throw se.error("Role selection failed", c), c;
|
|
630
|
+
}
|
|
631
|
+
};
|
|
632
|
+
if (R && F) {
|
|
633
|
+
const o = xe(m || f || {}), c = /* @__PURE__ */ e(
|
|
634
|
+
$e,
|
|
635
|
+
{
|
|
636
|
+
user: R.user,
|
|
637
|
+
roles: F,
|
|
638
|
+
onRoleSelect: d,
|
|
639
|
+
title: O,
|
|
640
|
+
subtitle: P
|
|
641
|
+
}
|
|
642
|
+
);
|
|
643
|
+
return V ? /* @__PURE__ */ e(Ee, { appName: r, appLogo: typeof g == "string" ? g : p, children: c }) : /* @__PURE__ */ e(Q, { className: "min-h-screen", style: o, children: /* @__PURE__ */ e(Ge, { className: "flex justify-center items-center min-h-screen p-5", children: c }) });
|
|
644
|
+
}
|
|
645
|
+
return /* @__PURE__ */ e(
|
|
646
|
+
Je,
|
|
647
|
+
{
|
|
648
|
+
onLogin: I,
|
|
649
|
+
logo: g,
|
|
650
|
+
title: y,
|
|
651
|
+
subtitle: h,
|
|
652
|
+
apiConfig: m,
|
|
653
|
+
useDynamicConfig: B,
|
|
654
|
+
staticConfig: f
|
|
655
|
+
},
|
|
656
|
+
K
|
|
657
|
+
);
|
|
658
|
+
};
|
|
659
|
+
export {
|
|
660
|
+
as as LoginPageWithRoleSelection
|
|
661
|
+
};
|
|
662
|
+
//# sourceMappingURL=LoginPageWithRoleSelection-xTr_eIWh.js.map
|