Fix /auth/login, user object ignore files and relations

Find user by email or identifier to get files and relations.
This commit is contained in:
Rémi M 2019-08-03 15:58:01 +02:00 committed by GitHub
parent 649df34583
commit 04f0995b43
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -57,15 +57,17 @@ module.exports = {
const isEmail = emailRegExp.test(params.identifier);
// Set the identifier to the appropriate query field.
let key = "email";
if (isEmail) {
query.email = params.identifier.toLowerCase();
} else {
query.username = params.identifier;
key = "username";
}
// Check if the user exists.
const user = await strapi.plugins['users-permissions'].queries('user', 'users-permissions')
.findOne(query, ['role']);
const user = await strapi.plugins["users-permissions"]
.queries("user", "users-permissions")
.findOne(_.pick(query, [key, key]));
if (!user) {
return ctx.badRequest(