nuxt-iam
nuxt-iam copied to clipboard
Problem with Reauthentication (setCookie)
Hello.
In file \server\middleware\iam\authentication\index.ts we call 2 functions:
- const authenticated = await isAuthenticated(event)
- await getUserFromAccessToken(event)
In first function we setCookie if we reauthenticate user:
setCookie(event, 'iam-access-token', 'Bearer ' + tokens.accessToken, { httpOnly: true, secure: true })
, but when we read this cookies in second function:
getCookie(event, "iam-access-token") as string;
we got an old value until next request.
I thought that it must be some time between set and get cookies and have added pause-function for 10sec, but problem still there. Cookie don't want to set until next request.