Skip to content

Commit 4dfe81b

Browse files
committed
Redirects for already logged-in users in connect-next playground
1 parent 1049a29 commit 4dfe81b

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

playground/connect-next/app/(no-auth)/login/ConventionalLogin.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ export const ConventionalLogin = ({ initialUserProvidedIdentifier, initialError
4646
}
4747
} catch (e) {
4848
if (e instanceof Error) {
49+
if (e.name === 'UserAlreadyAuthenticatedException') {
50+
router.push('/profile');
51+
}
52+
4953
return e.message;
5054
}
5155

playground/connect-next/app/(no-auth)/page.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,14 @@ export default function SignupPage() {
3737
console.log(resLogin);
3838
router.push('/post-login?post-signup=true');
3939
} catch (err) {
40-
console.error('Error during signup:', err);
40+
if (err instanceof Error) {
41+
if (err.name === 'UserAlreadyAuthenticatedException') {
42+
router.push('/profile');
43+
return;
44+
}
45+
}
46+
47+
console.error('Unhandled error during signup:', err);
4148
}
4249
};
4350

0 commit comments

Comments
 (0)