mirror of
https://github.com/bitwarden/browser.git
synced 2025-01-22 21:21:35 +01:00
PM-1049 - (1) Updated dependencies in parent BaseLoginDecryptionOptionsComponent class + child components (2) Retrieve userEmail b/c needed for displaying which email the user is logging in with (3) Add log out functionality (4) Add comments regarding future implementation details for each login approval flow.
This commit is contained in:
parent
997ee5c43c
commit
8eb182ffda
@ -4,6 +4,9 @@ import { Router } from "@angular/router";
|
||||
|
||||
import { BaseLoginDecryptionOptionsComponent } from "@bitwarden/angular/auth/components/base-login-decryption-options.component";
|
||||
import { DevicesApiServiceAbstraction } from "@bitwarden/common/abstractions/devices/devices-api.service.abstraction";
|
||||
import { LoginService } from "@bitwarden/common/auth/abstractions/login.service";
|
||||
import { TokenService } from "@bitwarden/common/auth/abstractions/token.service";
|
||||
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
||||
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
|
||||
|
||||
@Component({
|
||||
@ -15,8 +18,19 @@ export class LoginDecryptionOptionsComponent extends BaseLoginDecryptionOptionsC
|
||||
formBuilder: FormBuilder,
|
||||
devicesApiService: DevicesApiServiceAbstraction,
|
||||
stateService: StateService,
|
||||
router: Router
|
||||
router: Router,
|
||||
messagingService: MessagingService,
|
||||
tokenService: TokenService,
|
||||
loginService: LoginService
|
||||
) {
|
||||
super(formBuilder, devicesApiService, stateService, router);
|
||||
super(
|
||||
formBuilder,
|
||||
devicesApiService,
|
||||
stateService,
|
||||
router,
|
||||
messagingService,
|
||||
tokenService,
|
||||
loginService
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,9 @@ import { Router } from "@angular/router";
|
||||
|
||||
import { BaseLoginDecryptionOptionsComponent } from "@bitwarden/angular/auth/components/base-login-decryption-options.component";
|
||||
import { DevicesApiServiceAbstraction } from "@bitwarden/common/abstractions/devices/devices-api.service.abstraction";
|
||||
import { LoginService } from "@bitwarden/common/auth/abstractions/login.service";
|
||||
import { TokenService } from "@bitwarden/common/auth/abstractions/token.service";
|
||||
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
||||
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
|
||||
|
||||
@Component({
|
||||
@ -15,8 +18,19 @@ export class LoginDecryptionOptionsComponent extends BaseLoginDecryptionOptionsC
|
||||
formBuilder: FormBuilder,
|
||||
devicesApiService: DevicesApiServiceAbstraction,
|
||||
stateService: StateService,
|
||||
router: Router
|
||||
router: Router,
|
||||
messagingService: MessagingService,
|
||||
tokenService: TokenService,
|
||||
loginService: LoginService
|
||||
) {
|
||||
super(formBuilder, devicesApiService, stateService, router);
|
||||
super(
|
||||
formBuilder,
|
||||
devicesApiService,
|
||||
stateService,
|
||||
router,
|
||||
messagingService,
|
||||
tokenService,
|
||||
loginService
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,9 @@ import { Router } from "@angular/router";
|
||||
|
||||
import { BaseLoginDecryptionOptionsComponent } from "@bitwarden/angular/auth/components/base-login-decryption-options.component";
|
||||
import { DevicesApiServiceAbstraction } from "@bitwarden/common/abstractions/devices/devices-api.service.abstraction";
|
||||
import { LoginService } from "@bitwarden/common/auth/abstractions/login.service";
|
||||
import { TokenService } from "@bitwarden/common/auth/abstractions/token.service";
|
||||
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
||||
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
|
||||
@Component({
|
||||
selector: "web-login-decryption-options",
|
||||
@ -14,8 +17,19 @@ export class LoginDecryptionOptionsComponent extends BaseLoginDecryptionOptionsC
|
||||
formBuilder: FormBuilder,
|
||||
devicesApiService: DevicesApiServiceAbstraction,
|
||||
stateService: StateService,
|
||||
router: Router
|
||||
router: Router,
|
||||
messagingService: MessagingService,
|
||||
tokenService: TokenService,
|
||||
loginService: LoginService
|
||||
) {
|
||||
super(formBuilder, devicesApiService, stateService, router);
|
||||
super(
|
||||
formBuilder,
|
||||
devicesApiService,
|
||||
stateService,
|
||||
router,
|
||||
messagingService,
|
||||
tokenService,
|
||||
loginService
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,10 @@ import { Router } from "@angular/router";
|
||||
import { Subject } from "rxjs";
|
||||
|
||||
import { DevicesApiServiceAbstraction } from "@bitwarden/common/abstractions/devices/devices-api.service.abstraction";
|
||||
import { LoginService } from "@bitwarden/common/auth/abstractions/login.service";
|
||||
import { TokenService } from "@bitwarden/common/auth/abstractions/token.service";
|
||||
import { DeviceType } from "@bitwarden/common/enums/device-type.enum";
|
||||
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
||||
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
|
||||
import { AccountDecryptionOptions } from "@bitwarden/common/platform/models/domain/account";
|
||||
|
||||
@ -12,6 +15,8 @@ import { AccountDecryptionOptions } from "@bitwarden/common/platform/models/doma
|
||||
export class BaseLoginDecryptionOptionsComponent implements OnInit, OnDestroy {
|
||||
private componentDestroyed$: Subject<void> = new Subject();
|
||||
|
||||
userEmail: string = null;
|
||||
|
||||
rememberDeviceForm = this.formBuilder.group({
|
||||
rememberDevice: [true],
|
||||
});
|
||||
@ -26,7 +31,10 @@ export class BaseLoginDecryptionOptionsComponent implements OnInit, OnDestroy {
|
||||
protected formBuilder: FormBuilder,
|
||||
protected devicesApiService: DevicesApiServiceAbstraction,
|
||||
protected stateService: StateService,
|
||||
protected router: Router
|
||||
protected router: Router,
|
||||
protected messagingService: MessagingService,
|
||||
protected tokenService: TokenService,
|
||||
protected loginService: LoginService
|
||||
) {}
|
||||
|
||||
async ngOnInit() {
|
||||
@ -51,31 +59,51 @@ export class BaseLoginDecryptionOptionsComponent implements OnInit, OnDestroy {
|
||||
const acctDecryptionOptions: AccountDecryptionOptions =
|
||||
await this.stateService.getAcctDecryptionOptions();
|
||||
|
||||
// Show the admin approval btn if user has TDE enabled and the org admin approval policy is set
|
||||
this.showReqAdminApprovalBtn = !!acctDecryptionOptions.trustedDeviceOption?.hasAdminApproval;
|
||||
// Get user's email from access token:
|
||||
this.userEmail = await this.tokenService.getEmail();
|
||||
|
||||
// Show the admin approval btn if user has TDE enabled and the org admin approval policy is set && user email is not null
|
||||
this.showReqAdminApprovalBtn =
|
||||
!!acctDecryptionOptions.trustedDeviceOption?.hasAdminApproval && this.userEmail != null;
|
||||
|
||||
this.showApproveWithMasterPasswordBtn = acctDecryptionOptions.hasMasterPassword;
|
||||
|
||||
// TODO: do I extend the lock guard for the lock screen to prevent the user from getting to the lock screen
|
||||
// if they do not have a master password set
|
||||
|
||||
this.loading = false;
|
||||
}
|
||||
|
||||
approveFromOtherDevice() {
|
||||
// this.devicesApiService.sendApproval();
|
||||
// TODO: plan is to re-use existing login-with-device component but rework it to have two flows
|
||||
// (1) Standard flow for unauthN user based on AuthService status
|
||||
// (2) New flow for authN user based on AuthService status b/c they have just authenticated w/ SSO
|
||||
this.loginService.setEmail(this.userEmail);
|
||||
this.router.navigate(["/login-with-device"]);
|
||||
}
|
||||
|
||||
requestAdminApproval() {
|
||||
// TODO: add create admin approval request on new OrganizationAuthRequestsController on the server
|
||||
// this.router.navigate(["/admin-approval-requested"]); // new component that doesn't exist yet
|
||||
// Idea: extract logic from the existing login-with-device component into a base-auth-request-component that
|
||||
// the new admin-approval-requested component and the existing login-with-device component can extend
|
||||
// TODO: how to do:
|
||||
// add create admin approval request on new OrganizationAuthRequestsController on the server
|
||||
// once https://github.com/bitwarden/server/pull/2993 is merged
|
||||
// Client with create an AdminAuthRequest without org id and send it to the server
|
||||
// Client will create an AuthRequest of type AdminAuthRequest WITHOUT orgId and send it to the server
|
||||
// Server will look up the org id(s) based on the user id and create the AdminAuthRequest(s)
|
||||
// Note: must lookup if the user has an account recovery key set in the org
|
||||
// Note: must lookup if the user has an account recovery key (resetPasswordKey) set in the org
|
||||
// (means they've opted into the Admin Acct Recovery feature)
|
||||
// Per discussion with Micah, fire out requests to all admins in any orgs the user is a member of
|
||||
// UNTIL the Admin Console team finishes their work to turn on Single Org policy when Admin Acct Recovery is enabled.
|
||||
}
|
||||
|
||||
approveWithMasterPassword() {
|
||||
this.router.navigate(["lock"]);
|
||||
this.router.navigate(["/lock"]);
|
||||
}
|
||||
|
||||
logOut() {
|
||||
this.loading = true; // to avoid an awkward delay in browser extension
|
||||
this.messagingService.send("logout");
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
|
Loading…
Reference in New Issue
Block a user