Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/helpers/userInvite.js
Original file line number Diff line number Diff line change
Expand Up @@ -1241,6 +1241,7 @@ module.exports = class UserInviteHelper {
roles: roleToString || '',
portalURL: tenantDomains.domain,
username: inviteeData.username,
password: invitee.password,
},
tenantCode: tenantDetails.code,
organization_code: user.organization_code,
Expand Down
21 changes: 19 additions & 2 deletions src/services/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ module.exports = class AccountHelper {
}
}

const rawPassword = bodyData.password
bodyData.password = utilsHelper.hashPassword(bodyData.password)
if (!bodyData.username) {
bodyData.username = await generateUniqueUsername(bodyData.name)
Expand Down Expand Up @@ -322,7 +323,12 @@ module.exports = class AccountHelper {
role = await roleQueries.findAll(
{
title: {
[Op.in]: typeof bodyData.roles === 'string' ? bodyData.roles.split(',') : (Array.isArray(bodyData.roles) ? bodyData.roles : process.env.DEFAULT_ROLE.split(',')),
[Op.in]:
typeof bodyData.roles === 'string'
? bodyData.roles.split(',')
: Array.isArray(bodyData.roles)
? bodyData.roles
: process.env.DEFAULT_ROLE.split(','),
},
tenant_code: tenantDetail.code,
},
Expand Down Expand Up @@ -588,14 +594,25 @@ module.exports = class AccountHelper {
}

if (plaintextEmailId) {
let portalURL = tenantDomain?.domain || ''

if (!portalURL && tenantDetail?.code) {
const foundDomain = await tenantDomainQueries.findOne(
{ tenant_code: tenantDetail.code },
{ attributes: ['domain'] }
)
portalURL = foundDomain?.domain
}

notificationUtils.sendEmailNotification({
emailId: plaintextEmailId,
templateCode: process.env.REGISTRATION_EMAIL_TEMPLATE_CODE,
variables: {
name: bodyData.name,
appName: tenantDetail.name,
roles: roleToString || '',
portalURL: tenantDomain.domain,
portalURL,
password: rawPassword,
},
tenantCode: tenantDetail.code,
organization_code: user.organizations?.[0].code || null,
Expand Down