Guest User

Untitled

a guest
Jan 18th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. public auth2: any;
  2. public googleInit() {
  3. gapi.load('auth2', () => {
  4. this.auth2 = gapi.auth2.init({
  5. client_id: 'my-client id',
  6. scope: 'profile email'
  7. });
  8. this.attachSignin(document.getElementById('googleSignIn'));
  9. });
  10. }
  11. public attachSignin(element:any) {
  12. this.auth2.attachClickHandler(element, {},
  13. (googleUser:any) => {
  14. let profile = googleUser.getBasicProfile();
  15.  
  16. this.login(profile.getEmail(),"", 'S')/*Calling login function*/
  17. },
  18. (error:any) => {
  19. //alert(JSON.stringify(error, undefined, 2));
  20. });
  21. }
  22.  
  23. ngAfterViewInit(){
  24. this.googleInit();
  25. }
  26.  
  27. login(userId: string, password: string, option: string) {
  28. this.authenticationService.login(userId,password,option)
  29. .subscribe(
  30. data => {
  31. if (data.responseStatus) {
  32. this.isSignBtnDisbld=false;
  33. this.router.navigate(['/home']);
  34. } else {
  35. alert(data.errorMsg);
  36.  
  37. }
  38. },
  39. error => {
  40. alert("Server Error");
  41. });
  42. }
Add Comment
Please, Sign In to add comment