Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PM-11405] Account Management: Prevent a verified user from changing their email address #11486

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
804e706
Update AccountService to include a method for setting the managedByOrโ€ฆ
r-tome Oct 4, 2024
ebfcf3a
Update AccountComponent to conditionally show the purgeVault button bโ€ฆ
r-tome Oct 4, 2024
3ac0c4c
Merge branch 'main' into ac/pm-11404/prevent-a-verified-user-from-purโ€ฆ
r-tome Oct 7, 2024
d01119f
Add missing method to FakeAccountService
r-tome Oct 7, 2024
077d8c3
Remove the setAccountManagedByOrganizationId method from the AccountSโ€ฆ
r-tome Oct 8, 2024
3a02b67
Refactor AccountComponent to use OrganizationService to check for manโ€ฆ
r-tome Oct 8, 2024
f224b58
Merge branch 'main' into ac/pm-11404/prevent-a-verified-user-from-purโ€ฆ
r-tome Oct 8, 2024
5d3689c
Rename managesActiveUser to userIsManagedByOrganization
r-tome Oct 9, 2024
a5debdb
Hide the change email section if the user is managed by an organization
r-tome Oct 10, 2024
48d4efd
Refactor userIsManagedByOrganization property to be non-nullable in oโ€ฆ
r-tome Oct 11, 2024
09ae6bd
Merge branch 'ac/pm-11404/prevent-a-verified-user-from-purging-their-โ€ฆ
r-tome Oct 11, 2024
8d06879
Refactor organization.data.spec.ts to include non-nullable userIsManaโ€ฆ
r-tome Oct 11, 2024
e219cb7
Merge branch 'ac/pm-11404/prevent-a-verified-user-from-purging-their-โ€ฆ
r-tome Oct 11, 2024
79d8fb6
Merge branch 'main' into ac/pm-11405/prevent-a-verified-user-from-chaโ€ฆ
r-tome Oct 18, 2024
8d816f2
Refactor account component initialization logic
r-tome Oct 18, 2024
e5a47cc
Remove opening modal that was added by mistake
r-tome Oct 18, 2024
e3ec094
Merge branch 'main' into ac/pm-11405/prevent-a-verified-user-from-chaโ€ฆ
r-tome Oct 28, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<bit-container>
<app-profile></app-profile>

<div *ngIf="showChangeEmail" class="tw-mt-16">
<div *ngIf="showChangeEmail$ | async" class="tw-mt-16">
<h1 bitTypography="h1">{{ "changeEmail" | i18n }}</h1>
<app-change-email></app-change-email>
</div>
Expand Down
49 changes: 32 additions & 17 deletions apps/web/src/app/auth/settings/account/account.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, OnInit, ViewChild, ViewContainerRef } from "@angular/core";
import { lastValueFrom, map, Observable, of, switchMap } from "rxjs";
import { combineLatest, from, lastValueFrom, map, Observable } from "rxjs";

import { ModalService } from "@bitwarden/angular/services/modal.service";
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
Expand All @@ -21,7 +21,7 @@
@ViewChild("deauthorizeSessionsTemplate", { read: ViewContainerRef, static: true })
deauthModalRef: ViewContainerRef;

showChangeEmail = true;
showChangeEmail$: Observable<boolean>;
showPurgeVault$: Observable<boolean>;

constructor(
Expand All @@ -33,21 +33,36 @@
) {}

async ngOnInit() {
this.showChangeEmail = await this.userVerificationService.hasMasterPassword();
this.showPurgeVault$ = this.configService
.getFeatureFlag$(FeatureFlag.AccountDeprovisioning)
.pipe(
switchMap((isAccountDeprovisioningEnabled) =>
isAccountDeprovisioningEnabled
? this.organizationService.organizations$.pipe(
map(
(organizations) =>
!organizations.some((o) => o.userIsManagedByOrganization === true),
),
)
: of(true),
),
);
const isAccountDeprovisioningEnabled$ = this.configService.getFeatureFlag$(

Check warning on line 36 in apps/web/src/app/auth/settings/account/account.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/auth/settings/account/account.component.ts#L36

Added line #L36 was not covered by tests
FeatureFlag.AccountDeprovisioning,
);

const userIsManagedByOrganization$ = this.organizationService.organizations$.pipe(
map((organizations) => organizations.some((o) => o.userIsManagedByOrganization === true)),

Check warning on line 41 in apps/web/src/app/auth/settings/account/account.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/auth/settings/account/account.component.ts#L40-L41

Added lines #L40 - L41 were not covered by tests
);

const hasMasterPassword$ = from(this.userVerificationService.hasMasterPassword());

Check warning on line 44 in apps/web/src/app/auth/settings/account/account.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/auth/settings/account/account.component.ts#L44

Added line #L44 was not covered by tests

this.showChangeEmail$ = combineLatest([

Check warning on line 46 in apps/web/src/app/auth/settings/account/account.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/auth/settings/account/account.component.ts#L46

Added line #L46 was not covered by tests
hasMasterPassword$,
isAccountDeprovisioningEnabled$,
userIsManagedByOrganization$,
]).pipe(
map(
([hasMasterPassword, isAccountDeprovisioningEnabled, userIsManagedByOrganization]) =>
hasMasterPassword && (!isAccountDeprovisioningEnabled || !userIsManagedByOrganization),
),
);

this.showPurgeVault$ = combineLatest([

Check warning on line 57 in apps/web/src/app/auth/settings/account/account.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/auth/settings/account/account.component.ts#L57

Added line #L57 was not covered by tests
isAccountDeprovisioningEnabled$,
userIsManagedByOrganization$,
]).pipe(
map(
([isAccountDeprovisioningEnabled, userIsManagedByOrganization]) =>
!isAccountDeprovisioningEnabled || !userIsManagedByOrganization,
),
);
}

async deauthorizeSessions() {
Expand Down
Loading