-
Notifications
You must be signed in to change notification settings - Fork 0
/
loginGoogle.php
31 lines (30 loc) · 1.21 KB
/
loginGoogle.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
<?php
require_once 'GoogleAPI/vendor/autoload.php';
require_once "base.php";
$id_token = $_POST["idtoken"];
$CLIENT_ID = "8751899160-bmc7qpi981l19htokhlq8pdoc8g39b7g.apps.googleusercontent.com";
$client = new Google_Client(['client_id' => $CLIENT_ID]); // Specify the CLIENT_ID of the app that accesses the backend
$payload = $client->verifyIdToken($id_token);
if ($payload) {
$userid = $payload['sub'];
$emailGoogle = $payload['email'];
$queryEmail = "SELECT * FROM utenti WHERE email LIKE \"$emailGoogle\"";
$tmp = mysqli_query($con, $queryEmail);
if(mysqli_num_rows($tmp) == 0) {
esci("Email non registrata! Contatta l'amministratore.");
}
else {
$u = mysqli_fetch_array($tmp);
$utente = $u["nome"];
$idutente = $u["idutente"];
$not = $u["notifiche"];
$_SESSION["utente"] = $utente;
$_SESSION["idutente"] = $idutente;
$_SESSION["emailutente"] = $email;
$_SESSION["notifiche"] = $not;
}
echo "Login effettuato!";
exit();
} else {
echo "Not okay man. Not okay at all";
}