L'utilisateur est maintenant déconnecté lorsque sa connexion est expirée.
This commit is contained in:
parent
caa82ff64e
commit
31b140fe80
|
@ -73,9 +73,7 @@ export class AccountService implements OnDestroy {
|
|||
)
|
||||
.subscribe({
|
||||
next: () => {
|
||||
this.appState.isAuthenticated = false
|
||||
this.appState.authenticationExpiration = -1
|
||||
this.appState.authenticatedEmployee = null
|
||||
this.appState.resetAuthenticatedEmployee()
|
||||
this.checkAuthenticationStatus()
|
||||
success()
|
||||
},
|
||||
|
|
|
@ -13,6 +13,13 @@ export class AppState {
|
|||
authenticatedUser$ = new Subject<{ authenticated: boolean, authenticatedUser: Employee }>()
|
||||
serverOnline$ = new Subject<boolean>()
|
||||
|
||||
resetAuthenticatedEmployee() {
|
||||
this.isAuthenticated = false
|
||||
this.authenticationExpiration = -1
|
||||
this.authenticatedEmployee = null
|
||||
|
||||
}
|
||||
|
||||
set isServerOnline(isOnline: boolean) {
|
||||
if (!isOnline) this.authenticatedEmployee = null
|
||||
this.serverOnline$.next(isOnline);
|
||||
|
|
|
@ -7,6 +7,7 @@ import {Router} from '@angular/router'
|
|||
import {map, share, takeUntil} from 'rxjs/operators'
|
||||
import {valueOr} from '../utils/utils'
|
||||
import {ErrorService} from './error.service'
|
||||
import {AccountService} from '../../accounts/services/account.service'
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
|
@ -77,17 +78,16 @@ export class ApiService implements OnDestroy {
|
|||
console.error('httpOptions need to be specified to use credentials in HTTP methods.')
|
||||
}
|
||||
} else {
|
||||
this.appState.resetAuthenticatedEmployee()
|
||||
this.navigateToLogin()
|
||||
}
|
||||
}
|
||||
|
||||
const result$ = requestOptions.takeFullResponse
|
||||
return requestOptions.takeFullResponse
|
||||
? requestFn(httpOptions)
|
||||
.pipe(takeUntil(this._destroy$), share())
|
||||
: requestFn(httpOptions)
|
||||
.pipe(takeUntil(this._destroy$), map(r => r.body), share())
|
||||
|
||||
return result$
|
||||
}
|
||||
|
||||
private checkAuthenticated(): boolean {
|
||||
|
|
Loading…
Reference in New Issue