bulk upload existing user fixed
This commit is contained in:
parent
ff78e28e6f
commit
ab2d90d8d2
@ -1831,6 +1831,15 @@ exports.establishmentBulkUpload = async (req, res) => {
|
|||||||
const autoPassword = generateSecurePassword(12);
|
const autoPassword = generateSecurePassword(12);
|
||||||
const hashed = await bcrypt.hash(autoPassword, 10);
|
const hashed = await bcrypt.hash(autoPassword, 10);
|
||||||
|
|
||||||
|
const existingAdminUser = await User.findOne({ where: { email:p.email, is_active: true } });
|
||||||
|
if (existingAdminUser) {
|
||||||
|
logger.warn(`Email already exists in Admin Users: ${p.email}`);
|
||||||
|
return res.status(409).send({
|
||||||
|
status: "failed",
|
||||||
|
message: "This email address is already registered in the admin users."
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
await EstablishmentUser.create({
|
await EstablishmentUser.create({
|
||||||
establishment_id: est.id,
|
establishment_id: est.id,
|
||||||
name: r.user_name,
|
name: r.user_name,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user