mirror of
https://github.com/strapi/strapi.git
synced 2025-09-02 21:32:43 +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) {
|
if (ctx.request && ctx.request.header && ctx.request.header.authorization) {
|
||||||
try {
|
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) {
|
} catch (err) {
|
||||||
return ctx.unauthorized(err);
|
return ctx.unauthorized(err);
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ module.exports = {
|
|||||||
} else if (params.id) {
|
} else if (params.id) {
|
||||||
delete params.id;
|
delete params.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this
|
return this
|
||||||
.findOne(params)
|
.findOne(params)
|
||||||
.populate(populate || this.associations.map(x => x.alias).join(' '));
|
.populate(populate || this.associations.map(x => x.alias).join(' '));
|
||||||
|
@ -39,7 +39,7 @@ module.exports = {
|
|||||||
if (!user) {
|
if (!user) {
|
||||||
return ctx.badRequest(null, [{ messages: [{ id: 'No authorization header was found' }] }]);
|
return ctx.badRequest(null, [{ messages: [{ id: 'No authorization header was found' }] }]);
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = _.omit(user.toJSON ? user.toJSON() : user, ['password', 'resetPasswordToken']);
|
const data = _.omit(user.toJSON ? user.toJSON() : user, ['password', 'resetPasswordToken']);
|
||||||
|
|
||||||
// Send 200 `ok`
|
// Send 200 `ok`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user