|
@@ -6,7 +6,6 @@ use Illuminate\Http\Request;
|
6
|
6
|
use Luticate\Utils\LuBusiness;
|
7
|
7
|
use Luticate\Auth\DataAccess\LuticateUsersDataAccess;
|
8
|
8
|
use Luticate\Auth\DBO\LuticateUsersDbo;
|
9
|
|
-use Luticate\Utils\LuRoute;
|
10
|
9
|
|
11
|
10
|
class LuticateUsersBusiness extends LuBusiness {
|
12
|
11
|
/**
|
|
@@ -34,29 +33,23 @@ class LuticateUsersBusiness extends LuBusiness {
|
34
|
33
|
public static function authFilter($permissions, $request)
|
35
|
34
|
{
|
36
|
35
|
$token = $request->header(self::TOKEN_HEADER);
|
37
|
|
- if ($token == null)
|
38
|
|
- {
|
39
|
|
- return false;
|
|
36
|
+ if ($token != null && $token != "") {
|
|
37
|
+ $data = JwtHelper::decode($token);
|
|
38
|
+ if ($data != null) {
|
|
39
|
+ $user_id = $data[JwtHelper::USER_KEY];
|
|
40
|
+ self::$_currentUser = LuticateUsersBusiness::getById($user_id);
|
|
41
|
+ }
|
40
|
42
|
}
|
41
|
|
- $data = JwtHelper::decode($token);
|
42
|
|
- if ($data == null)
|
43
|
|
- {
|
|
43
|
+
|
|
44
|
+ if (self::$_currentUser == null && count($permissions) != 0) {
|
44
|
45
|
return false;
|
45
|
46
|
}
|
46
|
|
- $user_id = $data[JwtHelper::USER_KEY];
|
47
|
47
|
|
48
|
48
|
foreach ($permissions as $permission) {
|
49
|
|
- if (!LuticatePermissionsBusiness::getUserPermission($user_id, $permission)) {
|
|
49
|
+ if (!LuticatePermissionsBusiness::getUserPermission(self::$_currentUser->getId(), $permission)) {
|
50
|
50
|
return false;
|
51
|
51
|
}
|
52
|
52
|
}
|
53
|
|
-
|
54
|
|
- $user = LuticateUsersBusiness::getById($user_id);
|
55
|
|
- if ($user == null)
|
56
|
|
- {
|
57
|
|
- return false;
|
58
|
|
- }
|
59
|
|
- self::$_currentUser = $user;
|
60
|
53
|
return true;
|
61
|
54
|
}
|
62
|
55
|
}
|