@payez/next-mvp 4.0.0 → 4.0.2
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/api-handlers/account/change-password.js +110 -110
- package/dist/api-handlers/admin/analytics.d.ts +19 -19
- package/dist/api-handlers/admin/analytics.js +378 -378
- package/dist/api-handlers/admin/audit.d.ts +19 -19
- package/dist/api-handlers/admin/audit.js +213 -213
- package/dist/api-handlers/admin/index.d.ts +21 -21
- package/dist/api-handlers/admin/index.js +42 -42
- package/dist/api-handlers/admin/redis-sessions.d.ts +35 -35
- package/dist/api-handlers/admin/redis-sessions.js +203 -203
- package/dist/api-handlers/admin/sessions.d.ts +20 -20
- package/dist/api-handlers/admin/sessions.js +283 -283
- package/dist/api-handlers/admin/site-logs.d.ts +45 -45
- package/dist/api-handlers/admin/site-logs.js +317 -317
- package/dist/api-handlers/admin/stats.d.ts +20 -20
- package/dist/api-handlers/admin/stats.js +239 -239
- package/dist/api-handlers/admin/users.d.ts +19 -19
- package/dist/api-handlers/admin/users.js +221 -221
- package/dist/api-handlers/admin/vibe-data.d.ts +79 -79
- package/dist/api-handlers/admin/vibe-data.js +267 -267
- package/dist/api-handlers/auth/refresh.js +633 -633
- package/dist/api-handlers/auth/signout.js +186 -186
- package/dist/api-handlers/auth/verify-code.d.ts +43 -43
- package/dist/api-handlers/auth/verify-code.js +90 -90
- package/dist/api-handlers/session/viability.js +114 -114
- package/dist/api-handlers/test/force-expire.js +59 -59
- package/dist/auth/auth-decision.js +182 -182
- package/dist/auth/utils/token-utils.d.ts +83 -83
- package/dist/auth/utils/token-utils.js +218 -218
- package/dist/client/AuthContext.js +115 -115
- package/dist/client/better-auth-client.d.ts +1020 -1020
- package/dist/components/SessionSync.js +121 -121
- package/dist/components/account/MobileNavDrawer.js +64 -64
- package/dist/components/account/UserAvatarMenu.js +91 -91
- package/dist/components/admin/VibeAdminLayout.js +71 -71
- package/dist/hooks/useAuthSettings.js +93 -93
- package/dist/hooks/useAvailableProviders.d.ts +43 -43
- package/dist/hooks/useAvailableProviders.js +112 -112
- package/dist/lib/app-slug.d.ts +95 -95
- package/dist/lib/app-slug.js +172 -172
- package/dist/lib/test-aware-get-token.js +86 -86
- package/dist/lib/token-lifecycle.d.ts +78 -78
- package/dist/lib/token-lifecycle.js +360 -360
- package/dist/pages/admin-login/page.js +73 -73
- package/dist/pages/client-admin/ClientSiteAdminPage.js +179 -179
- package/dist/pages/login/page.js +202 -202
- package/dist/pages/showcase/ShowcasePage.js +142 -142
- package/dist/pages/test-env/EmergencyLogoutPage.js +99 -99
- package/dist/pages/test-env/JwtInspectPage.js +116 -116
- package/dist/pages/test-env/TestEnvPage.js +51 -51
- package/dist/pages/verify-code/page.js +412 -412
- package/dist/routes/auth/logout.d.ts +31 -31
- package/dist/routes/auth/logout.js +98 -98
- package/dist/routes/auth/session.js +157 -157
- package/dist/routes/auth/viability.js +190 -190
- package/package.json +6 -16
- package/dist/auth/auth-options.d.ts +0 -57
- package/dist/auth/auth-options.js +0 -213
- package/dist/auth/callbacks/index.d.ts +0 -6
- package/dist/auth/callbacks/index.js +0 -12
- package/dist/auth/callbacks/jwt.d.ts +0 -45
- package/dist/auth/callbacks/jwt.js +0 -305
- package/dist/auth/callbacks/session.d.ts +0 -60
- package/dist/auth/callbacks/session.js +0 -170
- package/dist/auth/callbacks/signin.d.ts +0 -23
- package/dist/auth/callbacks/signin.js +0 -44
- package/dist/auth/events/index.d.ts +0 -4
- package/dist/auth/events/index.js +0 -8
- package/dist/auth/events/signout.d.ts +0 -17
- package/dist/auth/events/signout.js +0 -32
- package/dist/auth/providers/credentials.d.ts +0 -32
- package/dist/auth/providers/credentials.js +0 -223
- package/dist/auth/providers/index.d.ts +0 -5
- package/dist/auth/providers/index.js +0 -21
- package/dist/auth/providers/oauth.d.ts +0 -26
- package/dist/auth/providers/oauth.js +0 -105
- package/dist/lib/nextauth-secret.d.ts +0 -10
- package/dist/lib/nextauth-secret.js +0 -100
- package/dist/pages/profile/profile-patch.d.ts +0 -1
- package/dist/pages/profile/profile-patch.js +0 -281
- package/dist/pages/security/security-patch.d.ts +0 -1
- package/dist/pages/security/security-patch.js +0 -302
package/dist/pages/login/page.js
CHANGED
|
@@ -1,181 +1,181 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Themed Login Page for @payez/next-mvp
|
|
4
|
-
*
|
|
5
|
-
* DEPENDENCIES: Only React, Next.js, next-auth, and Tailwind CSS
|
|
6
|
-
* NO shadcn/ui or other UI library required!
|
|
7
|
-
*
|
|
8
|
-
* FEATURES:
|
|
9
|
-
* ✅ Atomic state management with visual feedback (submitting/error/success)
|
|
10
|
-
* ✅ Enhanced error handling with user-friendly messages
|
|
11
|
-
* ✅ Show/hide password toggle
|
|
12
|
-
* ✅ Loading state management with timeouts
|
|
13
|
-
* ✅ Proper autofill styling
|
|
14
|
-
* ✅ Session expiration handling
|
|
15
|
-
* ✅ Themeable styling via ThemeProvider
|
|
16
|
-
* ✅ Placeholder for health check component
|
|
17
|
-
*
|
|
18
|
-
* USAGE:
|
|
19
|
-
* 1. Import from @payez/next-mvp/pages/login
|
|
20
|
-
* 2. Wrap your app with ThemeProvider to customize branding
|
|
21
|
-
* 3. Optionally add your health check component
|
|
22
|
-
*/
|
|
23
|
-
'use client';
|
|
24
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
25
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
26
|
-
};
|
|
27
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
-
exports.default = LoginPage;
|
|
29
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
30
|
-
const react_1 = require("react");
|
|
31
|
-
const better_auth_client_1 = require("../../client/better-auth-client");
|
|
32
|
-
const navigation_1 = require("next/navigation");
|
|
33
|
-
const react_2 = require("react");
|
|
34
|
-
const ReservedStatusBox_1 = __importDefault(require("../../components/reserved/ReservedStatusBox"));
|
|
35
|
-
const ReservedRecoveryWarning_1 = __importDefault(require("../../components/reserved/ReservedRecoveryWarning"));
|
|
36
|
-
const useTheme_1 = require("../../theme/useTheme");
|
|
37
|
-
function LoginForm() {
|
|
38
|
-
const searchParams = (0, navigation_1.useSearchParams)();
|
|
39
|
-
const callbackUrl = searchParams?.get('callbackUrl') || '/dashboard';
|
|
40
|
-
const urlError = searchParams?.get('error');
|
|
41
|
-
const { data: sessionData, isPending } = better_auth_client_1.authClient.useSession();
|
|
42
|
-
const session = sessionData;
|
|
43
|
-
const status = isPending ? 'loading' : session ? 'authenticated' : 'unauthenticated';
|
|
44
|
-
const branding = (0, useTheme_1.useBranding)();
|
|
45
|
-
const colors = (0, useTheme_1.useColors)();
|
|
46
|
-
const layout = (0, useTheme_1.useLayout)();
|
|
47
|
-
// Helper to create lighter/darker shades for hover states
|
|
48
|
-
const adjustBrightness = (hex, percent) => {
|
|
49
|
-
const num = parseInt(hex.replace('#', ''), 16);
|
|
50
|
-
const amt = Math.round(2.55 * percent);
|
|
51
|
-
const R = (num >> 16) + amt;
|
|
52
|
-
const G = (num >> 8 & 0x00FF) + amt;
|
|
53
|
-
const B = (num & 0x0000FF) + amt;
|
|
54
|
-
return '#' + (0x1000000 + (R < 255 ? R < 1 ? 0 : R : 255) * 0x10000 +
|
|
55
|
-
(G < 255 ? G < 1 ? 0 : G : 255) * 0x100 +
|
|
56
|
-
(B < 255 ? B < 1 ? 0 : B : 255))
|
|
57
|
-
.toString(16).slice(1);
|
|
58
|
-
};
|
|
59
|
-
// Get the primary button color from theme (defaults to primary, or uses component override)
|
|
60
|
-
const buttonColor = colors.secondary || colors.primary || '#3b82f6';
|
|
61
|
-
const buttonHoverColor = adjustBrightness(buttonColor, -10);
|
|
62
|
-
// Form fields
|
|
63
|
-
const [email, setEmail] = (0, react_1.useState)('');
|
|
64
|
-
const [password, setPassword] = (0, react_1.useState)('');
|
|
65
|
-
const [showPassword, setShowPassword] = (0, react_1.useState)(false);
|
|
66
|
-
// Atomic state management - only ONE can be true at a time
|
|
67
|
-
const [isSubmitting, setIsSubmitting] = (0, react_1.useState)(false);
|
|
68
|
-
const [loginSuccess, setLoginSuccess] = (0, react_1.useState)(false);
|
|
69
|
-
const [loginError, setLoginError] = (0, react_1.useState)(null);
|
|
70
|
-
const [loading, setLoading] = (0, react_1.useState)(false);
|
|
71
|
-
const [showRecoveryOptions, setShowRecoveryOptions] = (0, react_1.useState)(false);
|
|
72
|
-
// Force show form after timeout if stuck in loading
|
|
73
|
-
const [forceShowForm, setForceShowForm] = (0, react_1.useState)(false);
|
|
74
|
-
// Handle URL errors with user-friendly messages
|
|
75
|
-
(0, react_1.useEffect)(() => {
|
|
76
|
-
if (urlError) {
|
|
77
|
-
let friendlyError = urlError;
|
|
78
|
-
if (urlError === 'SessionExpired') {
|
|
79
|
-
// Session expiration is normal - don't show as error
|
|
80
|
-
console.log('[LOGIN] SessionExpired detected - normal behavior');
|
|
81
|
-
friendlyError = null;
|
|
82
|
-
}
|
|
83
|
-
else if (urlError === 'ServiceUnavailable') {
|
|
84
|
-
friendlyError = 'Authentication service is temporarily unavailable. Please try again in a few minutes.';
|
|
85
|
-
}
|
|
86
|
-
else if (urlError.startsWith("Unexpected token")) {
|
|
87
|
-
friendlyError = 'An authentication error occurred. Please try signing in again.';
|
|
88
|
-
}
|
|
89
|
-
else if (urlError.includes('not valid JSON')) {
|
|
90
|
-
friendlyError = 'An authentication error occurred. Please try signing in again.';
|
|
91
|
-
}
|
|
92
|
-
else if (urlError === 'CredentialsSignin') {
|
|
93
|
-
friendlyError = 'Invalid email or password. Please try again.';
|
|
94
|
-
}
|
|
95
|
-
setLoginError(friendlyError);
|
|
96
|
-
}
|
|
97
|
-
}, [urlError]);
|
|
98
|
-
// Timeout to prevent infinite loading states
|
|
99
|
-
(0, react_1.useEffect)(() => {
|
|
100
|
-
if (status === 'loading') {
|
|
101
|
-
const timeout = setTimeout(() => {
|
|
102
|
-
console.warn('[LOGIN] NextAuth status stuck in loading, forcing form display');
|
|
103
|
-
setForceShowForm(true);
|
|
104
|
-
}, 3000);
|
|
105
|
-
return () => clearTimeout(timeout);
|
|
106
|
-
}
|
|
107
|
-
}, [status]);
|
|
108
|
-
// Force show form after 1 second if no session
|
|
109
|
-
(0, react_1.useEffect)(() => {
|
|
110
|
-
const immediateTimeout = setTimeout(() => {
|
|
111
|
-
if (status === 'loading' && !session) {
|
|
112
|
-
console.log('[LOGIN] Force showing form after 1 second');
|
|
113
|
-
setForceShowForm(true);
|
|
114
|
-
}
|
|
115
|
-
}, 1000);
|
|
116
|
-
return () => clearTimeout(immediateTimeout);
|
|
117
|
-
}, [status, session]);
|
|
118
|
-
const handleSubmit = async (e) => {
|
|
119
|
-
e.preventDefault();
|
|
120
|
-
// Atomic state: set to submitting (clears error and success)
|
|
121
|
-
setIsSubmitting(true);
|
|
122
|
-
setLoading(true);
|
|
123
|
-
setLoginError(null);
|
|
124
|
-
setLoginSuccess(false);
|
|
125
|
-
try {
|
|
126
|
-
console.log('[LOGIN] Starting authentication...');
|
|
127
|
-
const result = await better_auth_client_1.authClient.signIn.email({
|
|
128
|
-
email,
|
|
129
|
-
password,
|
|
130
|
-
callbackURL: callbackUrl,
|
|
131
|
-
});
|
|
132
|
-
if (result?.error) {
|
|
133
|
-
console.log('[LOGIN] Authentication failed:', result.error);
|
|
134
|
-
setIsSubmitting(false);
|
|
135
|
-
setLoading(false);
|
|
136
|
-
setLoginSuccess(false);
|
|
137
|
-
const errorMsg = typeof result.error === 'object'
|
|
138
|
-
? result.error.message || 'Authentication failed'
|
|
139
|
-
: String(result.error);
|
|
140
|
-
if (errorMsg.includes('password') || errorMsg.includes('Password')) {
|
|
141
|
-
console.log('[LOGIN] Password error detected - showing recovery options');
|
|
142
|
-
setShowRecoveryOptions(true);
|
|
143
|
-
setLoginError(errorMsg);
|
|
144
|
-
}
|
|
145
|
-
else if (errorMsg.includes('Unable to connect')) {
|
|
146
|
-
setLoginError('The authentication service is currently unavailable. Please try again later.');
|
|
147
|
-
}
|
|
148
|
-
else {
|
|
149
|
-
setLoginError(errorMsg);
|
|
150
|
-
}
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
// Atomic state: set to success
|
|
154
|
-
console.log('[LOGIN] Authentication successful!');
|
|
155
|
-
setLoginSuccess(true);
|
|
156
|
-
setLoginError(null);
|
|
157
|
-
setIsSubmitting(false);
|
|
158
|
-
// Get updated session
|
|
159
|
-
const freshSession = await better_auth_client_1.authClient.getSession();
|
|
160
|
-
console.log('[LOGIN] Fresh session obtained, redirecting to 2FA...');
|
|
161
|
-
// Redirect to verify-code for 2FA
|
|
162
|
-
const verifyUrl = `/account-auth/verify-code?callbackUrl=${encodeURIComponent(callbackUrl)}`;
|
|
163
|
-
console.log('[LOGIN] Redirecting to:', verifyUrl);
|
|
164
|
-
window.location.href = verifyUrl;
|
|
165
|
-
}
|
|
166
|
-
catch (err) {
|
|
167
|
-
console.error('[LOGIN] Unexpected error:', err);
|
|
168
|
-
// Atomic state: set to error
|
|
169
|
-
setIsSubmitting(false);
|
|
170
|
-
setLoading(false);
|
|
171
|
-
setLoginSuccess(false);
|
|
172
|
-
setLoginError(err instanceof Error ? err.message : 'An error occurred during login');
|
|
173
|
-
}
|
|
174
|
-
};
|
|
175
|
-
// Show loading spinner for initial loads
|
|
176
|
-
if (!forceShowForm && !loginError && (loading || (status === 'loading' && !session))) {
|
|
177
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: `flex flex-col items-center justify-center min-h-screen ${colors.background}`, children: [(0, jsx_runtime_1.jsxs)("svg", { className: "animate-spin h-6 w-6", style: { color: buttonColor }, viewBox: "0 0 24 24", fill: "none", children: [(0, jsx_runtime_1.jsx)("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }), (0, jsx_runtime_1.jsx)("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8v4a4 4 0 00-4 4H4z" })] }), (0, jsx_runtime_1.jsx)("p", { className: `mt-4 text-sm ${colors.muted}`, children: status === 'loading' ? 'Loading...' : 'Authenticating...' })] }));
|
|
178
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Themed Login Page for @payez/next-mvp
|
|
4
|
+
*
|
|
5
|
+
* DEPENDENCIES: Only React, Next.js, next-auth, and Tailwind CSS
|
|
6
|
+
* NO shadcn/ui or other UI library required!
|
|
7
|
+
*
|
|
8
|
+
* FEATURES:
|
|
9
|
+
* ✅ Atomic state management with visual feedback (submitting/error/success)
|
|
10
|
+
* ✅ Enhanced error handling with user-friendly messages
|
|
11
|
+
* ✅ Show/hide password toggle
|
|
12
|
+
* ✅ Loading state management with timeouts
|
|
13
|
+
* ✅ Proper autofill styling
|
|
14
|
+
* ✅ Session expiration handling
|
|
15
|
+
* ✅ Themeable styling via ThemeProvider
|
|
16
|
+
* ✅ Placeholder for health check component
|
|
17
|
+
*
|
|
18
|
+
* USAGE:
|
|
19
|
+
* 1. Import from @payez/next-mvp/pages/login
|
|
20
|
+
* 2. Wrap your app with ThemeProvider to customize branding
|
|
21
|
+
* 3. Optionally add your health check component
|
|
22
|
+
*/
|
|
23
|
+
'use client';
|
|
24
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
25
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
26
|
+
};
|
|
27
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
+
exports.default = LoginPage;
|
|
29
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
30
|
+
const react_1 = require("react");
|
|
31
|
+
const better_auth_client_1 = require("../../client/better-auth-client");
|
|
32
|
+
const navigation_1 = require("next/navigation");
|
|
33
|
+
const react_2 = require("react");
|
|
34
|
+
const ReservedStatusBox_1 = __importDefault(require("../../components/reserved/ReservedStatusBox"));
|
|
35
|
+
const ReservedRecoveryWarning_1 = __importDefault(require("../../components/reserved/ReservedRecoveryWarning"));
|
|
36
|
+
const useTheme_1 = require("../../theme/useTheme");
|
|
37
|
+
function LoginForm() {
|
|
38
|
+
const searchParams = (0, navigation_1.useSearchParams)();
|
|
39
|
+
const callbackUrl = searchParams?.get('callbackUrl') || '/dashboard';
|
|
40
|
+
const urlError = searchParams?.get('error');
|
|
41
|
+
const { data: sessionData, isPending } = better_auth_client_1.authClient.useSession();
|
|
42
|
+
const session = sessionData;
|
|
43
|
+
const status = isPending ? 'loading' : session ? 'authenticated' : 'unauthenticated';
|
|
44
|
+
const branding = (0, useTheme_1.useBranding)();
|
|
45
|
+
const colors = (0, useTheme_1.useColors)();
|
|
46
|
+
const layout = (0, useTheme_1.useLayout)();
|
|
47
|
+
// Helper to create lighter/darker shades for hover states
|
|
48
|
+
const adjustBrightness = (hex, percent) => {
|
|
49
|
+
const num = parseInt(hex.replace('#', ''), 16);
|
|
50
|
+
const amt = Math.round(2.55 * percent);
|
|
51
|
+
const R = (num >> 16) + amt;
|
|
52
|
+
const G = (num >> 8 & 0x00FF) + amt;
|
|
53
|
+
const B = (num & 0x0000FF) + amt;
|
|
54
|
+
return '#' + (0x1000000 + (R < 255 ? R < 1 ? 0 : R : 255) * 0x10000 +
|
|
55
|
+
(G < 255 ? G < 1 ? 0 : G : 255) * 0x100 +
|
|
56
|
+
(B < 255 ? B < 1 ? 0 : B : 255))
|
|
57
|
+
.toString(16).slice(1);
|
|
58
|
+
};
|
|
59
|
+
// Get the primary button color from theme (defaults to primary, or uses component override)
|
|
60
|
+
const buttonColor = colors.secondary || colors.primary || '#3b82f6';
|
|
61
|
+
const buttonHoverColor = adjustBrightness(buttonColor, -10);
|
|
62
|
+
// Form fields
|
|
63
|
+
const [email, setEmail] = (0, react_1.useState)('');
|
|
64
|
+
const [password, setPassword] = (0, react_1.useState)('');
|
|
65
|
+
const [showPassword, setShowPassword] = (0, react_1.useState)(false);
|
|
66
|
+
// Atomic state management - only ONE can be true at a time
|
|
67
|
+
const [isSubmitting, setIsSubmitting] = (0, react_1.useState)(false);
|
|
68
|
+
const [loginSuccess, setLoginSuccess] = (0, react_1.useState)(false);
|
|
69
|
+
const [loginError, setLoginError] = (0, react_1.useState)(null);
|
|
70
|
+
const [loading, setLoading] = (0, react_1.useState)(false);
|
|
71
|
+
const [showRecoveryOptions, setShowRecoveryOptions] = (0, react_1.useState)(false);
|
|
72
|
+
// Force show form after timeout if stuck in loading
|
|
73
|
+
const [forceShowForm, setForceShowForm] = (0, react_1.useState)(false);
|
|
74
|
+
// Handle URL errors with user-friendly messages
|
|
75
|
+
(0, react_1.useEffect)(() => {
|
|
76
|
+
if (urlError) {
|
|
77
|
+
let friendlyError = urlError;
|
|
78
|
+
if (urlError === 'SessionExpired') {
|
|
79
|
+
// Session expiration is normal - don't show as error
|
|
80
|
+
console.log('[LOGIN] SessionExpired detected - normal behavior');
|
|
81
|
+
friendlyError = null;
|
|
82
|
+
}
|
|
83
|
+
else if (urlError === 'ServiceUnavailable') {
|
|
84
|
+
friendlyError = 'Authentication service is temporarily unavailable. Please try again in a few minutes.';
|
|
85
|
+
}
|
|
86
|
+
else if (urlError.startsWith("Unexpected token")) {
|
|
87
|
+
friendlyError = 'An authentication error occurred. Please try signing in again.';
|
|
88
|
+
}
|
|
89
|
+
else if (urlError.includes('not valid JSON')) {
|
|
90
|
+
friendlyError = 'An authentication error occurred. Please try signing in again.';
|
|
91
|
+
}
|
|
92
|
+
else if (urlError === 'CredentialsSignin') {
|
|
93
|
+
friendlyError = 'Invalid email or password. Please try again.';
|
|
94
|
+
}
|
|
95
|
+
setLoginError(friendlyError);
|
|
96
|
+
}
|
|
97
|
+
}, [urlError]);
|
|
98
|
+
// Timeout to prevent infinite loading states
|
|
99
|
+
(0, react_1.useEffect)(() => {
|
|
100
|
+
if (status === 'loading') {
|
|
101
|
+
const timeout = setTimeout(() => {
|
|
102
|
+
console.warn('[LOGIN] NextAuth status stuck in loading, forcing form display');
|
|
103
|
+
setForceShowForm(true);
|
|
104
|
+
}, 3000);
|
|
105
|
+
return () => clearTimeout(timeout);
|
|
106
|
+
}
|
|
107
|
+
}, [status]);
|
|
108
|
+
// Force show form after 1 second if no session
|
|
109
|
+
(0, react_1.useEffect)(() => {
|
|
110
|
+
const immediateTimeout = setTimeout(() => {
|
|
111
|
+
if (status === 'loading' && !session) {
|
|
112
|
+
console.log('[LOGIN] Force showing form after 1 second');
|
|
113
|
+
setForceShowForm(true);
|
|
114
|
+
}
|
|
115
|
+
}, 1000);
|
|
116
|
+
return () => clearTimeout(immediateTimeout);
|
|
117
|
+
}, [status, session]);
|
|
118
|
+
const handleSubmit = async (e) => {
|
|
119
|
+
e.preventDefault();
|
|
120
|
+
// Atomic state: set to submitting (clears error and success)
|
|
121
|
+
setIsSubmitting(true);
|
|
122
|
+
setLoading(true);
|
|
123
|
+
setLoginError(null);
|
|
124
|
+
setLoginSuccess(false);
|
|
125
|
+
try {
|
|
126
|
+
console.log('[LOGIN] Starting authentication...');
|
|
127
|
+
const result = await better_auth_client_1.authClient.signIn.email({
|
|
128
|
+
email,
|
|
129
|
+
password,
|
|
130
|
+
callbackURL: callbackUrl,
|
|
131
|
+
});
|
|
132
|
+
if (result?.error) {
|
|
133
|
+
console.log('[LOGIN] Authentication failed:', result.error);
|
|
134
|
+
setIsSubmitting(false);
|
|
135
|
+
setLoading(false);
|
|
136
|
+
setLoginSuccess(false);
|
|
137
|
+
const errorMsg = typeof result.error === 'object'
|
|
138
|
+
? result.error.message || 'Authentication failed'
|
|
139
|
+
: String(result.error);
|
|
140
|
+
if (errorMsg.includes('password') || errorMsg.includes('Password')) {
|
|
141
|
+
console.log('[LOGIN] Password error detected - showing recovery options');
|
|
142
|
+
setShowRecoveryOptions(true);
|
|
143
|
+
setLoginError(errorMsg);
|
|
144
|
+
}
|
|
145
|
+
else if (errorMsg.includes('Unable to connect')) {
|
|
146
|
+
setLoginError('The authentication service is currently unavailable. Please try again later.');
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
setLoginError(errorMsg);
|
|
150
|
+
}
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
// Atomic state: set to success
|
|
154
|
+
console.log('[LOGIN] Authentication successful!');
|
|
155
|
+
setLoginSuccess(true);
|
|
156
|
+
setLoginError(null);
|
|
157
|
+
setIsSubmitting(false);
|
|
158
|
+
// Get updated session
|
|
159
|
+
const freshSession = await better_auth_client_1.authClient.getSession();
|
|
160
|
+
console.log('[LOGIN] Fresh session obtained, redirecting to 2FA...');
|
|
161
|
+
// Redirect to verify-code for 2FA
|
|
162
|
+
const verifyUrl = `/account-auth/verify-code?callbackUrl=${encodeURIComponent(callbackUrl)}`;
|
|
163
|
+
console.log('[LOGIN] Redirecting to:', verifyUrl);
|
|
164
|
+
window.location.href = verifyUrl;
|
|
165
|
+
}
|
|
166
|
+
catch (err) {
|
|
167
|
+
console.error('[LOGIN] Unexpected error:', err);
|
|
168
|
+
// Atomic state: set to error
|
|
169
|
+
setIsSubmitting(false);
|
|
170
|
+
setLoading(false);
|
|
171
|
+
setLoginSuccess(false);
|
|
172
|
+
setLoginError(err instanceof Error ? err.message : 'An error occurred during login');
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
// Show loading spinner for initial loads
|
|
176
|
+
if (!forceShowForm && !loginError && (loading || (status === 'loading' && !session))) {
|
|
177
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: `flex flex-col items-center justify-center min-h-screen ${colors.background}`, children: [(0, jsx_runtime_1.jsxs)("svg", { className: "animate-spin h-6 w-6", style: { color: buttonColor }, viewBox: "0 0 24 24", fill: "none", children: [(0, jsx_runtime_1.jsx)("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }), (0, jsx_runtime_1.jsx)("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8v4a4 4 0 00-4 4H4z" })] }), (0, jsx_runtime_1.jsx)("p", { className: `mt-4 text-sm ${colors.muted}`, children: status === 'loading' ? 'Loading...' : 'Authenticating...' })] }));
|
|
178
|
+
}
|
|
179
179
|
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("style", { dangerouslySetInnerHTML: { __html: `
|
|
180
180
|
.themed-input:focus {
|
|
181
181
|
outline: none;
|
|
@@ -204,27 +204,27 @@ function LoginForm() {
|
|
|
204
204
|
.themed-status-submitting svg {
|
|
205
205
|
color: ${buttonColor} !important;
|
|
206
206
|
}
|
|
207
|
-
` } }), (0, jsx_runtime_1.jsx)("div", { className: `min-h-screen flex items-center justify-center px-4 ${colors.background}`, children: (0, jsx_runtime_1.jsxs)("div", { className: "max-w-md w-full", children: [(0, jsx_runtime_1.jsxs)("div", { className: `rounded-2xl shadow-xl p-8 ${colors.card} ${colors.border} text-gray-800`, children: [(0, jsx_runtime_1.jsxs)("div", { className: "text-center mb-8", children: [(0, jsx_runtime_1.jsx)("h1", { className: "text-3xl font-bold mb-2", style: { color: 'inherit' }, children: branding.tagline || 'Welcome Back' }), (0, jsx_runtime_1.jsx)("p", { className: colors.muted, children: "Sign in to your account" })] }), (0, jsx_runtime_1.jsxs)("form", { onSubmit: handleSubmit, className: "space-y-6", "data-testid": "login-form", children: [(0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("label", { htmlFor: "email", className: "block text-sm font-medium mb-2", style: { color: 'inherit' }, children: "Email Address" }), (0, jsx_runtime_1.jsx)("input", { id: "email", type: "email", required: true, autoFocus: true, autoComplete: "email", value: email, onChange: (e) => setEmail(e.target.value), className: `themed-input w-full px-4 py-3 border border-gray-300 rounded-lg transition-colors`, placeholder: "you@example.com", disabled: isSubmitting, style: { backgroundColor: 'white', color: '#1f2937' } })] }), (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("label", { htmlFor: "password", className: "block text-sm font-medium mb-2", style: { color: 'inherit' }, children: "Password" }), (0, jsx_runtime_1.jsxs)("div", { className: "relative", children: [(0, jsx_runtime_1.jsx)("input", { id: "password", type: showPassword ? "text" : "password", required: true, autoComplete: "current-password", value: password, onChange: (e) => setPassword(e.target.value), className: `themed-input w-full px-4 py-3 pr-12 border border-gray-300 rounded-lg transition-colors`, placeholder: "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022", disabled: isSubmitting, style: { backgroundColor: 'white', color: '#1f2937' } }), (0, jsx_runtime_1.jsx)("button", { type: "button", onClick: () => setShowPassword(!showPassword), className: "absolute right-3 top-1/2 transform -translate-y-1/2 hover:opacity-70", style: { color: 'inherit', opacity: 0.7 }, "aria-label": showPassword ? "Hide password" : "Show password", children: showPassword ? ((0, jsx_runtime_1.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", className: "w-5 h-5", children: (0, jsx_runtime_1.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.878 9.878L6.464 6.464m7.535 7.535l3.415 3.414M3 3l3.464 3.464M21 21l-3.415-3.414" }) })) : ((0, jsx_runtime_1.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", className: "w-5 h-5", children: [(0, jsx_runtime_1.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M15 12a3 3 0 11-6 0 3 3 0 016 0z" }), (0, jsx_runtime_1.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z" })] })) })] })] }), (0, jsx_runtime_1.jsx)(ReservedStatusBox_1.default, { candidates: [
|
|
208
|
-
"Ready",
|
|
209
|
-
"Authenticating...",
|
|
210
|
-
"The authentication service is currently unavailable. Please try again later.",
|
|
211
|
-
"Invalid email or password. Please try again.",
|
|
212
|
-
"Login successful! Redirecting..."
|
|
213
|
-
], containerClass: "p-3 text-sm leading-relaxed rounded-lg border", iconSizePx: 16, children: isSubmitting ? (
|
|
214
|
-
/* Themed: Submitting */
|
|
215
|
-
(0, jsx_runtime_1.jsxs)("div", { className: "themed-status-submitting flex items-start space-x-2 p-3 rounded-lg", children: [(0, jsx_runtime_1.jsxs)("svg", { className: "animate-spin w-4 h-4 mt-0.5 flex-shrink-0", fill: "none", viewBox: "0 0 24 24", style: { color: buttonColor }, children: [(0, jsx_runtime_1.jsx)("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }), (0, jsx_runtime_1.jsx)("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" })] }), (0, jsx_runtime_1.jsx)("span", { className: "themed-status-submitting-text text-sm leading-relaxed", style: { color: buttonColor }, children: "Authenticating..." })] })) : loginError ? (
|
|
216
|
-
/* Red: Error */
|
|
217
|
-
(0, jsx_runtime_1.jsxs)("div", { className: "flex items-start space-x-2 p-3 rounded-lg bg-red-500/10 border border-red-500/20", children: [(0, jsx_runtime_1.jsx)("div", { className: "w-4 h-4 bg-red-500 rounded-full mt-0.5 flex-shrink-0" }), (0, jsx_runtime_1.jsx)("span", { className: "text-red-600 text-sm leading-relaxed", children: loginError })] })) : loginSuccess ? (
|
|
218
|
-
/* Green: Success */
|
|
219
|
-
(0, jsx_runtime_1.jsxs)("div", { className: "flex items-start space-x-2 p-3 rounded-lg bg-green-500/10 border border-green-500/20", children: [(0, jsx_runtime_1.jsx)("div", { className: "w-4 h-4 bg-green-500 rounded-full mt-0.5 flex-shrink-0" }), (0, jsx_runtime_1.jsx)("span", { className: "text-green-600 text-sm leading-relaxed", children: "Login successful! Redirecting..." })] })) : (
|
|
220
|
-
/* Ready State / Health Check Placeholder */
|
|
221
|
-
(0, jsx_runtime_1.jsxs)("div", { className: "flex items-start space-x-2 p-3 rounded-lg bg-green-500/10 border border-green-500/20", children: [(0, jsx_runtime_1.jsx)("div", { className: "w-4 h-4 bg-green-500 rounded-full mt-0.5 flex-shrink-0" }), (0, jsx_runtime_1.jsx)("span", { className: "text-green-600 text-sm leading-relaxed", children: "Ready" })] })) }), (0, jsx_runtime_1.jsx)(ReservedRecoveryWarning_1.default, { show: showRecoveryOptions, titleText: "Account Lockout Warning", bodyText: "Your account will be locked after one more failed attempt. Need help?", actionLabel: "Start Account Recovery", containerClass: "p-4 bg-amber-50 border border-amber-200 rounded-lg", titleClass: "text-amber-900 font-medium mb-2", bodyClass: "text-amber-800 text-sm mb-3", buttonClass: "w-full bg-amber-600 hover:bg-amber-700 text-white font-medium py-2 px-4 rounded-md text-sm transition-colors", iconSizePx: 20, children: showRecoveryOptions && ((0, jsx_runtime_1.jsx)("div", { className: "p-4 bg-amber-50 border border-amber-200 rounded-lg", children: (0, jsx_runtime_1.jsxs)("div", { className: "flex items-start space-x-3", children: [(0, jsx_runtime_1.jsx)("svg", { className: "w-5 h-5 text-amber-600 mt-0.5 flex-shrink-0", fill: "currentColor", viewBox: "0 0 20 20", children: (0, jsx_runtime_1.jsx)("path", { fillRule: "evenodd", d: "M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z", clipRule: "evenodd" }) }), (0, jsx_runtime_1.jsxs)("div", { className: "flex-1", children: [(0, jsx_runtime_1.jsx)("h3", { className: "text-amber-900 font-medium mb-2", children: "Account Lockout Warning" }), (0, jsx_runtime_1.jsx)("p", { className: "text-amber-800 text-sm mb-3", children: "Your account will be locked after one more failed attempt. Need help?" }), (0, jsx_runtime_1.jsx)("button", { type: "button", onClick: () => window.location.href = `/account-auth/recovery?email=${encodeURIComponent(email)}`, className: "w-full bg-amber-600 hover:bg-amber-700 text-white font-medium py-2 px-4 rounded-md text-sm transition-colors", children: "Start Account Recovery" })] })] }) })) }), (0, jsx_runtime_1.jsx)("button", { type: "submit", disabled: isSubmitting, className: "themed-button w-full text-white font-semibold py-3 px-4 rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center", children: isSubmitting ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("svg", { className: "animate-spin -ml-1 mr-3 h-5 w-5 text-white", xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", children: [(0, jsx_runtime_1.jsx)("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }), (0, jsx_runtime_1.jsx)("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" })] }), "Signing in..."] })) : ('Sign In') })] }), (0, jsx_runtime_1.jsx)("div", { className: `mt-6 text-center text-sm ${colors.muted}`, children: (0, jsx_runtime_1.jsx)("a", { href: "/account-auth/recovery", className: "themed-link hover:underline", children: "Start account recovery" }) })] }), (0, jsx_runtime_1.jsxs)("p", { className: `mt-4 text-center text-sm ${colors.muted}`, children: ["Don't have an account?", ' ', (0, jsx_runtime_1.jsx)("a", { href: "/account-auth/register", className: "themed-link font-medium hover:underline", children: "Sign up" })] })] }) })] }));
|
|
222
|
-
}
|
|
223
|
-
function LoginPageFallback() {
|
|
224
|
-
const colors = (0, useTheme_1.useColors)();
|
|
225
|
-
const buttonColor = colors.secondary || colors.primary || '#11B588';
|
|
226
|
-
return ((0, jsx_runtime_1.jsx)("div", { className: `min-h-screen flex items-center justify-center ${colors.background}`, children: (0, jsx_runtime_1.jsxs)("div", { className: "text-center", children: [(0, jsx_runtime_1.jsxs)("svg", { className: "animate-spin h-10 w-10 mx-auto", style: { color: buttonColor }, xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", children: [(0, jsx_runtime_1.jsx)("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }), (0, jsx_runtime_1.jsx)("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" })] }), (0, jsx_runtime_1.jsx)("p", { className: `mt-4 ${colors.muted}`, children: "Loading..." })] }) }));
|
|
227
|
-
}
|
|
228
|
-
function LoginPage() {
|
|
229
|
-
return ((0, jsx_runtime_1.jsx)(react_2.Suspense, { fallback: (0, jsx_runtime_1.jsx)(LoginPageFallback, {}), children: (0, jsx_runtime_1.jsx)(LoginForm, {}) }));
|
|
230
|
-
}
|
|
207
|
+
` } }), (0, jsx_runtime_1.jsx)("div", { className: `min-h-screen flex items-center justify-center px-4 ${colors.background}`, children: (0, jsx_runtime_1.jsxs)("div", { className: "max-w-md w-full", children: [(0, jsx_runtime_1.jsxs)("div", { className: `rounded-2xl shadow-xl p-8 ${colors.card} ${colors.border} text-gray-800`, children: [(0, jsx_runtime_1.jsxs)("div", { className: "text-center mb-8", children: [(0, jsx_runtime_1.jsx)("h1", { className: "text-3xl font-bold mb-2", style: { color: 'inherit' }, children: branding.tagline || 'Welcome Back' }), (0, jsx_runtime_1.jsx)("p", { className: colors.muted, children: "Sign in to your account" })] }), (0, jsx_runtime_1.jsxs)("form", { onSubmit: handleSubmit, className: "space-y-6", "data-testid": "login-form", children: [(0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("label", { htmlFor: "email", className: "block text-sm font-medium mb-2", style: { color: 'inherit' }, children: "Email Address" }), (0, jsx_runtime_1.jsx)("input", { id: "email", type: "email", required: true, autoFocus: true, autoComplete: "email", value: email, onChange: (e) => setEmail(e.target.value), className: `themed-input w-full px-4 py-3 border border-gray-300 rounded-lg transition-colors`, placeholder: "you@example.com", disabled: isSubmitting, style: { backgroundColor: 'white', color: '#1f2937' } })] }), (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("label", { htmlFor: "password", className: "block text-sm font-medium mb-2", style: { color: 'inherit' }, children: "Password" }), (0, jsx_runtime_1.jsxs)("div", { className: "relative", children: [(0, jsx_runtime_1.jsx)("input", { id: "password", type: showPassword ? "text" : "password", required: true, autoComplete: "current-password", value: password, onChange: (e) => setPassword(e.target.value), className: `themed-input w-full px-4 py-3 pr-12 border border-gray-300 rounded-lg transition-colors`, placeholder: "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022", disabled: isSubmitting, style: { backgroundColor: 'white', color: '#1f2937' } }), (0, jsx_runtime_1.jsx)("button", { type: "button", onClick: () => setShowPassword(!showPassword), className: "absolute right-3 top-1/2 transform -translate-y-1/2 hover:opacity-70", style: { color: 'inherit', opacity: 0.7 }, "aria-label": showPassword ? "Hide password" : "Show password", children: showPassword ? ((0, jsx_runtime_1.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", className: "w-5 h-5", children: (0, jsx_runtime_1.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.878 9.878L6.464 6.464m7.535 7.535l3.415 3.414M3 3l3.464 3.464M21 21l-3.415-3.414" }) })) : ((0, jsx_runtime_1.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", className: "w-5 h-5", children: [(0, jsx_runtime_1.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M15 12a3 3 0 11-6 0 3 3 0 016 0z" }), (0, jsx_runtime_1.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z" })] })) })] })] }), (0, jsx_runtime_1.jsx)(ReservedStatusBox_1.default, { candidates: [
|
|
208
|
+
"Ready",
|
|
209
|
+
"Authenticating...",
|
|
210
|
+
"The authentication service is currently unavailable. Please try again later.",
|
|
211
|
+
"Invalid email or password. Please try again.",
|
|
212
|
+
"Login successful! Redirecting..."
|
|
213
|
+
], containerClass: "p-3 text-sm leading-relaxed rounded-lg border", iconSizePx: 16, children: isSubmitting ? (
|
|
214
|
+
/* Themed: Submitting */
|
|
215
|
+
(0, jsx_runtime_1.jsxs)("div", { className: "themed-status-submitting flex items-start space-x-2 p-3 rounded-lg", children: [(0, jsx_runtime_1.jsxs)("svg", { className: "animate-spin w-4 h-4 mt-0.5 flex-shrink-0", fill: "none", viewBox: "0 0 24 24", style: { color: buttonColor }, children: [(0, jsx_runtime_1.jsx)("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }), (0, jsx_runtime_1.jsx)("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" })] }), (0, jsx_runtime_1.jsx)("span", { className: "themed-status-submitting-text text-sm leading-relaxed", style: { color: buttonColor }, children: "Authenticating..." })] })) : loginError ? (
|
|
216
|
+
/* Red: Error */
|
|
217
|
+
(0, jsx_runtime_1.jsxs)("div", { className: "flex items-start space-x-2 p-3 rounded-lg bg-red-500/10 border border-red-500/20", children: [(0, jsx_runtime_1.jsx)("div", { className: "w-4 h-4 bg-red-500 rounded-full mt-0.5 flex-shrink-0" }), (0, jsx_runtime_1.jsx)("span", { className: "text-red-600 text-sm leading-relaxed", children: loginError })] })) : loginSuccess ? (
|
|
218
|
+
/* Green: Success */
|
|
219
|
+
(0, jsx_runtime_1.jsxs)("div", { className: "flex items-start space-x-2 p-3 rounded-lg bg-green-500/10 border border-green-500/20", children: [(0, jsx_runtime_1.jsx)("div", { className: "w-4 h-4 bg-green-500 rounded-full mt-0.5 flex-shrink-0" }), (0, jsx_runtime_1.jsx)("span", { className: "text-green-600 text-sm leading-relaxed", children: "Login successful! Redirecting..." })] })) : (
|
|
220
|
+
/* Ready State / Health Check Placeholder */
|
|
221
|
+
(0, jsx_runtime_1.jsxs)("div", { className: "flex items-start space-x-2 p-3 rounded-lg bg-green-500/10 border border-green-500/20", children: [(0, jsx_runtime_1.jsx)("div", { className: "w-4 h-4 bg-green-500 rounded-full mt-0.5 flex-shrink-0" }), (0, jsx_runtime_1.jsx)("span", { className: "text-green-600 text-sm leading-relaxed", children: "Ready" })] })) }), (0, jsx_runtime_1.jsx)(ReservedRecoveryWarning_1.default, { show: showRecoveryOptions, titleText: "Account Lockout Warning", bodyText: "Your account will be locked after one more failed attempt. Need help?", actionLabel: "Start Account Recovery", containerClass: "p-4 bg-amber-50 border border-amber-200 rounded-lg", titleClass: "text-amber-900 font-medium mb-2", bodyClass: "text-amber-800 text-sm mb-3", buttonClass: "w-full bg-amber-600 hover:bg-amber-700 text-white font-medium py-2 px-4 rounded-md text-sm transition-colors", iconSizePx: 20, children: showRecoveryOptions && ((0, jsx_runtime_1.jsx)("div", { className: "p-4 bg-amber-50 border border-amber-200 rounded-lg", children: (0, jsx_runtime_1.jsxs)("div", { className: "flex items-start space-x-3", children: [(0, jsx_runtime_1.jsx)("svg", { className: "w-5 h-5 text-amber-600 mt-0.5 flex-shrink-0", fill: "currentColor", viewBox: "0 0 20 20", children: (0, jsx_runtime_1.jsx)("path", { fillRule: "evenodd", d: "M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z", clipRule: "evenodd" }) }), (0, jsx_runtime_1.jsxs)("div", { className: "flex-1", children: [(0, jsx_runtime_1.jsx)("h3", { className: "text-amber-900 font-medium mb-2", children: "Account Lockout Warning" }), (0, jsx_runtime_1.jsx)("p", { className: "text-amber-800 text-sm mb-3", children: "Your account will be locked after one more failed attempt. Need help?" }), (0, jsx_runtime_1.jsx)("button", { type: "button", onClick: () => window.location.href = `/account-auth/recovery?email=${encodeURIComponent(email)}`, className: "w-full bg-amber-600 hover:bg-amber-700 text-white font-medium py-2 px-4 rounded-md text-sm transition-colors", children: "Start Account Recovery" })] })] }) })) }), (0, jsx_runtime_1.jsx)("button", { type: "submit", disabled: isSubmitting, className: "themed-button w-full text-white font-semibold py-3 px-4 rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center", children: isSubmitting ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("svg", { className: "animate-spin -ml-1 mr-3 h-5 w-5 text-white", xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", children: [(0, jsx_runtime_1.jsx)("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }), (0, jsx_runtime_1.jsx)("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" })] }), "Signing in..."] })) : ('Sign In') })] }), (0, jsx_runtime_1.jsx)("div", { className: `mt-6 text-center text-sm ${colors.muted}`, children: (0, jsx_runtime_1.jsx)("a", { href: "/account-auth/recovery", className: "themed-link hover:underline", children: "Start account recovery" }) })] }), (0, jsx_runtime_1.jsxs)("p", { className: `mt-4 text-center text-sm ${colors.muted}`, children: ["Don't have an account?", ' ', (0, jsx_runtime_1.jsx)("a", { href: "/account-auth/register", className: "themed-link font-medium hover:underline", children: "Sign up" })] })] }) })] }));
|
|
222
|
+
}
|
|
223
|
+
function LoginPageFallback() {
|
|
224
|
+
const colors = (0, useTheme_1.useColors)();
|
|
225
|
+
const buttonColor = colors.secondary || colors.primary || '#11B588';
|
|
226
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: `min-h-screen flex items-center justify-center ${colors.background}`, children: (0, jsx_runtime_1.jsxs)("div", { className: "text-center", children: [(0, jsx_runtime_1.jsxs)("svg", { className: "animate-spin h-10 w-10 mx-auto", style: { color: buttonColor }, xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", children: [(0, jsx_runtime_1.jsx)("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }), (0, jsx_runtime_1.jsx)("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" })] }), (0, jsx_runtime_1.jsx)("p", { className: `mt-4 ${colors.muted}`, children: "Loading..." })] }) }));
|
|
227
|
+
}
|
|
228
|
+
function LoginPage() {
|
|
229
|
+
return ((0, jsx_runtime_1.jsx)(react_2.Suspense, { fallback: (0, jsx_runtime_1.jsx)(LoginPageFallback, {}), children: (0, jsx_runtime_1.jsx)(LoginForm, {}) }));
|
|
230
|
+
}
|