fix: hide registration option when sign-in mode is SignIn only
Fetch /api/.well-known/sign-in-exp on mount and check signInMode. If not SignInAndRegister, hide the "Sign up" link and force sign-in mode (even if ?first_screen=register was in the URL). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -61,6 +61,7 @@ function getInitialMode(): Mode {
|
||||
|
||||
export function SignInPage() {
|
||||
const [mode, setMode] = useState<Mode>(getInitialMode);
|
||||
const [registrationEnabled, setRegistrationEnabled] = useState(true);
|
||||
const subtitle = useMemo(
|
||||
() => pickRandom(mode === 'signIn' ? SIGN_IN_SUBTITLES : REGISTER_SUBTITLES),
|
||||
[mode === 'signIn' ? 'signIn' : 'register'],
|
||||
@@ -75,6 +76,18 @@ export function SignInPage() {
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [verificationId, setVerificationId] = useState('');
|
||||
|
||||
// Fetch sign-in experience to check if registration is enabled
|
||||
useEffect(() => {
|
||||
fetch('/api/.well-known/sign-in-exp')
|
||||
.then((r) => r.json())
|
||||
.then((data) => {
|
||||
const enabled = data.signInMode === 'SignInAndRegister';
|
||||
setRegistrationEnabled(enabled);
|
||||
if (!enabled && mode !== 'signIn') setMode('signIn');
|
||||
})
|
||||
.catch(() => {});
|
||||
}, []);
|
||||
|
||||
// Reset error when switching modes
|
||||
useEffect(() => { setError(null); }, [mode]);
|
||||
|
||||
@@ -211,12 +224,14 @@ export function SignInPage() {
|
||||
Sign in
|
||||
</Button>
|
||||
|
||||
<p className={styles.switchText}>
|
||||
Don't have an account?{' '}
|
||||
<button type="button" className={styles.switchLink} onClick={() => switchMode('register')}>
|
||||
Sign up
|
||||
</button>
|
||||
</p>
|
||||
{registrationEnabled && (
|
||||
<p className={styles.switchText}>
|
||||
Don't have an account?{' '}
|
||||
<button type="button" className={styles.switchLink} onClick={() => switchMode('register')}>
|
||||
Sign up
|
||||
</button>
|
||||
</p>
|
||||
)}
|
||||
</form>
|
||||
)}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user