@@ -170,20 +170,15 @@ export class AuthService {
170
170
}
171
171
performEndSessionRequest ( state ) {
172
172
return __awaiter ( this , void 0 , void 0 , function * ( ) {
173
- if ( this . _tokenSubject . value != undefined ) {
174
- let requestJson = {
175
- postLogoutRedirectURI : this . authConfig . end_session_redirect_url ,
176
- idTokenHint : this . _tokenSubject . value . idToken || '' ,
177
- state : state || undefined ,
178
- } ;
179
- let request = new EndSessionRequest ( requestJson ) ;
180
- let returnedUrl = yield this . endSessionHandler . performEndSessionRequest ( yield this . configuration , request ) ;
181
- //callback may come from showWindow or via another method
182
- if ( returnedUrl != undefined ) {
183
- this . endSessionCallback ( ) ;
184
- }
185
- } else {
186
- //if user has no token they should not be logged in in the first place
173
+ let requestJson = {
174
+ postLogoutRedirectURI : this . authConfig . end_session_redirect_url ,
175
+ idTokenHint : this . _tokenSubject . value ? this . _tokenSubject . value . idToken || '' : '' ,
176
+ state : state || undefined ,
177
+ } ;
178
+ let request = new EndSessionRequest ( requestJson ) ;
179
+ let returnedUrl = yield this . endSessionHandler . performEndSessionRequest ( yield this . configuration , request ) ;
180
+ //callback may come from showWindow or via another method
181
+ if ( returnedUrl != undefined ) {
187
182
this . endSessionCallback ( ) ;
188
183
}
189
184
} ) ;
@@ -226,8 +221,8 @@ export class AuthService {
226
221
} ) ;
227
222
}
228
223
requestTokenRefresh ( ) {
229
- var _a ;
230
224
return __awaiter ( this , void 0 , void 0 , function * ( ) {
225
+ var _a ;
231
226
if ( ! this . _tokenSubject . value ) {
232
227
throw new Error ( 'No Token Defined!' ) ;
233
228
}
@@ -302,7 +297,10 @@ export class AuthService {
302
297
if ( revokeTokens ) {
303
298
yield this . revokeTokens ( ) ;
304
299
}
305
- yield this . storage . removeItem ( TOKEN_RESPONSE_KEY ) ;
300
+ const token = yield this . storage . getItem ( TOKEN_RESPONSE_KEY ) ;
301
+ if ( token ) {
302
+ yield this . storage . removeItem ( TOKEN_RESPONSE_KEY ) ;
303
+ }
306
304
if ( ( yield this . configuration ) . endSessionEndpoint ) {
307
305
yield this . performEndSessionRequest ( state ) . catch ( ( response ) => {
308
306
this . notifyActionListers ( AuthActionBuilder . SignOutFailed ( response ) ) ;
@@ -343,8 +341,8 @@ export class AuthService {
343
341
this . notifyActionListers ( AuthActionBuilder . SignOutFailed ( response ) ) ;
344
342
} ) ;
345
343
}
346
- getValidToken ( buffer = AUTH_EXPIRY_BUFFER ) {
347
- return __awaiter ( this , void 0 , void 0 , function * ( ) {
344
+ getValidToken ( ) {
345
+ return __awaiter ( this , arguments , void 0 , function * ( buffer = AUTH_EXPIRY_BUFFER ) {
348
346
if ( this . _tokenSubject . value ) {
349
347
if ( ! this . _tokenSubject . value . isValid ( buffer ) ) {
350
348
yield this . refreshToken ( ) ;
0 commit comments