add flash message
This commit is contained in:
@@ -15,7 +15,7 @@ export const authMiddleware = async (
|
||||
const strategy = authenticator.get<OAuth2Strategy<User>>('oidc')
|
||||
const session = await sessionStorage.getSession(request.headers.get('cookie'))
|
||||
const requestId = context.get(requestIdContext)
|
||||
let user = session.get('user') as User | null
|
||||
let user = session.get('user')
|
||||
|
||||
if (!user) {
|
||||
console.log('There is no user logged in')
|
||||
@@ -67,7 +67,11 @@ export const authMiddleware = async (
|
||||
context.set(userContext, user)
|
||||
|
||||
const response = await next()
|
||||
const sessionCookie = await sessionStorage.commitSession(session)
|
||||
response.headers.set('Set-Cookie', sessionCookie)
|
||||
|
||||
if (!response.headers.has('Set-Cookie')) {
|
||||
const sessionCookie = await sessionStorage.commitSession(session)
|
||||
response.headers.set('Set-Cookie', sessionCookie)
|
||||
}
|
||||
|
||||
return response
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user