You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

12 lines
324 B
JavaScript

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();
};