mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-14 21:41:09 +02:00
fix(shared-auth): set SSO session cookie on login
The signIn() method only called the custom /api/v1/auth/login endpoint which returns JWT tokens but doesn't set a session cookie. Without the cookie, cross-subdomain SSO (trySSO) can never find an active session. Now also calls Better Auth's native /api/auth/sign-in/email with credentials:'include' after successful login, which sets the session cookie with Domain=.mana.how for cross-subdomain SSO. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
5c9e16f634
commit
720602343e
1 changed files with 13 additions and 0 deletions
|
|
@ -95,6 +95,19 @@ export function createAuthService(config: AuthServiceConfig) {
|
|||
storage.setItem(storageKeys.USER_EMAIL, email),
|
||||
]);
|
||||
|
||||
// Also sign in via Better Auth native endpoint to set session cookie
|
||||
// This enables cross-subdomain SSO (cookie shared across *.mana.how)
|
||||
try {
|
||||
await fetch(`${baseUrl}/api/auth/sign-in/email`, {
|
||||
method: 'POST',
|
||||
credentials: 'include',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ email, password }),
|
||||
});
|
||||
} catch {
|
||||
// SSO cookie is nice-to-have, don't fail login if this fails
|
||||
}
|
||||
|
||||
return { success: true };
|
||||
} catch (error) {
|
||||
console.error('Error signing in:', error);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue