mirror of
https://github.com/strapi/strapi.git
synced 2025-08-22 07:38:41 +00:00
feat(plugin-users-permissions): lowercase email
This commit is contained in:
parent
0641c7b279
commit
adc532cf74
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const crypto = require('crypto');
|
const crypto = require('crypto');
|
||||||
|
const emailRegExp = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
callback: async (ctx) => {
|
callback: async (ctx) => {
|
||||||
@ -29,14 +30,13 @@ module.exports = {
|
|||||||
const query = {};
|
const query = {};
|
||||||
|
|
||||||
// Check if the provided identifier is an email or not.
|
// Check if the provided identifier is an email or not.
|
||||||
const isEmail = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(params.identifier);
|
const isEmail = emailRegExp.test(params.identifier);
|
||||||
|
|
||||||
// Set the identifier to the appropriate query field.
|
// Set the identifier to the appropriate query field.
|
||||||
const identifier = params.identifier.toLowerCase();
|
|
||||||
if (isEmail) {
|
if (isEmail) {
|
||||||
query.email = identifier;
|
query.email = params.identifier.toLowerCase();
|
||||||
} else {
|
} else {
|
||||||
query.username = identifier;
|
query.username = params.identifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the user exists.
|
// Check if the user exists.
|
||||||
@ -169,7 +169,11 @@ module.exports = {
|
|||||||
params.role = '1';
|
params.role = '1';
|
||||||
}
|
}
|
||||||
|
|
||||||
params.identifier = params.identifier.toLowerCase();
|
// Check if the provided identifier is an email or not.
|
||||||
|
const isEmail = emailRegExp.test(params.identifier);
|
||||||
|
if (isEmail) {
|
||||||
|
params.identifier = params.identifier.toLowerCase();
|
||||||
|
}
|
||||||
params.password = await strapi.plugins['users-permissions'].services.user.hashPassword(params);
|
params.password = await strapi.plugins['users-permissions'].services.user.hashPassword(params);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user