-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTokenCheck.php
More file actions
36 lines (31 loc) · 968 Bytes
/
TokenCheck.php
File metadata and controls
36 lines (31 loc) · 968 Bytes
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
class TokenCheck {
/**
* Validate provided token
* @param string $token
* @param boolean $returnMember
* @return CustomMemberDataEntity
*/
public static function validateToken($token, $returnMember = true) {
if ((!$token) && (isset($_SESSION["Token"]))) {
$token = $_SESSION["Token"];
}
$errorControl = CoreFactory::getErrorControl();
$memberAuthentication = Factory::getMemberAuthentication();
if (!$token) {
$errorControl->addError("Could not log in without token", "InvalidToken");
$memberAuthentication->revokeFacebookSession();
return false;
}
$memberControl = Factory::getMemberControl();
if ($memberDataEntity = $memberControl->getMemberDataEntityByToken($token)) {
if ($returnMember) {
return $memberDataEntity;
}
return true;
}
$errorControl->addError("Invalid token", "InvalidToken");
$memberAuthentication->revokeFacebookSession();
return false;
}
}