cherry pick from master

This commit is contained in:
Nikolaos Laskaris 2017-11-23 13:13:20 +02:00 committed by annampak
parent 2c47630087
commit 123660f250
4 changed files with 11 additions and 21 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

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

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

View File

@ -52,16 +52,10 @@
</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>
</body> </body>
</html> </html>