@payez/next-mvp 4.5.7 → 4.7.10

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.
Files changed (68) hide show
  1. package/dist/api-handlers/auth/credential-login-email-code.d.ts +24 -0
  2. package/dist/api-handlers/auth/credential-login-email-code.js +83 -0
  3. package/dist/api-handlers/auth/credential-login.d.ts +41 -0
  4. package/dist/api-handlers/auth/credential-login.js +858 -0
  5. package/dist/api-handlers/oauth/resume.d.ts +16 -0
  6. package/dist/api-handlers/oauth/resume.js +207 -0
  7. package/dist/auth/better-auth.d.ts +14 -2
  8. package/dist/auth/better-auth.js +59 -34
  9. package/dist/auth/idp-oauth.d.ts +106 -0
  10. package/dist/auth/idp-oauth.js +280 -0
  11. package/dist/auth/safe-callback.js +10 -2
  12. package/dist/client/AuthContext.d.ts +2 -0
  13. package/dist/client/AuthContext.js +14 -1
  14. package/dist/components/auth/CredentialSignInForm.d.ts +33 -0
  15. package/dist/components/auth/CredentialSignInForm.js +134 -0
  16. package/dist/components/auth/ModeAwareLoginPage.js +4 -1
  17. package/dist/components/auth/ModeAwareSignupPage.js +7 -22
  18. package/dist/lib/authorize-resume.d.ts +87 -0
  19. package/dist/lib/authorize-resume.js +190 -0
  20. package/dist/lib/bearer-fetch.d.ts +17 -0
  21. package/dist/lib/bearer-fetch.js +32 -0
  22. package/dist/lib/code-step-copy.d.ts +53 -0
  23. package/dist/lib/code-step-copy.js +73 -0
  24. package/dist/lib/credential-sign-in-client.d.ts +59 -0
  25. package/dist/lib/credential-sign-in-client.js +89 -0
  26. package/dist/lib/device-id.d.ts +37 -0
  27. package/dist/lib/device-id.js +70 -0
  28. package/dist/lib/lock-window.d.ts +29 -0
  29. package/dist/lib/lock-window.js +53 -0
  30. package/dist/lib/login-error-message.d.ts +18 -0
  31. package/dist/lib/login-error-message.js +47 -0
  32. package/dist/lib/twofa-rejection.d.ts +20 -0
  33. package/dist/lib/twofa-rejection.js +73 -0
  34. package/dist/middleware/create-middleware.d.ts +12 -1
  35. package/dist/middleware/create-middleware.js +19 -5
  36. package/dist/pages/login/page.js +11 -37
  37. package/dist/routes/auth/credential-login-email-code.d.ts +6 -0
  38. package/dist/routes/auth/credential-login-email-code.js +10 -0
  39. package/dist/routes/auth/credential-login.d.ts +6 -0
  40. package/dist/routes/auth/credential-login.js +10 -0
  41. package/dist/routes/oauth/resume.d.ts +11 -0
  42. package/dist/routes/oauth/resume.js +16 -0
  43. package/dist/types/auth.d.ts +6 -0
  44. package/package.json +1102 -1047
  45. package/src/api-handlers/auth/credential-login-email-code.ts +92 -0
  46. package/src/api-handlers/auth/credential-login.ts +948 -0
  47. package/src/api-handlers/oauth/resume.ts +182 -0
  48. package/src/auth/better-auth.ts +81 -5
  49. package/src/auth/idp-oauth.ts +310 -0
  50. package/src/auth/safe-callback.ts +11 -2
  51. package/src/client/AuthContext.tsx +14 -1
  52. package/src/components/auth/CredentialSignInForm.tsx +240 -0
  53. package/src/components/auth/ModeAwareLoginPage.tsx +21 -1
  54. package/src/components/auth/ModeAwareSignupPage.tsx +38 -108
  55. package/src/lib/authorize-resume.ts +187 -0
  56. package/src/lib/bearer-fetch.ts +31 -0
  57. package/src/lib/code-step-copy.ts +83 -0
  58. package/src/lib/credential-sign-in-client.ts +101 -0
  59. package/src/lib/device-id.ts +67 -0
  60. package/src/lib/lock-window.ts +49 -0
  61. package/src/lib/login-error-message.ts +41 -0
  62. package/src/lib/twofa-rejection.ts +91 -0
  63. package/src/middleware/create-middleware.ts +35 -4
  64. package/src/pages/login/page.tsx +20 -34
  65. package/src/routes/auth/credential-login-email-code.ts +6 -0
  66. package/src/routes/auth/credential-login.ts +6 -0
  67. package/src/routes/oauth/resume.ts +11 -0
  68. package/src/types/auth.ts +6 -0
@@ -38,9 +38,15 @@ interface AuthProviderProps {
38
38
  useDynamicProviders?: boolean;
39
39
  }
40
40
 
41
+ /** PAY-2334: how long /api/auth/settings may take before the sign-in card stops waiting and says it could not load. */
42
+ export const SETTINGS_FETCH_TIMEOUT_MS = 10000;
43
+
41
44
  export function AuthProvider({ children, config, useDynamicProviders = true }: AuthProviderProps) {
42
45
  const [dynamicProviders, setDynamicProviders] = useState<FederatedProvider[]>([]);
43
46
  const [providersLoaded, setProvidersLoaded] = useState(!useDynamicProviders);
47
+ // PAY-2334: providersLoaded is true on failure too (it only means "stop waiting"), so it cannot tell an empty answer from
48
+ // no answer. This can: loading -> ready (answered) | failed (non-2xx, thrown, timed out).
49
+ const [settingsStatus, setSettingsStatus] = useState<'loading' | 'ready' | 'failed'>(useDynamicProviders ? 'loading' : 'ready');
44
50
 
45
51
  // What the IDP says this client offers. null until /api/auth/settings answers.
46
52
  const [serverSettings, setServerSettings] = useState<{
@@ -66,6 +72,9 @@ export function AuthProvider({ children, config, useDynamicProviders = true }: A
66
72
  let mounted = true;
67
73
 
68
74
  async function fetchDynamicProviders() {
75
+ const controller = new AbortController();
76
+ const timer = setTimeout(() => controller.abort(), SETTINGS_FETCH_TIMEOUT_MS);
77
+ let status: 'ready' | 'failed' = 'failed';
69
78
  try {
70
79
  // READ THE IDP. This used to be a hardcoded literal:
71
80
  // const result = { google: { id: 'google', name: 'Google' } };
@@ -75,7 +84,7 @@ export function AuthProvider({ children, config, useDynamicProviders = true }: A
75
84
  //
76
85
  // /api/auth/settings already serves the real answer (enabledProviders,
77
86
  // allowFederatedLogin, enablePasswordReset) and nothing consumed it.
78
- const response = await fetch('/api/auth/settings');
87
+ const response = await fetch('/api/auth/settings', { signal: controller.signal });
79
88
  if (!response.ok) {
80
89
  // No silent substitution. Absent settings means we do not know what this
81
90
  // client offers, and inventing a provider list is how a tenant ends up with a
@@ -98,6 +107,7 @@ export function AuthProvider({ children, config, useDynamicProviders = true }: A
98
107
  .map(id => PROVIDER_MAP[id])
99
108
  .filter((p): p is FederatedProvider => p !== undefined);
100
109
 
110
+ status = 'ready';
101
111
  setDynamicProviders(oauthProviders);
102
112
  setServerSettings({
103
113
  allowFederatedLogin: settings?.allowFederatedLogin !== false,
@@ -109,7 +119,9 @@ export function AuthProvider({ children, config, useDynamicProviders = true }: A
109
119
  } catch (err) {
110
120
  console.error('[AuthProvider] could not read /api/auth/settings:', err);
111
121
  } finally {
122
+ clearTimeout(timer);
112
123
  if (mounted) {
124
+ setSettingsStatus(status);
113
125
  setProvidersLoaded(true);
114
126
  }
115
127
  }
@@ -130,6 +142,7 @@ export function AuthProvider({ children, config, useDynamicProviders = true }: A
130
142
  ...defaultConfig,
131
143
  ...config,
132
144
  providers, // from the IDP when useDynamicProviders is on
145
+ settingsStatus: useDynamicProviders ? settingsStatus : 'ready',
133
146
  // THE SERVER DECIDES, THE SITE MAY OVERRIDE. A site that passes an explicit value
134
147
  // still wins; absent that, what the tenant's IDP reports is what renders. A client
135
148
  // hardcoding its own auth mode is how a sign-in screen and its IDP disagree.
@@ -0,0 +1,240 @@
1
+ 'use client';
2
+
3
+ import React, { useState } from 'react';
4
+ import { TraditionalAuthSection } from './TraditionalAuthSection';
5
+ import { safeCallbackPath } from '../../auth/safe-callback';
6
+ import { authorizeResumeHref } from '../../lib/authorize-resume';
7
+ import { NO_CODE_REQUEST, codeStepInstruction, type CodeRequest } from '../../lib/code-step-copy';
8
+ import {
9
+ credentialSignIn,
10
+ requestEmailCode,
11
+ validateCredentials,
12
+ type FetchLike,
13
+ } from '../../lib/credential-sign-in-client';
14
+
15
+ /**
16
+ * PAY-2302 cut 1b: the package's email + password (+ 2FA code) sign-in form.
17
+ *
18
+ * WHY IT EXISTS. The package's own Better Auth instance has no emailAndPassword, so the login page had no credential form
19
+ * (removed 2026-08-02, BAPert 17586: "restore this form together" with the backend that makes it work). This is that pair:
20
+ * the backend is routes/auth/credential-login (+ credential-login-email-code), which the app mounts at
21
+ * /api/auth/admin-login[/email-code]; this component drives it. Moved from the portal's AdminLoginCard (VibeID-Customer-Portal
22
+ * 3d654917), re-styled with the package's own TraditionalAuthSection instead of the portal's AuthCard chrome.
23
+ *
24
+ * MOUNT IT through the login page's slot, so nothing changes for a consumer that does not opt in:
25
+ * <LoginPage altAuthSlot={<CredentialSignInForm />} />
26
+ * (An app that has not mounted the two routes must NOT mount this form: it would be the dead control 17586 removed.)
27
+ *
28
+ * Two steps, the IdP's own contract (an access token with no refresh token means a second factor is outstanding):
29
+ * 'credentials' - email + password
30
+ * 'code' - the 2FA code; the door parks the provisional bearer in an httpOnly cookie, this step resubmits with the code.
31
+ *
32
+ * After success the browser goes to the callbackUrl, passed through safeCallbackPath (same-origin paths only); when the page
33
+ * carries ?return_url (an IdP authorize request) it goes to the app's /api/oauth/resume instead, which resumes that request.
34
+ */
35
+
36
+ interface Props {
37
+ /** Where to go after sign-in. Default: the page's ?callbackUrl, else /dashboard. Always passed through safeCallbackPath. */
38
+ callbackUrl?: string;
39
+ /** Test seam: the fetch used for both doors. */
40
+ fetchImpl?: FetchLike;
41
+ /** Test seam: navigation after success. */
42
+ onSignedIn?: (destination: string) => void;
43
+ showForgotPassword?: boolean;
44
+ }
45
+
46
+ const inputStyle: React.CSSProperties = {
47
+ borderColor: 'var(--border-default, #e5e7eb)',
48
+ color: 'var(--text-primary, #111827)',
49
+ background: 'var(--bg-input, white)',
50
+ };
51
+
52
+ export function resolveDestination(explicit?: string): string {
53
+ let raw = explicit;
54
+ let returnUrl: string | null = null;
55
+ if (typeof window !== 'undefined') {
56
+ const params = new URLSearchParams(window.location.search);
57
+ if (raw === undefined) raw = params.get('callbackUrl') ?? undefined;
58
+ // PAY-2302 cut 2: an IdP that sent the user here mid-authorize (?return_url=<IdP authorize request>) must get the
59
+ // authorize request resumed after sign-in. The href points at the app's OWN /api/oauth/resume, which validates the
60
+ // URL against IDP_URL server-side; nothing absolute is navigated to from here, and the result is still guarded.
61
+ returnUrl = params.get('return_url');
62
+ }
63
+ return safeCallbackPath(authorizeResumeHref(returnUrl), safeCallbackPath(raw, '/dashboard'));
64
+ }
65
+
66
+ export function CredentialSignInForm({ callbackUrl, fetchImpl, onSignedIn, showForgotPassword = false }: Props) {
67
+ const [step, setStep] = useState<'credentials' | 'code'>('credentials');
68
+ const [email, setEmail] = useState('');
69
+ const [password, setPassword] = useState('');
70
+ const [code, setCode] = useState('');
71
+ const [busy, setBusy] = useState(false);
72
+ const [error, setError] = useState<string | null>(null);
73
+ const [fieldError, setFieldError] = useState<string | null>(null);
74
+ const [codeRequest, setCodeRequest] = useState<CodeRequest>(NO_CODE_REQUEST);
75
+ const [offerEmailCode, setOfferEmailCode] = useState(false);
76
+ const [emailCodeMsg, setEmailCodeMsg] = useState<string | null>(null);
77
+
78
+ async function submit(withCode?: string) {
79
+ setBusy(true);
80
+ setError(null);
81
+ setOfferEmailCode(false);
82
+ try {
83
+ const r = await credentialSignIn({ email, password, code: withCode }, fetchImpl);
84
+ if (r.kind === 'success') {
85
+ const destination = resolveDestination(callbackUrl);
86
+ if (onSignedIn) onSignedIn(destination);
87
+ else window.location.href = destination;
88
+ return;
89
+ }
90
+ if (r.kind === 'two_factor') {
91
+ setCodeRequest(r.codeRequest);
92
+ setStep('code');
93
+ return;
94
+ }
95
+ setError(r.message);
96
+ if (r.kind === 'error') setOfferEmailCode(r.offerEmailCode);
97
+ } finally {
98
+ setBusy(false);
99
+ }
100
+ }
101
+
102
+ function onCredentialsSubmit(e: React.FormEvent) {
103
+ e.preventDefault();
104
+ const invalid = validateCredentials(email, password);
105
+ if (invalid) {
106
+ setFieldError(invalid.email ?? invalid.password ?? null);
107
+ return;
108
+ }
109
+ setFieldError(null);
110
+ void submit();
111
+ }
112
+
113
+ function onCodeSubmit(e: React.FormEvent) {
114
+ e.preventDefault();
115
+ const trimmed = code.trim();
116
+ if (!trimmed) {
117
+ setFieldError('Enter your authentication code.');
118
+ return;
119
+ }
120
+ setFieldError(null);
121
+ void submit(trimmed);
122
+ }
123
+
124
+ function onBack() {
125
+ setStep('credentials');
126
+ setCodeRequest(NO_CODE_REQUEST);
127
+ setCode('');
128
+ setFieldError(null);
129
+ setError(null);
130
+ setOfferEmailCode(false);
131
+ setEmailCodeMsg(null);
132
+ }
133
+
134
+ async function askForEmailCode() {
135
+ setBusy(true);
136
+ setEmailCodeMsg(null);
137
+ try {
138
+ const r = await requestEmailCode(fetchImpl);
139
+ if (r.kind === 'requested') {
140
+ setCodeRequest(r.codeRequest);
141
+ setError(null);
142
+ setOfferEmailCode(false);
143
+ setEmailCodeMsg('We asked for a code to be emailed to you. Enter it above when it arrives.');
144
+ } else {
145
+ setEmailCodeMsg(r.message);
146
+ }
147
+ } finally {
148
+ setBusy(false);
149
+ }
150
+ }
151
+
152
+ const problem = fieldError ?? error;
153
+ const problemLine = problem && (
154
+ <p role="alert" data-testid="credential-sign-in-error" className="text-sm mt-3" style={{ color: 'var(--color-error, #ef4444)' }}>
155
+ {problem}
156
+ </p>
157
+ );
158
+
159
+ if (step === 'code') {
160
+ return (
161
+ <div data-testid="credential-sign-in-code-step" className="text-left">
162
+ <p className="text-sm mb-4" style={{ color: 'var(--text-primary, #111827)' }}>{codeStepInstruction(email, codeRequest)}</p>
163
+ <form onSubmit={onCodeSubmit} noValidate className="space-y-4">
164
+ <div>
165
+ <label htmlFor="credential-code" className="block text-sm font-medium mb-2" style={{ color: 'var(--text-primary, #111827)' }}>
166
+ Authentication code
167
+ </label>
168
+ <input
169
+ id="credential-code"
170
+ name="code"
171
+ type="text"
172
+ inputMode="numeric"
173
+ autoComplete="one-time-code"
174
+ required
175
+ placeholder="000000"
176
+ value={code}
177
+ disabled={busy}
178
+ onChange={(e) => {
179
+ setCode(e.target.value);
180
+ setFieldError(null);
181
+ }}
182
+ className="w-full px-4 py-3 rounded-lg border transition-colors focus:outline-none focus:ring-2 disabled:opacity-50"
183
+ style={inputStyle}
184
+ />
185
+ </div>
186
+ <button
187
+ type="submit"
188
+ disabled={busy}
189
+ className="w-full py-3 px-4 rounded-lg font-semibold focus:outline-none focus:ring-2 disabled:opacity-50 disabled:cursor-not-allowed transition-colors"
190
+ style={{ background: 'var(--btn-primary-bg, #11B588)', color: 'var(--btn-primary-text, white)' }}
191
+ >
192
+ {busy ? 'Verifying…' : 'Verify'}
193
+ </button>
194
+ </form>
195
+ <button type="button" onClick={onBack} disabled={busy} className="text-sm underline mt-4" style={{ background: 'none', border: 'none', padding: 0, color: 'var(--text-muted, #6b7280)' }}>
196
+ Back
197
+ </button>
198
+ {problemLine}
199
+ {(offerEmailCode || emailCodeMsg) && (
200
+ <div data-testid="email-code-offer" className="mt-4">
201
+ {offerEmailCode && (
202
+ <button type="button" onClick={() => void askForEmailCode()} disabled={busy} className="text-sm font-semibold underline" style={{ background: 'none', border: 'none', padding: 0, color: 'var(--text-primary, #111827)' }}>
203
+ Email me a code instead
204
+ </button>
205
+ )}
206
+ {emailCodeMsg && (
207
+ <p role="status" data-testid="email-code-offer-msg" className="text-sm mt-2" style={{ color: 'var(--text-primary, #111827)' }}>
208
+ {emailCodeMsg}
209
+ </p>
210
+ )}
211
+ </div>
212
+ )}
213
+ </div>
214
+ );
215
+ }
216
+
217
+ return (
218
+ <div data-testid="credential-sign-in" className="text-left">
219
+ <TraditionalAuthSection
220
+ email={email}
221
+ password={password}
222
+ onEmailChange={(v) => {
223
+ setEmail(v);
224
+ setFieldError(null);
225
+ }}
226
+ onPasswordChange={(v) => {
227
+ setPassword(v);
228
+ setFieldError(null);
229
+ }}
230
+ onSubmit={onCredentialsSubmit}
231
+ isLoading={busy}
232
+ buttonText="Sign in"
233
+ showForgotPassword={showForgotPassword}
234
+ />
235
+ {problemLine}
236
+ </div>
237
+ );
238
+ }
239
+
240
+ export default CredentialSignInForm;
@@ -105,7 +105,27 @@ export function ModeAwareLoginPage({
105
105
  and rendered BOTH sections on the same condition - so a client configured with
106
106
  no sign-in method at all got the full form. Say so instead: a blank card leaves
107
107
  the user pressing nothing, and the operator with no idea what is wrong. */}
108
- {!isFederated && !isTraditional && (
108
+ {!isFederated && !isTraditional && config.settingsStatus === 'loading' && (
109
+ <div role="status" className="px-4 py-3 rounded-lg text-sm text-left" style={{ color: 'var(--text-secondary, #6b7280)' }}>
110
+ <p>Loading sign-in options…</p>
111
+ </div>
112
+ )}
113
+
114
+ {!isFederated && !isTraditional && config.settingsStatus === 'failed' && (
115
+ <div
116
+ role="alert"
117
+ className="px-4 py-3 rounded-lg text-sm text-left"
118
+ style={{
119
+ border: '1px solid var(--border-default, #e5e7eb)',
120
+ color: 'var(--text-primary, #111827)',
121
+ }}
122
+ >
123
+ <p className="font-semibold">Could not load sign-in options.</p>
124
+ <p className="mt-1">Please reload the page. If it keeps happening, contact an administrator.</p>
125
+ </div>
126
+ )}
127
+
128
+ {!isFederated && !isTraditional && (config.settingsStatus ?? 'ready') === 'ready' && (
109
129
  <div
110
130
  role="alert"
111
131
  className="px-4 py-3 rounded-lg text-sm text-left"
@@ -154,116 +154,46 @@ export function ModeAwareSignupPage({
154
154
  </form>
155
155
  )}
156
156
 
157
- {/* Hybrid Mode - Show both */}
158
- {isFederated === false && isTraditional === false && (
159
- <>
160
- <FederatedAuthSection
161
- providers={config.providers}
162
- onProviderClick={handleFederatedClick}
163
- isLoading={totalLoading}
164
- />
165
-
166
- {config.providers.length > 0 && config.enableEmailSignup && (
167
- <div className="relative my-6">
168
- <div className="absolute inset-0 flex items-center">
169
- <div
170
- className="w-full"
171
- style={{
172
- borderTop: '1px solid var(--border-default)',
173
- }}
174
- ></div>
175
- </div>
176
- <div className="relative flex justify-center text-sm">
177
- <span
178
- className="px-2"
179
- style={{
180
- background: 'var(--bg-card)',
181
- color: 'var(--text-secondary)',
182
- }}
183
- >
184
- Or sign up with email
185
- </span>
186
- </div>
187
- </div>
188
- )}
189
-
190
- {config.enableEmailSignup && (
191
- <form onSubmit={handleTraditionalSubmit} className="space-y-4">
192
- <div>
193
- <label className="block text-sm font-medium mb-2" style={{ color: 'var(--text-primary)' }}>
194
- Email Address
195
- </label>
196
- <input
197
- type="email"
198
- value={email}
199
- onChange={(e) => setEmail(e.target.value)}
200
- placeholder="you@example.com"
201
- disabled={totalLoading}
202
- required
203
- className="w-full px-4 py-3 rounded-lg border transition-colors focus:outline-none focus:ring-2 disabled:opacity-50"
204
- style={{
205
- border: '1px solid var(--border-default)',
206
- color: 'var(--text-primary)',
207
- background: 'var(--bg-default)',
208
- }}
209
- />
210
- </div>
211
-
212
- <div>
213
- <label className="block text-sm font-medium mb-2" style={{ color: 'var(--text-primary)' }}>
214
- Password
215
- </label>
216
- <input
217
- type="password"
218
- value={password}
219
- onChange={(e) => setPassword(e.target.value)}
220
- placeholder="••••••••"
221
- disabled={totalLoading}
222
- required
223
- className="w-full px-4 py-3 rounded-lg border transition-colors focus:outline-none focus:ring-2 disabled:opacity-50"
224
- style={{
225
- border: '1px solid var(--border-default)',
226
- color: 'var(--text-primary)',
227
- background: 'var(--bg-default)',
228
- }}
229
- />
230
- </div>
157
+ {/* PAY-2334: same three states as the login page. Not answered yet -> neutral text; read failed -> say so;
158
+ only an ANSWERED "nothing offered" falls through to the branch below. */}
159
+ {!isFederated && !isTraditional && config.settingsStatus === 'loading' && (
160
+ <div role="status" className="px-4 py-3 rounded-lg text-sm text-left" style={{ color: 'var(--text-secondary, #6b7280)' }}>
161
+ <p>Loading sign-up options…</p>
162
+ </div>
163
+ )}
231
164
 
232
- <div>
233
- <label className="block text-sm font-medium mb-2" style={{ color: 'var(--text-primary)' }}>
234
- Confirm Password
235
- </label>
236
- <input
237
- type="password"
238
- value={confirmPassword}
239
- onChange={(e) => setConfirmPassword(e.target.value)}
240
- placeholder="••••••••"
241
- disabled={totalLoading}
242
- required
243
- className="w-full px-4 py-3 rounded-lg border transition-colors focus:outline-none focus:ring-2 disabled:opacity-50"
244
- style={{
245
- border: '1px solid var(--border-default)',
246
- color: 'var(--text-primary)',
247
- background: 'var(--bg-default)',
248
- }}
249
- />
250
- </div>
165
+ {!isFederated && !isTraditional && config.settingsStatus === 'failed' && (
166
+ <div
167
+ role="alert"
168
+ className="px-4 py-3 rounded-lg text-sm text-left"
169
+ style={{
170
+ border: '1px solid var(--border-default, #e5e7eb)',
171
+ color: 'var(--text-primary, #111827)',
172
+ }}
173
+ >
174
+ <p className="font-semibold">Could not load sign-up options.</p>
175
+ <p className="mt-1">Please reload the page. If it keeps happening, contact an administrator.</p>
176
+ </div>
177
+ )}
251
178
 
252
- <button
253
- type="submit"
254
- disabled={totalLoading}
255
- className="w-full py-3 px-4 rounded-lg font-semibold focus:outline-none focus:ring-2 disabled:opacity-50 disabled:cursor-not-allowed transition-colors mt-6"
256
- style={{
257
- border: '1px solid var(--border-default)',
258
- color: 'white',
259
- background: 'var(--color-primary, #10b981)',
260
- }}
261
- >
262
- {totalLoading ? 'Creating Account...' : 'Create Account'}
263
- </button>
264
- </form>
265
- )}
266
- </>
179
+ {/* PAY-2341: ANSWERED, and nothing is offered. This branch used to be labelled "Hybrid Mode - Show both" and
180
+ rendered the federated section plus the email sign-up form on the same "neither" condition, so a client with no
181
+ sign-up method showed a working-looking form. Say so, as the login page does (ModeAwareLoginPage). */}
182
+ {!isFederated && !isTraditional && (config.settingsStatus ?? 'ready') === 'ready' && (
183
+ <div
184
+ role="alert"
185
+ className="px-4 py-3 rounded-lg text-sm text-left"
186
+ style={{
187
+ border: '1px solid var(--border-default, #e5e7eb)',
188
+ color: 'var(--text-primary, #111827)',
189
+ }}
190
+ >
191
+ <p className="font-semibold">Sign-up is not available for this application.</p>
192
+ <p className="mt-1">
193
+ No sign-up method is enabled for this client. An administrator needs to enable
194
+ a federated provider or username and password sign-in.
195
+ </p>
196
+ </div>
267
197
  )}
268
198
  </>
269
199
  );