Alan Colon пре 7 година
родитељ
комит
74a2d99d34
2 измењених фајлова са 4 додато и 3 уклоњено
  1. 1 1
      lib/controllers/auth/login.js
  2. 3 2
      lib/database/index.js

+ 1 - 1
lib/controllers/auth/login.js

@@ -11,7 +11,7 @@ module.exports = {
     if (user) {
       const success = await bcrypt.compare(req.body.password, user.password)
       if (success) {
-        const permissions = _.chain(await user.getRoles())
+        const permissions = _.chain(await user.getRoles({paranoid: !config.hiddenRoles}))
           .map(role => (role.permissions || '').split(','))
           .flatten()
           .uniq()

+ 3 - 2
lib/database/index.js

@@ -41,7 +41,8 @@ const fetch = async (Type, refs) => {
     const recs = dict(await Type.findAll({
       where: {
         [Op.or]: or
-      }
+      },
+      paranoid: false
     }))
     if (recs.length !== ids.length + keys.length) {
       const missing = [
@@ -64,7 +65,7 @@ const upsert = async (Type, object, fields) => {
       throw new Error(`Missing upsert field '${field}' in ${JSON.stringify(object)}.`)
     }
   }
-  const existing = await Type.findOne({where: _.pick(object, fields)})
+  const existing = await Type.findOne({where: _.pick(object, fields), paranoid: false})
   let record
   if (existing) {
     Object.assign(existing, object)