mirror of
https://github.com/strapi/strapi.git
synced 2025-09-02 13:23:12 +00:00
Fix infinite login
This commit is contained in:
parent
b84976fbbd
commit
fa8976c98f
@ -3,9 +3,9 @@ module.exports = async (ctx, next) => {
|
||||
|
||||
if (ctx.request && ctx.request.header && ctx.request.header.authorization) {
|
||||
try {
|
||||
const token = await strapi.plugins['users-permissions'].services.jwt.getToken(ctx);
|
||||
const { _id, id } = await strapi.plugins['users-permissions'].services.jwt.getToken(ctx);
|
||||
|
||||
ctx.state.user = await strapi.query('user', 'users-permissions').findOne({ _id, id } = token, ['role'])
|
||||
ctx.state.user = await strapi.query('user', 'users-permissions').findOne({ _id, id }, ['role']);
|
||||
} catch (err) {
|
||||
return ctx.unauthorized(err);
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ module.exports = {
|
||||
} else if (params.id) {
|
||||
delete params.id;
|
||||
}
|
||||
|
||||
|
||||
return this
|
||||
.findOne(params)
|
||||
.populate(populate || this.associations.map(x => x.alias).join(' '));
|
||||
|
@ -39,7 +39,7 @@ module.exports = {
|
||||
if (!user) {
|
||||
return ctx.badRequest(null, [{ messages: [{ id: 'No authorization header was found' }] }]);
|
||||
}
|
||||
|
||||
|
||||
const data = _.omit(user.toJSON ? user.toJSON() : user, ['password', 'resetPasswordToken']);
|
||||
|
||||
// Send 200 `ok`
|
||||
|
Loading…
x
Reference in New Issue
Block a user