|
|
@ -29,18 +29,15 @@ export default function register(factory: RouteRegisterFactory<MiddlewareMethod< |
|
|
|
} |
|
|
|
let body = { id: user.id, name: user.name, isAdmin: user.isAdmin }; |
|
|
|
let token = jwt.sign(body, app.APP_KEY, { expiresIn: 60*60*24 }); |
|
|
|
// Below code requires SSH to store cookies securely
|
|
|
|
// Store the header/payload in the client, store the signature in a secure httpOnly cookie
|
|
|
|
// if ((<any>request.query)["use_cookies"] || (<any>request.query)["use_cookies"] === undefined) {
|
|
|
|
// let [header, payload, signature] = token.split('.');
|
|
|
|
// token = `${header}.${payload}`;
|
|
|
|
// reply.setCookie("jwt_signature", signature, {
|
|
|
|
// path: '/',
|
|
|
|
// httpOnly: true,
|
|
|
|
// sameSite: true,
|
|
|
|
// secure: true
|
|
|
|
// });
|
|
|
|
// }
|
|
|
|
let [header, payload, signature] = token.split('.'); |
|
|
|
token = `${header}.${payload}`; |
|
|
|
reply.setCookie("jwt_signature", signature, { |
|
|
|
path: '/', |
|
|
|
httpOnly: true, |
|
|
|
sameSite: true, |
|
|
|
secure: process.env["NODE_ENV"] === "production" |
|
|
|
}); |
|
|
|
respond(reply, Status.Ok, { token }); |
|
|
|
})); |
|
|
|
|
|
|
|