[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
This commit is contained in:
Vincent Salucci 2020-08-26 10:54:16 -05:00 committed by GitHub
parent e55528e617
commit 8f27110754
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 3 deletions

View File

@ -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<any>;
emailPromise: Promise<any>;
resetMasterPassword: boolean = false;
onSuccessfulLogin: () => Promise<any>;
onSuccessfulLoginNavigate: () => Promise<any>;
@ -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<boolean>(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 {