Skip to content

Commit

Permalink
tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
eirslett committed May 19, 2024
1 parent 6755bb3 commit a03d5d2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
8 changes: 2 additions & 6 deletions backend/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,9 @@ 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));
console.log('found cookies: ', Object.keys(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 All @@ -171,7 +167,7 @@ export async function authMiddleware(req, res, next) {
issuer,
audience,
});
console.log('cookie payload', payload);
console.log('validated OK, setting UNREED_USER to', payload.email);
res.cookie(UNREED_USER, payload.email, { path: '/', maxAge: maxAge * 1000, httpOnly: false });
req.user = { email: payload.email };
}
Expand Down
3 changes: 2 additions & 1 deletion frontend/components/App/App.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { StrictMode, ReactNode } from 'react';
import { createBrowserRouter, RouterProvider } from 'react-router-dom';
import { createBrowserRouter, RouterProvider, ScrollRestoration } from 'react-router-dom';
import { Auth } from '../Auth/Auth';
import { Layout, LayoutTopbar, LayoutContent } from '../Layout/Layout';
import { DiscardedReeds, ReedOverview } from '../ReedOverview/ReedOverview';
Expand All @@ -24,6 +24,7 @@ const router = createBrowserRouter([
path: '/',
element: (
<Shell>
<ScrollRestoration />
<ReedOverview />
</Shell>
),
Expand Down

0 comments on commit a03d5d2

Please sign in to comment.