Skip to content

Commit

Permalink
Merge pull request #2198 from bcgov/feature/ALCS-2522-fix
Browse files Browse the repository at this point in the history
ALCS-2522: Send user request email even if no email provided
  • Loading branch information
trslater authored Mar 6, 2025
2 parents dea7191 + 55b33cc commit 7084bd7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ export class AuthorizationService {
this.mapUserFromTokenToCreateDto(payload),
);

if (user.clientRoles.length === 0 && !isPortal && user.email !== undefined) {
await this.userService.sendNewUserRequestEmail(user.email, user.bceidGuid ?? user.displayName);
if (user.clientRoles.length === 0 && !isPortal) {
await this.userService.sendNewUserRequestEmail(user.bceidGuid ?? user.displayName, user.email);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion services/apps/alcs/src/user/user.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ describe('UserService', () => {
const body = `A new user ${email}: ${userIdentifier} has requested access to ALCS.<br/>
<a href="https://bcgov.github.io/sso-requests/my-dashboard/integrations">CSS</a>`;

await service.sendNewUserRequestEmail(email, userIdentifier);
await service.sendNewUserRequestEmail(userIdentifier, email);

expect(emailServiceMock.sendEmail).toBeCalledWith({
to: config.get('EMAIL.DEFAULT_ADMINS'),
Expand Down
5 changes: 3 additions & 2 deletions services/apps/alcs/src/user/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,12 @@ export class UserService {
return null;
}

async sendNewUserRequestEmail(email: string, userIdentifier: string) {
async sendNewUserRequestEmail(userIdentifier: string, email?: string) {
const userText = email ? `${email}: ${userIdentifier}` : `${userIdentifier}`;
const env = this.config.get('ENV');
const prefix = env === 'production' ? '' : `[${env}]`;
const subject = `${prefix} Access Requested to ALCS`;
const body = `A new user ${email}: ${userIdentifier} has requested access to ALCS.<br/>
const body = `A new user ${userText} has requested access to ALCS.<br/>
<a href="https://bcgov.github.io/sso-requests/my-dashboard/integrations">CSS</a>`;

await this.emailService.sendEmail({
Expand Down

0 comments on commit 7084bd7

Please sign in to comment.