import { Request, Response } from 'express'; import User from '../models/users'; import { AuthenticatedRequest, UserInterface } from '../shared/interfaces/user.interface'; import { hashPassword } from '../utils/passwordUtils'; import { FindOptions, Op } from 'sequelize'; import { logger } from '../utils/logger'; import Role from '../models/roles'; import { sendMail } from '../utils/mailer'; import RolePermission from '../models/rolePermissions'; import Permission from '../models/permissions'; import { JwtPayload } from 'jsonwebtoken'; const createUser = async (req: Request, res: Response) => { try { const { name, email, role_id, status, password } = req.body; const hashedPassword = await hashPassword(password); const newUser: UserInterface = { name, email, role_id, status, password: hashedPassword, }; const createdUser = await User.create(newUser); const userResponse = { id: createdUser.id, name: createdUser.name, email: createdUser.email, status: createdUser.status, role_id: createdUser.role_id, }; sendMail({ subject: 'Welcome to Fusion Bills - Your Account Has Been Created', to: email, content: `
Hi ${name},
Welcome to Fusion Bills. We’re excited to have you on board.
Your account has been created by an administrator. Here are your login credentials:
You can log in to your account at ${process.env.APP_URL} using these credentials. We recommend changing your password after logging in for the first time to keep your account secure.
If you have any questions or need assistance, feel free to reach out to our support team.
Best regards,
Team Fusion Bills
Hi ${name},
We wanted to inform you that the email address associated with your account has been updated. From now on, you will need to use your new email address: ${email} to log in. Your password remains the same, so you can continue using your current password to access your account. All future notifications, updates, and important communications will be sent to this new email address. If you did not request this change or believe this to be a mistake, please contact us immediately. If you have any questions or concerns, feel free to reach out to our support team.
Thank you for your attention.
Best regards,
Team Fusion Bills
Hi ${name},
We’re writing to confirm that both your email address and password have been updated.
Your new login details are:
You can now use these credentials to log in at ${process.env.APP_URL}
If you did not request these changes or believe this to be a mistake, please contact us immediately to secure your account.
For security, we recommend updating your password regularly and avoiding sharing your login information with anyone.
If you need any further assistance, feel free to reach out to our support team.
Best regards,
Team Fusion Bills
Hi ${name},
We wanted to inform you that an administrator has updated your account password.
Your new password is: ${password}.
Please use this new password to log in to your account at ${process.env.APP_URL}.
For security purposes, we recommend changing this password after logging in. If you did not request this change or believe this to be a mistake, please contact us immediately.
If you have any questions or need assistance, feel free to reach out to our support team.
Best regards,
Team Fusion Bills
Hi ${name},
We’re happy to confirm that your email address has been updated to ${email} . From now on, you can use this new email address to log in to your account, while keeping your current password. All future notifications and communications will also be sent to this address. If you did not request this change or believe this to be a mistake, please contact us immediately. Thank you for staying with us! If you have any questions or need further assistance, our support team is here to help.
Best regards,
Team Fusion Bills