Refactor with base actions methods
This commit is contained in:
@@ -4,7 +4,8 @@
|
||||
|
||||
const StrategyJWT = require(`passport-jwt`).Strategy;
|
||||
const ExtractJWT = require(`passport-jwt`).ExtractJwt;
|
||||
const { users } = require(`../models`);
|
||||
const userUtils = require(`../controllers/users/utils`);
|
||||
const db = require(`../db`);
|
||||
|
||||
module.exports = (passport) => {
|
||||
const options = {};
|
||||
@@ -15,7 +16,7 @@ module.exports = (passport) => {
|
||||
new StrategyJWT(options, async (jwtPayload, done) => {
|
||||
let user;
|
||||
try {
|
||||
user = await users.getById(jwtPayload.id);
|
||||
user = await db.getById(`user`, jwtPayload.id);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
return done(error, null);
|
||||
@@ -24,7 +25,7 @@ module.exports = (passport) => {
|
||||
if (!user) {
|
||||
return done(null, false);
|
||||
}
|
||||
return done(null, users.convertToPublicFormat(user));
|
||||
return done(null, userUtils.convertToPublicFormat(user));
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user