OauthService.logOut(true) not logging out of the identity server.
See original GitHub issueWe have a requirement where we are required to logout the user on some pages, like if the user goes to FAQ question after having a logged in session we want to explicitly terminate the session and require user to login again to go to any page.
On ngOnit
of this page(faq page) we are calling this.oauthService.logOut(true)
so that the user should be logged. What i have observed so far is that i did cleans up the localstorage
and cookies
associated with it but did’t call the logout for the identity server as the result the user is able to go back to dashboard page without logging again.
Below i am providing the minimal sample code of the component
import { Component, OnInit, ViewChild, ElementRef } from '@angular/core';
import { CookieService } from 'ngx-cookie-service';
import { OAuthService } from 'angular-oauth2-oidc';
import { Title } from '@angular/platform-browser';
import { NgxSpinnerService } from 'ngx-spinner';
import * as $ from 'jquery';
@Component({
selector: 'app-register',
templateUrl: './register.component.html',
styleUrls: ['./register.component.css']
})
export class RegisterComponent implements OnInit {
modalOptions: NgbModalOptions;
registerForm; otpForm; captureIncomeForm; captureIncomeModelRef;
constructor(
private cookieService: CookieService,
private oauthService: OAuthService,
private titleService: Title
) {
this.modalOptions = {
backdrop: 'static',
backdropClass: 'customBackdrop'
};
location.onPopState(() => this.modalService.dismissAll());
this.titleService.setTitle('*************************');
}
ngOnInit() {
localStorage.removeItem('tempToken');
this.logOut();
}
logOut() {
console.log("logout calling");
this.cookieService.delete('submissionId', '/');
this.cookieService.delete('uType', '/');
this.oauthService.logOut(true);
this.cookieService.delete('submissionId', '/');
console.log("oauthService logout called");
return false;
}
azureAdlogin(message) {
localStorage.removeItem('tempToken');
let submissionId = '';
if (this.cookieService.get('submissionId')) {
submissionId = this.cookieService.get('submissionId');
}
this.oauthService.initLoginFlow('', {
submissionId, ccAppUrl: window.location.origin,
instrumentationKey: environment.appInsights.instrumentationKey, message
});
}
}
using angular-oauth2-oidc 8.0.4 I have also read few issues regarding this but to no help. Any suggestion/help will be appreciated.
Issue Analytics
- State:
- Created 3 years ago
- Comments:9
Top GitHub Comments
I have found a workaround it. Closing this issue and very thanks for info
yes, thanks for the info