mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 13:37:07 +00:00
Fix user authentication.
* Use X-JWT header for sending authentication info both from server to client and from client to server. * Send token in body of login response. * Also use Set-Cookie: JWT=… so that calls that are not issued directly by Dougal (e.g. Deck.gl layers with a URL `data` property) work without having to jump through hoops. Closes #321
This commit is contained in:
@@ -6,8 +6,10 @@ async function login (req, res, next) {
|
||||
const {user, password} = req.body;
|
||||
const payload = await jwt.checkValidCredentials({user, password});
|
||||
if (payload) {
|
||||
jwt.issue(payload, req, res);
|
||||
res.status(204).send();
|
||||
const token = jwt.issue(payload, req, res);
|
||||
res.set("X-JWT", token);
|
||||
res.set("Set-Cookie", `JWT=${token}`); // For good measure
|
||||
res.status(200).send({token});
|
||||
next();
|
||||
return;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user