Skip to content

Commit

Permalink
More logging, add extra cookie call
Browse files Browse the repository at this point in the history
  • Loading branch information
eirslett committed May 19, 2024
1 parent 1e6ca17 commit 3d89b5f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions backend/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ async function productionCallbackPage(req, res) {
path: '/',
secure: true,
});
res.cookie(UNREED_USER, claims.email, { path: '/', maxAge: maxAge * 1000, httpOnly: false });

res.clearCookie(REDIRECT_URI_COOKIE);
res.clearCookie(AUTH_NONCE_COOKIE);
res.redirect(req.cookies.UNREED_REDIRECT_URI ?? '/');
Expand All @@ -152,8 +154,13 @@ if (isDevelopment()) {
authRouter.get('/login/callback', productionCallbackPage);
}

console.log('authMiddleware defined');
export async function authMiddleware(req, res, next) {
console.log('authMiddleware()');
console.log('req.cookies is ', typeof req.cookies);
console.log('found cookies: ', Object.entries(req.cookies));
const token = req.cookies[AUTH_COOKIE];
console.log('token is ', typeof token);
try {
if (!token) {
console.log('no token found - remove UNREED_USER cookie');
Expand Down

0 comments on commit 3d89b5f

Please sign in to comment.