mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 07:57:07 +00:00
Set response auth headers conditionally
This commit is contained in:
@@ -43,8 +43,14 @@ function issue (payload, req, res) {
|
||||
}
|
||||
|
||||
if (res) {
|
||||
res.set("X-JWT", token);
|
||||
res.set("Set-Cookie", `JWT=${token}`); // For good measure
|
||||
if (token) {
|
||||
res.set("X-JWT", token);
|
||||
const expiry = payload.exp ? (new Date(payload.exp*1000)).toUTCString() : null;
|
||||
const cookie = expiry
|
||||
? `JWT=${token}; path=/; SameSite=lax; expires=${expiry}`
|
||||
: `JWT=${token}; path=/; SameSite=lax`
|
||||
res.set("Set-Cookie", cookie); // For good measure
|
||||
}
|
||||
}
|
||||
|
||||
return token;
|
||||
|
||||
Reference in New Issue
Block a user