mirror of
https://github.com/strapi/strapi.git
synced 2025-12-27 15:13:21 +00:00
Execute controller action out of authorization try
This commit is contained in:
parent
6a59946f71
commit
ff46faf306
@ -46,4 +46,4 @@
|
||||
"npm": ">= 3.0.0"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
||||
}
|
||||
@ -55,4 +55,4 @@
|
||||
"npm": ">= 5.3.0"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
||||
}
|
||||
@ -46,4 +46,4 @@
|
||||
"npm": ">= 5.0.0"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
||||
}
|
||||
@ -48,4 +48,4 @@
|
||||
"react-select": "^1.0.0-rc.5",
|
||||
"strapi-helper-plugin": "3.0.0-alpha.7.3"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -48,4 +48,4 @@
|
||||
"npm": ">= 3.0.0"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
||||
}
|
||||
@ -46,4 +46,4 @@
|
||||
"npm": ">= 3.0.0"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
||||
}
|
||||
@ -45,4 +45,4 @@
|
||||
"npm": ">= 3.0.0"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
||||
}
|
||||
@ -10,18 +10,19 @@ module.exports = async (ctx, next) => {
|
||||
|
||||
ctx.state.user = await strapi.plugins['users-permissions'].services.user.fetch(_.pick(tokenUser, ['_id', 'id']));
|
||||
|
||||
if (!ctx.state.user) {
|
||||
ctx.unauthorized('This user doesn\'t exit.');
|
||||
}
|
||||
|
||||
role = ctx.state.user.role;
|
||||
|
||||
if (role.toString() === '0') {
|
||||
return await next();
|
||||
}
|
||||
} catch (err) {
|
||||
return ctx.unauthorized(err);
|
||||
}
|
||||
|
||||
if (!ctx.state.user) {
|
||||
ctx.unauthorized('This user doesn\'t exit.');
|
||||
}
|
||||
|
||||
role = ctx.state.user.role;
|
||||
|
||||
if (role.toString() === '0') {
|
||||
return await next();
|
||||
}
|
||||
}
|
||||
|
||||
const permission = _.get(strapi.plugins['users-permissions'].config, ['roles', role.toString(), 'permissions', route.plugin || 'application', 'controllers', route.controller, route.action]);
|
||||
|
||||
@ -48,4 +48,4 @@
|
||||
"npm": ">= 3.0.0"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user