From 8f27110754d7a492ebbd5e3bb9b9b99c9ab9869b Mon Sep 17 00:00:00 2001 From: Vincent Salucci <26154748+vincentsalucci@users.noreply.github.com> Date: Wed, 26 Aug 2020 10:54:16 -0500 Subject: [PATCH] [SSO] Bug - Fixed set password route (#156) * Fixed 2fa + set password bug// moved query params parsing in shared lib * Removed unnecessary params parse // added auth result conditional for success route --- src/angular/components/two-factor.component.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/angular/components/two-factor.component.ts b/src/angular/components/two-factor.component.ts index 16a7d1032d0..72c92bdf896 100644 --- a/src/angular/components/two-factor.component.ts +++ b/src/angular/components/two-factor.component.ts @@ -2,6 +2,7 @@ import { OnDestroy, OnInit, } from '@angular/core'; + import { Router } from '@angular/router'; import { DeviceType } from '../../enums/deviceType'; @@ -9,6 +10,8 @@ import { TwoFactorProviderType } from '../../enums/twoFactorProviderType'; import { TwoFactorEmailRequest } from '../../models/request/twoFactorEmailRequest'; +import { AuthResult } from '../../models/domain'; + import { ApiService } from '../../abstractions/api.service'; import { AuthService } from '../../abstractions/auth.service'; import { EnvironmentService } from '../../abstractions/environment.service'; @@ -37,7 +40,6 @@ export class TwoFactorComponent implements OnInit, OnDestroy { twoFactorEmail: string = null; formPromise: Promise; emailPromise: Promise; - resetMasterPassword: boolean = false; onSuccessfulLogin: () => Promise; onSuccessfulLoginNavigate: () => Promise; @@ -60,7 +62,7 @@ export class TwoFactorComponent implements OnInit, OnDestroy { } if (this.authService.authingWithSso()) { - this.successRoute = this.resetMasterPassword ? 'reset-master-password' : 'lock'; + this.successRoute = 'lock'; } if (this.initU2f && this.win != null && this.u2fSupported) { @@ -176,7 +178,7 @@ export class TwoFactorComponent implements OnInit, OnDestroy { try { this.formPromise = this.authService.logInTwoFactor(this.selectedProviderType, this.token, this.remember); - await this.formPromise; + const response: AuthResult = await this.formPromise; const disableFavicon = await this.storageService.get(ConstantsService.disableFaviconKey); await this.stateService.save(ConstantsService.disableFaviconKey, !!disableFavicon); if (this.onSuccessfulLogin != null) { @@ -186,6 +188,9 @@ export class TwoFactorComponent implements OnInit, OnDestroy { if (this.onSuccessfulLoginNavigate != null) { this.onSuccessfulLoginNavigate(); } else { + if (response.resetMasterPassword) { + this.successRoute = 'set-password'; + } this.router.navigate([this.successRoute]); } } catch {