Skip to content

Commit

Permalink
Merge pull request #2197 from bcgov/feature/ALCS-2522
Browse files Browse the repository at this point in the history
ALCS-2522: Make user email optional
  • Loading branch information
trslater authored Mar 6, 2025
2 parents e705884 + bf818d8 commit dea7191
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export class CardDialogComponent implements OnInit, OnDestroy {
filterAssigneeList(term: string, item: AssigneeDto) {
const termLower = term.toLocaleLowerCase();
return (
item.email.toLocaleLowerCase().indexOf(termLower) > -1 ||
(item.email && item.email.toLocaleLowerCase().indexOf(termLower) > -1) ||
item.prettyName.toLocaleLowerCase().indexOf(termLower) > -1
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class SubtaskTableComponent {
filterAssigneeList(term: string, item: AssigneeDto) {
const termLower = term.toLocaleLowerCase();
return (
item.email.toLocaleLowerCase().indexOf(termLower) > -1 ||
(item.email && item.email.toLocaleLowerCase().indexOf(termLower) > -1) ||
item.prettyName.toLocaleLowerCase().indexOf(termLower) > -1
);
}
Expand Down
2 changes: 1 addition & 1 deletion alcs-frontend/src/app/services/user/user.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export interface AssigneeDto {
uuid: string;
initials?: string;
name: string;
email: string;
email?: string;
mentionLabel: string;
clientRoles: ROLES[];
prettyName: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ describe('AuthorizationService', () => {
clientRoles: [],
bceidGuid: '',
displayName: '',
email: '[email protected]',
identityProvider: 'idir',
uuid: 'user-uuid',
} as Partial<User> as User);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,8 @@ export class AuthorizationService {
this.mapUserFromTokenToCreateDto(payload),
);

if (user.clientRoles.length === 0 && !isPortal) {
await this.userService.sendNewUserRequestEmail(
user.email,
user.bceidGuid ?? user.displayName,
);
if (user.clientRoles.length === 0 && !isPortal && user.email !== undefined) {
await this.userService.sendNewUserRequestEmail(user.email, user.bceidGuid ?? user.displayName);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { MigrationInterface, QueryRunner } from "typeorm";

export class MakeUserEmailNullable1741219585820 implements MigrationInterface {
name = 'MakeUserEmailNullable1741219585820'

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "alcs"."user" ALTER COLUMN "email" DROP NOT NULL`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "alcs"."user" ALTER COLUMN "email" SET NOT NULL`);
}

}
4 changes: 2 additions & 2 deletions services/apps/alcs/src/user/user.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class UserDto extends UpdateUserDto {
}

export class CreateUserDto {
email: string;
email?: string;
name?: string;
displayName: string;
givenName?: string;
Expand Down Expand Up @@ -79,7 +79,7 @@ export class AssigneeDto {
mentionLabel: string;

@AutoMap()
email: string;
email?: string;

@AutoMap()
clientRoles: string[];
Expand Down
4 changes: 2 additions & 2 deletions services/apps/alcs/src/user/user.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ export class User extends Base {
}

@AutoMap()
@Column()
email: string;
@Column({ nullable: true })
email?: string;

@AutoMap()
@Column()
Expand Down

0 comments on commit dea7191

Please sign in to comment.