|
|
@@ -1,4 +1,5 @@ |
|
|
|
import { Component, OnInit } from '@angular/core'; |
|
|
|
import { Router } from '@angular/router'; |
|
|
|
import { UserService } from '../../services/user.service'; |
|
|
|
|
|
|
|
// For capacitor Facebook |
|
|
@@ -28,7 +29,8 @@ export class FacebookLoginComponent implements OnInit { |
|
|
|
constructor( |
|
|
|
private platform: Platform, |
|
|
|
private http: HttpClient, |
|
|
|
private userService: UserService |
|
|
|
private userService: UserService, |
|
|
|
private router: Router |
|
|
|
) { |
|
|
|
} |
|
|
|
|
|
|
@@ -87,11 +89,16 @@ export class FacebookLoginComponent implements OnInit { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
async loadUserData() { |
|
|
|
async loadUserData(isFirstTime?: boolean) { |
|
|
|
const url = `https://graph.facebook.com/${this.token.userId}?fields=id,name,picture.width(720),email&access_token=${this.token.token}`; |
|
|
|
this.http.get(url).subscribe(res => { |
|
|
|
this.user = res; |
|
|
|
localStorage.setItem('FBUser', JSON.stringify(res)); |
|
|
|
|
|
|
|
if (isFirstTime) { |
|
|
|
this.router.navigate(['/welcome']); |
|
|
|
} |
|
|
|
|
|
|
|
}, (err) => { |
|
|
|
console.log(JSON.stringify(err)); |
|
|
|
alert("Falied to fetch user data"); |
|
|
|