fixed glitches of google-sign-in component

This commit is contained in:
Nikolaos Laskaris 2017-11-23 13:13:20 +02:00
parent 7a35eafab8
commit a00eec68d8
4 changed files with 12 additions and 22 deletions

View File

@ -57,12 +57,10 @@ export class AppComponent implements OnInit {
login(){ login(){
//redirect to login page //redirect to login page
this.router.navigate(['/login'], { queryParams: { /*refresh : Math.random() ,returnUrl: this.state.url*/ }}); this.router.navigate(['/login'], { queryParams: { /*refresh : Math.random() ,returnUrl: this.state.url*/ }});
location.reload();
} }
logout(){ logout(){
this.tokenService.logout(); this.tokenService.logout();
location.reload();
} }

View File

@ -28,16 +28,6 @@ export class GooggleSignInComponent implements OnInit, AfterViewInit, Injectable
ngAfterViewInit() { ngAfterViewInit() {
/*
$( window ).on( "load", function(){
if($("#googleBtn").length == 0) {
alert("GoogleButton found");
}
});
*/
this.googleInit(); this.googleInit();
} }
@ -64,8 +54,16 @@ export class GooggleSignInComponent implements OnInit, AfterViewInit, Injectable
cookiepolicy: 'single_host_origin', cookiepolicy: 'single_host_origin',
scope: this.scope 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'); var buttonElement = this.element.nativeElement.querySelector('#googleBtn');
this.attachSignin(buttonElement); this.attachSignin(buttonElement);
}); });
} }

View File

@ -52,13 +52,7 @@
</head> </head>
<body> <body>
<script> <script>
  function signOut() {
    var auth2 = gapi.auth2.getAuthInstance();
    auth2.signOut().then(function () {
      console.log('User signed out.');
localStorage.removeItem('currentUser');
    });
  }
</script> </script>
<app-root></app-root> <app-root></app-root>