Migrated the authenticate.ts middleware
This commit is contained in:
parent
0d83a0f670
commit
51e7b2562d
@ -18,11 +18,11 @@ module.exports.authenticate = async (req: AuthenticatedRequest, res: Response, n
|
||||
if (splitHeader.length !== 2) return res.status(400).json({message: "You need to provide the token in the 'authorization' header"});
|
||||
|
||||
// Check if the provided token is wrong
|
||||
req.token = await Token.findOne({token: splitHeader[1]}).exec() as IToken;
|
||||
req.token = await Token.findOne({where: {token: splitHeader[1]}}) as IToken;
|
||||
if (req.token == null) return res.status(401).json({message: "The provided token is wrong"});
|
||||
|
||||
// Check if the provided user exists
|
||||
req.user = await User.findOne({clientId: req.token.clientId}) as IUser;
|
||||
req.user = await User.findOne({where: {clientId: req.token.clientId}}) as IUser;
|
||||
if (req.user == null) return res.status(401).json({message: "The provided token is wrong"});
|
||||
|
||||
next();
|
||||
|
Loading…
x
Reference in New Issue
Block a user