Updated formatting

This commit is contained in:
2019-07-25 00:24:04 +02:00
parent 144b27f128
commit e19cfb5870
2 changed files with 10 additions and 10 deletions

View File

@@ -8,16 +8,16 @@ const Token = require('src/user/token');
// curl -i -H "Authorization:[token]" localhost:31459/api/v1/user/history // curl -i -H "Authorization:[token]" localhost:31459/api/v1/user/history
const tokenToUser = (req, res, next) => { const tokenToUser = (req, res, next) => {
const rawToken = req.headers.authorization; const rawToken = req.headers.authorization;
if (rawToken) { if (rawToken) {
try { try {
const token = Token.fromString(rawToken, secret); const token = Token.fromString(rawToken, secret);
req.loggedInUser = token.user; req.loggedInUser = token.user;
} catch (error) { } catch (error) {
req.loggedInUser = undefined; req.loggedInUser = undefined;
} }
} }
next(); next();
}; };
module.exports = tokenToUser; module.exports = tokenToUser;