fix: update token expiration handling to use correct time units for cookies
This commit is contained in:
parent
d5894f6ec4
commit
128088abfd
3 changed files with 7 additions and 7 deletions
|
|
@ -137,7 +137,7 @@ const refreshAuthToken = async (
|
|||
);
|
||||
response.cookies.set(TOKEN_CONFIG.ACCESS_TOKEN_COOKIE_NAME, newAccessToken, {
|
||||
expires: add(new Date(), {
|
||||
minutes: TOKEN_CONFIG.ACCESS_TOKEN_COOKIE_EXPIRY,
|
||||
hours: TOKEN_CONFIG.ACCESS_TOKEN_COOKIE_EXPIRY,
|
||||
}),
|
||||
...TOKEN_CONFIG.COOKIE_OPTIONS,
|
||||
//secure: env.NODE_ENV === "production",
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
export const TOKEN_CONFIG = {
|
||||
ACCESS_TOKEN_COOKIE_NAME: "access_token",
|
||||
REFRESH_TOKEN_COOKIE_NAME: "refresh_token",
|
||||
ACCESS_TOKEN_EXPIRY: "5m",
|
||||
ACCESS_TOKEN_EXPIRY: "1h",
|
||||
REFRESH_TOKEN_EXPIRY: "7d",
|
||||
ACCESS_TOKEN_COOKIE_EXPIRY: 5,
|
||||
ACCESS_TOKEN_COOKIE_EXPIRY: 1,
|
||||
REFRESH_TOKEN_COOKIE_EXPIRY: 7,
|
||||
COOKIE_OPTIONS: {
|
||||
httpOnly: true,
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ export const logIn = async ({
|
|||
await setCookie(TOKEN_CONFIG.ACCESS_TOKEN_COOKIE_NAME, accessToken, {
|
||||
...TOKEN_CONFIG.COOKIE_OPTIONS,
|
||||
expires: add(new Date(), {
|
||||
minutes: TOKEN_CONFIG.ACCESS_TOKEN_COOKIE_EXPIRY,
|
||||
hours: TOKEN_CONFIG.ACCESS_TOKEN_COOKIE_EXPIRY,
|
||||
}),
|
||||
req,
|
||||
res,
|
||||
|
|
@ -151,7 +151,7 @@ export const logIn = async ({
|
|||
await setCookie(TOKEN_CONFIG.REFRESH_TOKEN_COOKIE_NAME, refreshToken, {
|
||||
...TOKEN_CONFIG.COOKIE_OPTIONS,
|
||||
expires: add(new Date(), {
|
||||
minutes: TOKEN_CONFIG.REFRESH_TOKEN_COOKIE_EXPIRY,
|
||||
days: TOKEN_CONFIG.REFRESH_TOKEN_COOKIE_EXPIRY,
|
||||
}),
|
||||
req,
|
||||
res,
|
||||
|
|
@ -206,7 +206,7 @@ export const swapAuth = async ({
|
|||
await setCookie(TOKEN_CONFIG.ACCESS_TOKEN_COOKIE_NAME, accessToken, {
|
||||
...TOKEN_CONFIG.COOKIE_OPTIONS,
|
||||
expires: add(new Date(), {
|
||||
minutes: TOKEN_CONFIG.ACCESS_TOKEN_COOKIE_EXPIRY,
|
||||
hours: TOKEN_CONFIG.ACCESS_TOKEN_COOKIE_EXPIRY,
|
||||
}),
|
||||
req,
|
||||
res,
|
||||
|
|
@ -214,7 +214,7 @@ export const swapAuth = async ({
|
|||
await setCookie(TOKEN_CONFIG.REFRESH_TOKEN_COOKIE_NAME, refreshToken, {
|
||||
...TOKEN_CONFIG.COOKIE_OPTIONS,
|
||||
expires: add(new Date(), {
|
||||
minutes: TOKEN_CONFIG.REFRESH_TOKEN_COOKIE_EXPIRY,
|
||||
days: TOKEN_CONFIG.REFRESH_TOKEN_COOKIE_EXPIRY,
|
||||
}),
|
||||
req,
|
||||
res,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue