-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(auth): correction du bug qui fait que le contenu du json qui ne s…
…'affiche pas + authentification à chaque refresh (#1065) * fix: fix * fix: json * fix: json * fix: auth * fix: auth * fix: auth * fix: auth * fix: auth * version * fix: code * fix: code * fix: enfin ? * fix: enfin ? * fix: enfin ? * fix: enfin ? * fix: enfin ? * fix: enfin ? * fix: enfin ? * fix: enfin ? * fix: enfin ? * fix: bug * fix: bug * fix: bug * fix: bug * fix: bug * fix: bug * fix: bug * fix: bug * fix: bug * fix: bug * fix: bug * fix: bug * fix: bug * fix: merge * fix: merge * fix: merge * fix: merge * fix: merge * fix: docker v * fix: ommmmmmg * fix: ommmmmmg * fix: ommmmmmg * fix: ommmmmmg * fix: ommmmmmg * fix: ommmmmmg * fix: ommmmmmg * fix: token * fix: token * fix: token * fix: token * fix: token * fix: token * fix: token * fix: url * fix: url * fix: url * fix: url * fix: types * fix: types * fix: expected by snapshot * fix: expected by snapshot * fix: expected by snapshot * fix: undici * fix: merge * fix: merge * fix: delete error * fix: delete error * fix: delete error * fix: delete error * Update targets/frontend/src/hoc/UserProvider.js Co-authored-by: Caroline <[email protected]> --------- Co-authored-by: Caroline <[email protected]>
- Loading branch information
1 parent
0c77583
commit 86f146e
Showing
30 changed files
with
407 additions
and
415 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
20 | ||
20.3.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,3 @@ export const ACCOUNT_MAIL_SENDER = "[email protected]"; | |
export const JWT_TOKEN_EXPIRES = 15; // 15 min | ||
export const REFRESH_TOKEN_EXPIRES = 43200; // 30 days in minutes | ||
export const ACTIVATION_TOKEN_EXPIRES = 10080; // 7 days in minutes | ||
export const HASURA_GRAPHQL_JWT_SECRET = | ||
process.env.HASURA_GRAPHQL_JWT_SECRET ?? | ||
'{"type":"HS256","key":"a_pretty_long_secret_key_that_should_be_at_least_32_char"}'; | ||
export const BASE_URL = process.env.FRONTEND_HOST || `http://localhost:3000`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import cookie from "cookie"; | ||
import { REFRESH_TOKEN_EXPIRES } from "src/config"; | ||
|
||
export function setJwtCookie( | ||
res: any, | ||
refresh_token?: string, | ||
jwt_token?: string | ||
) { | ||
const cookies = []; | ||
try { | ||
if (refresh_token) { | ||
cookies.push( | ||
cookie.serialize("refresh_token", refresh_token, { | ||
httpOnly: true, | ||
maxAge: REFRESH_TOKEN_EXPIRES * 60, // maxAge in second | ||
path: "/", | ||
sameSite: "strict", | ||
secure: process.env.NODE_ENV === "production", | ||
}) | ||
); | ||
} | ||
if (jwt_token) { | ||
cookies.push( | ||
cookie.serialize("jwt", jwt_token, { | ||
httpOnly: true, | ||
path: "/", | ||
sameSite: "strict", | ||
secure: process.env.NODE_ENV === "production", | ||
}) | ||
); | ||
} | ||
if (cookies.length > 0) res.setHeader("Set-Cookie", cookies); | ||
} catch (err) { | ||
console.error("[setJwtCookie]", err); | ||
} | ||
} | ||
|
||
export function removeJwtCookie(res: any) { | ||
const cookies = [ | ||
cookie.serialize("refresh_token", "", { | ||
httpOnly: true, | ||
maxAge: -1, | ||
path: "/", | ||
sameSite: "strict", | ||
secure: process.env.NODE_ENV === "production", | ||
}), | ||
cookie.serialize("jwt", "", { | ||
httpOnly: true, | ||
maxAge: -1, | ||
path: "/", | ||
sameSite: "strict", | ||
secure: process.env.NODE_ENV === "production", | ||
}), | ||
]; | ||
res.setHeader("Set-Cookie", cookies); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.