Skip to content
Snippets Groups Projects
Commit fd6f0457 authored by Renzo Beux's avatar Renzo Beux
Browse files

Merge branch 'develop' into feature/audit

parents 7c5f67a6 e00975a4
No related branches found
No related tags found
No related merge requests found
MYSQL_USERNAME=root
MYSQL_PASSWORD=root
MYSQL_DB=repp_users
PORT = 4000
\ No newline at end of file
......@@ -140,6 +140,23 @@ const login = async (req: Request, res: Response): Promise<Response> => {
}
};
const validate = async (req: Request, res: Response): Promise<Response> => {
const { token } = req.body;
if (token) {
jwt.verify(token, secret.auth, (error: Error, decoded: {id: number; type: number}) => {
if (error) {
const message = 'Invalid token';
return res.status(401).send({ message });
}
const userId = decoded.id;
return res.status(200).send({ userId });
});
} else {
return res.status(400).send('auth token not supplied');
}
return res.status(500).send();
};
const listUsersById = async (req: Request, res: Response): Promise<Response> => {
try {
const { userIds } = req.body;
......@@ -157,6 +174,8 @@ router.route('/login')
router.route('/')
.post(create);
router.post('/validate', validate);
router.use('/', authorized);
router.route('/')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment