Remove auth folder / passport stuff

This commit is contained in:
rijkvanzanten
2020-06-23 15:44:50 -04:00
parent 34e105397f
commit 8387d4ffd3
2 changed files with 0 additions and 29 deletions

View File

@@ -1,6 +0,0 @@
import passport from 'passport';
import JWTStrategy from './strategies/jwt';
passport.use(JWTStrategy);
export default passport;

View File

@@ -1,23 +0,0 @@
import { Strategy, ExtractJwt } from 'passport-jwt';
import database from '../../database';
import APIError, { ErrorCode } from '../../error';
const JWTStrategy = new Strategy(
{
secretOrKey: process.env.SECRET,
jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
},
async (payload, done) => {
// This is just an extra verification to make sure the user actually exists when you're trying to
// use it
const users = await database.select('id').from('directus_users').where({ id: payload.id });
if (users && users[0]) {
return done(null, users[0]);
}
return done(new APIError(ErrorCode.USER_NOT_FOUND, 'User not found.'));
}
);
export default JWTStrategy;