From b431ac43e5649a83366e64a8929a71cc8346bf37 Mon Sep 17 00:00:00 2001 From: Tristan Slater <1631008+trslater@users.noreply.github.com> Date: Thu, 6 Mar 2025 08:53:45 -0800 Subject: [PATCH 1/4] Make user email optional - Make user email column nullable - Make all user email DTO fields optional - Disable subtask email filtering when email absent - Check for email before sending new user request email --- .../board/dialogs/card-dialog/card-dialog.component.ts | 7 +++---- .../home/subtask/subtask-table/subtask-table.component.ts | 7 +++---- alcs-frontend/src/app/services/user/user.dto.ts | 2 +- .../alcs/src/common/authorization/authorization.service.ts | 7 ++----- services/apps/alcs/src/user/user.dto.ts | 4 ++-- services/apps/alcs/src/user/user.entity.ts | 4 ++-- 6 files changed, 13 insertions(+), 18 deletions(-) diff --git a/alcs-frontend/src/app/features/board/dialogs/card-dialog/card-dialog.component.ts b/alcs-frontend/src/app/features/board/dialogs/card-dialog/card-dialog.component.ts index 2c0e31f4fc..ffa48437e6 100644 --- a/alcs-frontend/src/app/features/board/dialogs/card-dialog/card-dialog.component.ts +++ b/alcs-frontend/src/app/features/board/dialogs/card-dialog/card-dialog.component.ts @@ -79,10 +79,9 @@ export class CardDialogComponent implements OnInit, OnDestroy { filterAssigneeList(term: string, item: AssigneeDto) { const termLower = term.toLocaleLowerCase(); - return ( - item.email.toLocaleLowerCase().indexOf(termLower) > -1 || - item.prettyName.toLocaleLowerCase().indexOf(termLower) > -1 - ); + return item.email + ? item.email.toLocaleLowerCase().indexOf(termLower) > -1 + : false || item.prettyName.toLocaleLowerCase().indexOf(termLower) > -1; } onArchiveCard() { diff --git a/alcs-frontend/src/app/features/home/subtask/subtask-table/subtask-table.component.ts b/alcs-frontend/src/app/features/home/subtask/subtask-table/subtask-table.component.ts index 8b7b59ffc0..1f38a328b8 100644 --- a/alcs-frontend/src/app/features/home/subtask/subtask-table/subtask-table.component.ts +++ b/alcs-frontend/src/app/features/home/subtask/subtask-table/subtask-table.component.ts @@ -57,10 +57,9 @@ export class SubtaskTableComponent { filterAssigneeList(term: string, item: AssigneeDto) { const termLower = term.toLocaleLowerCase(); - return ( - item.email.toLocaleLowerCase().indexOf(termLower) > -1 || - item.prettyName.toLocaleLowerCase().indexOf(termLower) > -1 - ); + return item.email + ? item.email.toLocaleLowerCase().indexOf(termLower) > -1 + : false || item.prettyName.toLocaleLowerCase().indexOf(termLower) > -1; } async openCard(subtask: HomepageSubtaskDto) { diff --git a/alcs-frontend/src/app/services/user/user.dto.ts b/alcs-frontend/src/app/services/user/user.dto.ts index e5ea623f4d..810ecd8d72 100644 --- a/alcs-frontend/src/app/services/user/user.dto.ts +++ b/alcs-frontend/src/app/services/user/user.dto.ts @@ -23,7 +23,7 @@ export interface AssigneeDto { uuid: string; initials?: string; name: string; - email: string; + email?: string; mentionLabel: string; clientRoles: ROLES[]; prettyName: string; diff --git a/services/apps/alcs/src/common/authorization/authorization.service.ts b/services/apps/alcs/src/common/authorization/authorization.service.ts index 9363f06cfd..1f435a5d78 100644 --- a/services/apps/alcs/src/common/authorization/authorization.service.ts +++ b/services/apps/alcs/src/common/authorization/authorization.service.ts @@ -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); } } } diff --git a/services/apps/alcs/src/user/user.dto.ts b/services/apps/alcs/src/user/user.dto.ts index f856ba31cb..c281457e5e 100644 --- a/services/apps/alcs/src/user/user.dto.ts +++ b/services/apps/alcs/src/user/user.dto.ts @@ -49,7 +49,7 @@ export class UserDto extends UpdateUserDto { } export class CreateUserDto { - email: string; + email?: string; name?: string; displayName: string; givenName?: string; @@ -79,7 +79,7 @@ export class AssigneeDto { mentionLabel: string; @AutoMap() - email: string; + email?: string; @AutoMap() clientRoles: string[]; diff --git a/services/apps/alcs/src/user/user.entity.ts b/services/apps/alcs/src/user/user.entity.ts index 65ccaf1d56..2c3d515e41 100644 --- a/services/apps/alcs/src/user/user.entity.ts +++ b/services/apps/alcs/src/user/user.entity.ts @@ -21,8 +21,8 @@ export class User extends Base { } @AutoMap() - @Column() - email: string; + @Column({ nullable: true }) + email?: string; @AutoMap() @Column() From 564c626ff9a531cb75be1279f699a828e5bedd2b Mon Sep 17 00:00:00 2001 From: Tristan Slater <1631008+trslater@users.noreply.github.com> Date: Thu, 6 Mar 2025 09:02:05 -0800 Subject: [PATCH 2/4] Migrate email column change --- .../1741219585820-make_user_email_nullable.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 services/apps/alcs/src/providers/typeorm/migrations/1741219585820-make_user_email_nullable.ts diff --git a/services/apps/alcs/src/providers/typeorm/migrations/1741219585820-make_user_email_nullable.ts b/services/apps/alcs/src/providers/typeorm/migrations/1741219585820-make_user_email_nullable.ts new file mode 100644 index 0000000000..8a4c95863b --- /dev/null +++ b/services/apps/alcs/src/providers/typeorm/migrations/1741219585820-make_user_email_nullable.ts @@ -0,0 +1,14 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class MakeUserEmailNullable1741219585820 implements MigrationInterface { + name = 'MakeUserEmailNullable1741219585820' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "alcs"."user" ALTER COLUMN "email" DROP NOT NULL`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "alcs"."user" ALTER COLUMN "email" SET NOT NULL`); + } + +} From 1d43b763b89f57d683dc9d0560c5dff2d102c7dc Mon Sep 17 00:00:00 2001 From: Tristan Slater <1631008+trslater@users.noreply.github.com> Date: Thu, 6 Mar 2025 09:04:04 -0800 Subject: [PATCH 3/4] Improve subtask filtering logic --- .../board/dialogs/card-dialog/card-dialog.component.ts | 7 ++++--- .../home/subtask/subtask-table/subtask-table.component.ts | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/alcs-frontend/src/app/features/board/dialogs/card-dialog/card-dialog.component.ts b/alcs-frontend/src/app/features/board/dialogs/card-dialog/card-dialog.component.ts index ffa48437e6..7121eec811 100644 --- a/alcs-frontend/src/app/features/board/dialogs/card-dialog/card-dialog.component.ts +++ b/alcs-frontend/src/app/features/board/dialogs/card-dialog/card-dialog.component.ts @@ -79,9 +79,10 @@ export class CardDialogComponent implements OnInit, OnDestroy { filterAssigneeList(term: string, item: AssigneeDto) { const termLower = term.toLocaleLowerCase(); - return item.email - ? item.email.toLocaleLowerCase().indexOf(termLower) > -1 - : false || item.prettyName.toLocaleLowerCase().indexOf(termLower) > -1; + return ( + (item.email && item.email.toLocaleLowerCase().indexOf(termLower) > -1) || + item.prettyName.toLocaleLowerCase().indexOf(termLower) > -1 + ); } onArchiveCard() { diff --git a/alcs-frontend/src/app/features/home/subtask/subtask-table/subtask-table.component.ts b/alcs-frontend/src/app/features/home/subtask/subtask-table/subtask-table.component.ts index 1f38a328b8..f16cfe3fc5 100644 --- a/alcs-frontend/src/app/features/home/subtask/subtask-table/subtask-table.component.ts +++ b/alcs-frontend/src/app/features/home/subtask/subtask-table/subtask-table.component.ts @@ -57,9 +57,10 @@ export class SubtaskTableComponent { filterAssigneeList(term: string, item: AssigneeDto) { const termLower = term.toLocaleLowerCase(); - return item.email - ? item.email.toLocaleLowerCase().indexOf(termLower) > -1 - : false || item.prettyName.toLocaleLowerCase().indexOf(termLower) > -1; + return ( + (item.email && item.email.toLocaleLowerCase().indexOf(termLower) > -1) || + item.prettyName.toLocaleLowerCase().indexOf(termLower) > -1 + ); } async openCard(subtask: HomepageSubtaskDto) { From bf818d871c9cd3bb0a12c1811b990775615b718f Mon Sep 17 00:00:00 2001 From: Tristan Slater <1631008+trslater@users.noreply.github.com> Date: Thu, 6 Mar 2025 09:37:17 -0800 Subject: [PATCH 4/4] Add email to mock user, so email function called --- .../alcs/src/common/authorization/authorization.service.spec.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/services/apps/alcs/src/common/authorization/authorization.service.spec.ts b/services/apps/alcs/src/common/authorization/authorization.service.spec.ts index 331db5ef25..c58633332b 100644 --- a/services/apps/alcs/src/common/authorization/authorization.service.spec.ts +++ b/services/apps/alcs/src/common/authorization/authorization.service.spec.ts @@ -49,6 +49,7 @@ describe('AuthorizationService', () => { clientRoles: [], bceidGuid: '', displayName: '', + email: 'test@example.com', identityProvider: 'idir', uuid: 'user-uuid', } as Partial as User);