44 lines
1.4 KiB
TypeScript
44 lines
1.4 KiB
TypeScript
import { Component, OnInit, NgZone } from '@angular/core';
|
|
import {GoogleSignInSuccess} from 'angular-google-signin';
|
|
import { Router, ActivatedRoute } from '@angular/router';
|
|
|
|
@Component({
|
|
selector: 'login-page',
|
|
templateUrl: './login-page.html',
|
|
providers: []
|
|
})
|
|
export class LoginComponent implements OnInit{
|
|
returnUrl: string;
|
|
|
|
constructor(
|
|
private route: ActivatedRoute,
|
|
private router: Router,
|
|
private ngZone: NgZone){
|
|
|
|
}
|
|
|
|
ngOnInit() {
|
|
// reset login status
|
|
//this.authenticationService.logout();
|
|
|
|
// get return url from route parameters or default to '/'
|
|
this.returnUrl = this.route.snapshot.queryParams['returnUrl'] || '/';
|
|
}
|
|
private myClientId: string = '524432312250-vhgidft856v8qftsc81kls4c74v87d8o.apps.googleusercontent.com';
|
|
|
|
onGoogleSignInSuccess(event: GoogleSignInSuccess) { debugger;
|
|
let googleUser: gapi.auth2.GoogleUser = event.googleUser;
|
|
let id: string = googleUser.getId();
|
|
let profile: gapi.auth2.BasicProfile = googleUser.getBasicProfile();
|
|
console.log('ID: ' +
|
|
profile
|
|
.getId()); // Do not send to your backend! Use an ID token instead.
|
|
console.log('Name: ' + profile.getName());
|
|
localStorage.setItem('currentUser', JSON.stringify(googleUser));
|
|
//this.router.navigateByUrl('dynamic-form');
|
|
this.ngZone.run(() => this.router.navigateByUrl('projects'))
|
|
//this.router.navigate(['/projects']);
|
|
}
|
|
|
|
}
|