@@ -11,6 +11,11 @@ import { OAuthService } from 'angular-oauth2-oidc';
11
11
import { AuthService } from './auth.service' ;
12
12
import { StoreService } from './store.service' ;
13
13
14
+ export type MfaExceptionType =
15
+ | 'MfaPrivilegeException'
16
+ | 'MfaRolePrivilegeException'
17
+ | 'MfaTimeoutException' ;
18
+
14
19
@Injectable ( {
15
20
providedIn : 'root' ,
16
21
} )
@@ -30,20 +35,24 @@ export class MfaHandlerService {
30
35
* opened another window and the user cannot continue in the original application
31
36
* without finishing authentication/closing the second window
32
37
*/
33
- openMfaWindow ( mfaRoleException : boolean ) : Observable < boolean > {
38
+ openMfaWindow ( mfaExceptionType : MfaExceptionType ) : Observable < boolean > {
34
39
let newWindow : Window = null ;
35
40
let dialogRef : MatDialogRef < FocusOnMfaWindowComponent , void > = null ;
36
41
37
42
const configVerify = getDefaultDialogConfig ( ) ;
38
43
configVerify . width = '450px' ;
39
44
configVerify . data = {
40
- mfaRoleException : mfaRoleException ,
45
+ mfaRoleException : mfaExceptionType === 'MfaRolePrivilegeException' ,
41
46
} ;
42
47
const dialogVerifyRef = this . dialog . open ( MfaRequiredDialogComponent , configVerify ) ;
43
48
let verificationSkipped = false ;
44
49
45
50
dialogVerifyRef . afterClosed ( ) . subscribe ( ( result ) => {
46
51
if ( result ) {
52
+ if ( mfaExceptionType === 'MfaTimeoutException' ) {
53
+ localStorage . setItem ( 'mfaTimeout' , 'true' ) ;
54
+ }
55
+
47
56
localStorage . setItem ( 'mfaRequired' , 'true' ) ;
48
57
49
58
// save tokens - if MFA will NOT be successful, we will need to give them back to oauth storage
@@ -82,6 +91,7 @@ export class MfaHandlerService {
82
91
dialogRef . close ( ) ;
83
92
localStorage . removeItem ( 'mfaRequired' ) ;
84
93
localStorage . removeItem ( 'mfaProcessed' ) ;
94
+ localStorage . removeItem ( 'mfaTimeout' ) ;
85
95
// if the window is closed without successful MFA, then give back previous tokens to the oauth storage
86
96
if ( this . oauthService . getAccessToken ( ) === null ) {
87
97
localStorage . setItem ( 'access_token' , sessionStorage . getItem ( 'oldAccessToken' ) ) ;
@@ -132,6 +142,7 @@ export class MfaHandlerService {
132
142
closeMfaWindow ( ) : void {
133
143
if ( localStorage . getItem ( 'mfaProcessed' ) && ! localStorage . getItem ( 'mfaRequired' ) ) {
134
144
localStorage . removeItem ( 'mfaProcessed' ) ;
145
+ localStorage . removeItem ( 'mfaTimeout' ) ;
135
146
window . close ( ) ;
136
147
}
137
148
}
0 commit comments