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() {
|
export function SignInPage() {
|
||||||
const [mode, setMode] = useState<Mode>(getInitialMode);
|
const [mode, setMode] = useState<Mode>(getInitialMode);
|
||||||
|
const [registrationEnabled, setRegistrationEnabled] = useState(true);
|
||||||
const subtitle = useMemo(
|
const subtitle = useMemo(
|
||||||
() => pickRandom(mode === 'signIn' ? SIGN_IN_SUBTITLES : REGISTER_SUBTITLES),
|
() => pickRandom(mode === 'signIn' ? SIGN_IN_SUBTITLES : REGISTER_SUBTITLES),
|
||||||
[mode === 'signIn' ? 'signIn' : 'register'],
|
[mode === 'signIn' ? 'signIn' : 'register'],
|
||||||
@@ -75,6 +76,18 @@ export function SignInPage() {
|
|||||||
const [error, setError] = useState<string | null>(null);
|
const [error, setError] = useState<string | null>(null);
|
||||||
const [verificationId, setVerificationId] = useState('');
|
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
|
// Reset error when switching modes
|
||||||
useEffect(() => { setError(null); }, [mode]);
|
useEffect(() => { setError(null); }, [mode]);
|
||||||
|
|
||||||
@@ -211,12 +224,14 @@ export function SignInPage() {
|
|||||||
Sign in
|
Sign in
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<p className={styles.switchText}>
|
{registrationEnabled && (
|
||||||
Don't have an account?{' '}
|
<p className={styles.switchText}>
|
||||||
<button type="button" className={styles.switchLink} onClick={() => switchMode('register')}>
|
Don't have an account?{' '}
|
||||||
Sign up
|
<button type="button" className={styles.switchLink} onClick={() => switchMode('register')}>
|
||||||
</button>
|
Sign up
|
||||||
</p>
|
</button>
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
</form>
|
</form>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user