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.

15 lines
424 B
JavaScript

import { UserStore } from "../db/schemas.mjs";
export const auth = async (req, res, next) => {
const accessToken = req.headers['access-token'];
res.locals.user = await UserStore.findOne().byAccessToken(accessToken);
if (!res.locals.user) {
res.status(401);
res.send({ message: 'unauthorized' });
return;
}
console.log('middleware', res.locals.user, await res.locals.user.spotify.local);
next();
};