Duplicate email admin user restricted
This commit is contained in:
parent
f07ee52f67
commit
ac292945b1
@ -176,6 +176,8 @@ exports.createEstablishment = async (req, res) => {
|
||||
const existingUser = await EstablishmentUser.findOne({
|
||||
where: { email: establishment_user.email }
|
||||
});
|
||||
|
||||
const checkEmailInAdminUser = await User.findOne({ where: { email, is_active: true } });
|
||||
|
||||
if (existingUser) {
|
||||
return res.status(400).send({
|
||||
@ -184,6 +186,14 @@ exports.createEstablishment = async (req, res) => {
|
||||
});
|
||||
}
|
||||
|
||||
if (checkEmailInAdminUser) {
|
||||
logger.info(`Email already exists in Admin Users: ${email}`);
|
||||
return res.status(409).send({
|
||||
status: "failed",
|
||||
message: "This email address is already registered in the admin users."
|
||||
});
|
||||
}
|
||||
|
||||
// Create establishment record
|
||||
const establishment = await Establishment.create({
|
||||
establishment_code: sanitizeStringValue(establishment_code),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user