fixed glitches of google-sign-in component
This commit is contained in:
parent
7a35eafab8
commit
a00eec68d8
|
@ -57,12 +57,10 @@ export class AppComponent implements OnInit {
|
|||
login(){
|
||||
//redirect to login page
|
||||
this.router.navigate(['/login'], { queryParams: { /*refresh : Math.random() ,returnUrl: this.state.url*/ }});
|
||||
location.reload();
|
||||
}
|
||||
|
||||
logout(){
|
||||
this.tokenService.logout();
|
||||
location.reload();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -28,16 +28,6 @@ export class GooggleSignInComponent implements OnInit, AfterViewInit, Injectable
|
|||
|
||||
ngAfterViewInit() {
|
||||
|
||||
/*
|
||||
$( window ).on( "load", function(){
|
||||
|
||||
if($("#googleBtn").length == 0) {
|
||||
alert("GoogleButton found");
|
||||
}
|
||||
|
||||
});
|
||||
*/
|
||||
|
||||
this.googleInit();
|
||||
|
||||
}
|
||||
|
@ -64,8 +54,16 @@ export class GooggleSignInComponent implements OnInit, AfterViewInit, Injectable
|
|||
cookiepolicy: 'single_host_origin',
|
||||
scope: this.scope
|
||||
});
|
||||
|
||||
//RE-Render the button (due to known issues of google-button with angular's lifecycle)
|
||||
gapi.signin2.render('googleBtn', {
|
||||
'onsuccess': console.log("SUCCESSFULLY RERENDERED THE BUTTON"),
|
||||
'onfailure': console.log("FAILED TO RERENDER THE BUTTON")
|
||||
});
|
||||
|
||||
var buttonElement = this.element.nativeElement.querySelector('#googleBtn');
|
||||
this.attachSignin(buttonElement);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -52,13 +52,7 @@
|
|||
</head>
|
||||
<body>
|
||||
<script>
|
||||
function signOut() {
|
||||
var auth2 = gapi.auth2.getAuthInstance();
|
||||
auth2.signOut().then(function () {
|
||||
console.log('User signed out.');
|
||||
localStorage.removeItem('currentUser');
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<app-root></app-root>
|
||||
|
|
Loading…
Reference in New Issue