From cb23613cdc1214bd98c00756aa3c9e61cfe57b0e Mon Sep 17 00:00:00 2001 From: Hongbo Wu Date: Tue, 26 Jul 2022 14:06:11 +0800 Subject: [PATCH] Add Set-Cookie header --- packages/api/src/routers/auth/auth_router.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/api/src/routers/auth/auth_router.ts b/packages/api/src/routers/auth/auth_router.ts index ad19c9b1e..693e3861c 100644 --- a/packages/api/src/routers/auth/auth_router.ts +++ b/packages/api/src/routers/auth/auth_router.ts @@ -420,6 +420,13 @@ export function authRouter() { // set auth cookie in response header await setAuthInCookie({ uid: user.id }, res) + const cookie = res.get('cookie') + if (!cookie) { + return res.redirect( + `${env.client.url}/email-login?errorCodes=${LoginErrorCode.AuthFailed}` + ) + } + res.setHeader('set-cookie', cookie) await handleSuccessfulLogin(req, res, user, false) } catch (e) { logger.info('email-login exception:', e)