Greetings,
I am currently experiencing an issue with signing out of an auth2 client. Previously, this process functioned correctly until I upgraded my router to comply with new RC requirements. Now, it seems that the auth2 object is being cleared or lost during the transition from signing in to signing out.
Below is the sign out tag in question:
<a role="button" (click)="signOut()" style="padding-left: 30px;">Log out</a>
This tag simply triggers a call to the signOut() function located in navbar.component.ts (refer below)
signOut() {
var auth2 = this._navigationService.getAuth2();
auth2.signOut().then(function () {
});
console.log('User signed out.');
sessionStorage.clear();
localStorage.clear();
this.router.navigate(['Login'])
window.location.reload()
}
Here is the code for navigationService that's being referenced:
import { Injectable } from '@angular/core';
@Injectable()
export class NavigationService {
onEditMode:boolean;
auth2:any;
constructor() {
this.onEditMode=true;
}
getEditMode(){
return this.onEditMode;
}
setEditMode(editMode:boolean){
this.onEditMode=editMode;
}
setAuth2(auth2:any){
this.auth2=auth2;
}
getAuth2(){
return this.auth2;
}
}
Additionally, here is the login.component.ts snippet where the auth2 object is set and used from navigationService.ts:
onGoogleLoginSuccess = (loggedInUser) => {
// Code for setting auth2 object
}
The onGoogleLoginSuccess function is called within login.component.html like so:
<div style="margin-left:8% !important" id="{{googleLoginButtonId}}"></div>
Since upgrading my router to the latest Angular2 Release Candidate version, I have encountered the following error when attempting to sign out:
Error in component.html/navbar.component.html:12:33
ORIGINAL EXCEPTION: TypeError: Cannot read property 'signOut' of undefined
If further information or components are needed, please feel free to inquire. Given that everything was functioning properly before the update, any insights into resolving this issue are greatly appreciated.