duplicate email check
This commit is contained in:
parent
6aa8091774
commit
f07ee52f67
@ -40,6 +40,7 @@ exports.createUser = async (req, res) => {
|
|||||||
const existingUser = await EstablishmentUser.findOne({
|
const existingUser = await EstablishmentUser.findOne({
|
||||||
where: { email, is_active: true }
|
where: { email, is_active: true }
|
||||||
});
|
});
|
||||||
|
const checkEmailInAdminUser = await User.findOne({ where: { email, is_active: true } });
|
||||||
|
|
||||||
if (existingUser) {
|
if (existingUser) {
|
||||||
return res.status(409).json({
|
return res.status(409).json({
|
||||||
@ -48,9 +49,8 @@ exports.createUser = async (req, res) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const existingAdminUser = await User.findOne({ where: { email, is_active: true } });
|
if (checkEmailInAdminUser) {
|
||||||
if (existingAdminUser) {
|
logger.info(`Email already exists in Admin Users: ${email}`);
|
||||||
logger.warn(`Email already exists in Admin Users: ${email}`);
|
|
||||||
return res.status(409).send({
|
return res.status(409).send({
|
||||||
status: "failed",
|
status: "failed",
|
||||||
message: "This email address is already registered in the admin users."
|
message: "This email address is already registered in the admin users."
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user