Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Populate more user informations on POST /auth/login #3723

Merged
merged 5 commits into from Aug 6, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 5 additions & 3 deletions packages/strapi-plugin-users-permissions/controllers/Auth.js
Expand Up @@ -57,15 +57,17 @@ module.exports = {
const isEmail = emailRegExp.test(params.identifier);

// Set the identifier to the appropriate query field.
let key = "email";
derrickmehaffy marked this conversation as resolved.
Show resolved Hide resolved
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]));
derrickmehaffy marked this conversation as resolved.
Show resolved Hide resolved

if (!user) {
return ctx.badRequest(
Expand Down