forked from imselmon/meeting_pages
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauth.php
55 lines (37 loc) · 1.54 KB
/
auth.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
include "config.php";
use Kreait\Firebase\Factory;
use Kreait\Firebase\Exception\Auth\FailedToVerifySessionCookie;
if(isset($_COOKIE['user_session'])) {
if (isset( $_SESSION['idTokenString'])) {
try {
$sessionCookieString = $_COOKIE['user_session'];
$idTokenString = $_SESSION['idTokenString'];
try {
$verifiedSessionCookie = $auth->verifySessionCookie($sessionCookieString);
try {
$verifiedIdToken = $auth->verifyIdToken($idTokenString);
} catch (\Lcobucci\JWT\Token\InvalidTokenStructure) {
$_SESSION ['expiry_status'] = "Token Expired/Invalid. Login again";
exit();
} catch (InvalidArgumentException $e) {
echo 'The token could not be parsed: ' . $e->getMessage();
$_SESSION ['expiry_status'] = "Token Expired/Invalid. Login again";
exit();
}
} catch (FailedToVerifySessionCookie $e) {
$_SESSION ['expiry_status'] = "User Session Expired/Invalid. Login again";
header('Location:logout.php');
exit();
}
} catch (Exception) {
$_SESSION ['expiry_status'] = "User Session Expired/Invalid. Login again";
header('Location:logout.php');
exit();
}
}else{
$_SESSION ['status'] = "Login to accsess this page ";
header('Location:login.php');
exit();
}
}