Skip to content

Commit

Permalink
Update backToRoute for authed users
Browse files Browse the repository at this point in the history
We shouldn't use the type of auth request (Standard/Admin) to determine
what the backToRoute should be, since SSO TD authed users have the option
to use either a Standard or Admin flow. Instead, this commit uses the user's
authStatus to determine the backToRoute.
  • Loading branch information
rr-bw committed Nov 19, 2024
1 parent 8371657 commit 5bccf36
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ export class LoginViaAuthRequestComponent implements OnInit, OnDestroy {
// Get the authStatus early because we use it in both flows
this.authStatus = await firstValueFrom(this.authService.activeAccountStatus$);

Check warning on line 114 in libs/auth/src/angular/login-via-auth-request/login-via-auth-request.component.ts

View check run for this annotation

Codecov / codecov/patch

libs/auth/src/angular/login-via-auth-request/login-via-auth-request.component.ts#L114

Added line #L114 was not covered by tests

const userHasAuthenticatedViaSSO = this.authStatus === AuthenticationStatus.Locked;

Check warning on line 116 in libs/auth/src/angular/login-via-auth-request/login-via-auth-request.component.ts

View check run for this annotation

Codecov / codecov/patch

libs/auth/src/angular/login-via-auth-request/login-via-auth-request.component.ts#L116

Added line #L116 was not covered by tests

if (userHasAuthenticatedViaSSO) {
this.backToRoute = "/login-initiated";

Check warning on line 119 in libs/auth/src/angular/login-via-auth-request/login-via-auth-request.component.ts

View check run for this annotation

Codecov / codecov/patch

libs/auth/src/angular/login-via-auth-request/login-via-auth-request.component.ts#L119

Added line #L119 was not covered by tests
}

/**
* The LoginViaAuthRequestComponent handles both the `login-with-device` and
* the `admin-approval-requested` routes. Therefore we check the route to determine
Expand All @@ -127,7 +133,6 @@ export class LoginViaAuthRequestComponent implements OnInit, OnDestroy {

private async initAdminAuthRequestFlow(): Promise<void> {
this.flow = Flow.AdminAuthRequest;

Check warning on line 135 in libs/auth/src/angular/login-via-auth-request/login-via-auth-request.component.ts

View check run for this annotation

Codecov / codecov/patch

libs/auth/src/angular/login-via-auth-request/login-via-auth-request.component.ts#L135

Added line #L135 was not covered by tests
this.backToRoute = "/login-initiated";

// Get email from state for admin auth requests because it is available and also
// prevents it from being lost on refresh as the loginEmailService email does not persist.
Expand All @@ -154,7 +159,6 @@ export class LoginViaAuthRequestComponent implements OnInit, OnDestroy {

private async initStandardAuthRequestFlow(): Promise<void> {
this.flow = Flow.StandardAuthRequest;

Check warning on line 161 in libs/auth/src/angular/login-via-auth-request/login-via-auth-request.component.ts

View check run for this annotation

Codecov / codecov/patch

libs/auth/src/angular/login-via-auth-request/login-via-auth-request.component.ts#L161

Added line #L161 was not covered by tests
this.backToRoute = "/login";

this.email = await firstValueFrom(this.loginEmailService.loginEmail$);

Check warning on line 163 in libs/auth/src/angular/login-via-auth-request/login-via-auth-request.component.ts

View check run for this annotation

Codecov / codecov/patch

libs/auth/src/angular/login-via-auth-request/login-via-auth-request.component.ts#L163

Added line #L163 was not covered by tests

Expand Down

0 comments on commit 5bccf36

Please sign in to comment.