add auth middleware

master
adb-sh 2 years ago
parent 3e42a7c37b
commit 5ecff037dc

@ -0,0 +1,11 @@
import { store } from "../store.mjs";
export const auth = (req, res, next) => {
const accessToken = req.headers['access-token'];
res.locals.user = store.users.find(user => user.accessToken === accessToken);
if (!res.locals.user) {
res.status(401);
res.send({ message: 'unauthorized' });
}
else next();
};

@ -1 +1 @@
Subproject commit a86bd04da25c3715e7853cd1158b7e4929eacad4
Subproject commit e4de1997a3c34a9fb96136e82446ee926104c3d0
Loading…
Cancel
Save