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(){
//redirect to login page
this.router.navigate(['/login'], { queryParams: { /*refresh : Math.random() ,returnUrl: this.state.url*/ }});
location.reload();
}
logout(){
this.tokenService.logout();
location.reload();
}

View File

@ -27,16 +27,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);
});
}

View File

@ -2,7 +2,7 @@
var sign_out_google = (function() {
var auth2 = gapi.auth2.getAuthInstance();
auth2.signOut().then(function () {
console.log('User signed out from google.');
console.log('User signed out from google.');
});
});

View File

@ -49,16 +49,10 @@
<script src="assets/custom.js"></script>
</head>
<body>
</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>