company profile changes updated
This commit is contained in:
parent
7c8b8a44d9
commit
3237a62939
@ -180,7 +180,7 @@ exports.createEstablishment = async (req, res) => {
|
|||||||
const checkEmailInAdminUser = await User.findOne({ where: { email: establishment_user.email, is_active: true } });
|
const checkEmailInAdminUser = await User.findOne({ where: { email: establishment_user.email, is_active: true } });
|
||||||
|
|
||||||
if (existingUser) {
|
if (existingUser) {
|
||||||
return res.status(400).send({
|
return res.status(409).send({
|
||||||
status: "failed",
|
status: "failed",
|
||||||
message: "User email already exists"
|
message: "User email already exists"
|
||||||
});
|
});
|
||||||
@ -1789,6 +1789,24 @@ exports.establishmentBulkUpload = async (req, res) => {
|
|||||||
const p = prepared[k];
|
const p = prepared[k];
|
||||||
const r = p.r;
|
const r = p.r;
|
||||||
|
|
||||||
|
const existEstablishmentUser = await EstablishmentUser.findOne({ where: { email:p.email, is_active: true } });
|
||||||
|
const existingAdminUser = await User.findOne({ where: { email:p.email, is_active: true } });
|
||||||
|
if (existEstablishmentUser) {
|
||||||
|
logger.info(`Email already exists in company profile: ${p.email}`);
|
||||||
|
return res.status(409).send({
|
||||||
|
status: "failed",
|
||||||
|
message: "This email address is already exists in company profile."
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (existingAdminUser) {
|
||||||
|
logger.info(`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."
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const est = await Establishment.create({
|
const est = await Establishment.create({
|
||||||
establishment_code: p.est,
|
establishment_code: p.est,
|
||||||
license_number: p.est,
|
license_number: p.est,
|
||||||
@ -1840,16 +1858,6 @@ 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