-
Notifications
You must be signed in to change notification settings - Fork 0
/
g_login.php
71 lines (31 loc) · 1.2 KB
/
g_login.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
include_once("config.php");
include_once("includes/functions.php");
//print_r($_GET);die;
if(isset($_REQUEST['code'])){
$gClient->authenticate();
$_SESSION['token'] = $gClient->getAccessToken();
header('Location: ' . filter_var($redirect_url, FILTER_SANITIZE_URL));
}
if (isset($_SESSION['token'])) {
$gClient->setAccessToken($_SESSION['token']);
}
if ($gClient->getAccessToken()) {
$userProfile = $google_oauthV2->userinfo->get();
//print_r($userProfile);exit;
//DB Insert
$gUser = new Users();
$_SESSION['registration_id']=$gUser->checkUser('google',$userProfile['id'],$userProfile['given_name'],$userProfile['family_name'],$userProfile['email'],$userProfile['gender'],$userProfile['locale'],$userProfile['link'],$userProfile['picture']);
//echo $_SESSION['registration_id'];exit;
//$_SESSION['google_data'] = $userProfile; // Storing Google User Data in Session
//$_SESSION['registration_id'];
//header("location: account.php");
$_SESSION['token'] = $gClient->getAccessToken();
} else {
$authUrl = $gClient->createAuthUrl();
}
/*
if(isset($authUrl)) {
echo '<a href="'.$authUrl.'"><img src="images/glogin.png" alt=""/></a>';
} */
?>