Pārlūkot izejas kodu

added setting for user session duration

tags/0.1.2
Robin Thoni 8 gadus atpakaļ
vecāks
revīzija
4b0bd6b0e0

+ 2
- 2
src/Auth/Business/JwtHelper.php Parādīt failu

31
         return $data;
31
         return $data;
32
     }
32
     }
33
 
33
 
34
-    public static function encode($data)
34
+    public static function encode($data, $session_time)
35
     {
35
     {
36
         $date = new \DateTime("now", new \DateTimeZone("Europe/Paris"));
36
         $date = new \DateTime("now", new \DateTimeZone("Europe/Paris"));
37
-        $date->modify("+30 day");
37
+        $date->modify("+${session_time} day");
38
         $data[self::EXPIRATION_KEY] = $date->getTimestamp();
38
         $data[self::EXPIRATION_KEY] = $date->getTimestamp();
39
 
39
 
40
         return base64_encode(mcrypt_encrypt(MCRYPT_TRIPLEDES, env("MCRYPT_KEY"), \JWT::encode($data, env("JWT_KEY")), "ecb"));
40
         return base64_encode(mcrypt_encrypt(MCRYPT_TRIPLEDES, env("MCRYPT_KEY"), \JWT::encode($data, env("JWT_KEY")), "ecb"));

+ 16
- 4
src/Auth/Business/LuticateSettingsBusiness.php Parādīt failu

99
         return $setting;
99
         return $setting;
100
     }
100
     }
101
 
101
 
102
+    public static function getEffectiveSettingValue($user_id, $setting_name)
103
+    {
104
+        $setting = self::getEffectiveSetting($user_id, $setting_name);
105
+        return $setting["Value"];
106
+    }
107
+
102
     public static function getAllEffectiveSetting($user_id)
108
     public static function getAllEffectiveSetting($user_id)
103
     {
109
     {
104
         return LuticateSettingsDataAccess::getAllEffectiveSetting($user_id)->map(function($value)
110
         return LuticateSettingsDataAccess::getAllEffectiveSetting($user_id)->map(function($value)
111
 
117
 
112
     public static function get($setting_name)
118
     public static function get($setting_name)
113
     {
119
     {
114
-        $perm = LuticateSettingsDataAccess::getByName($setting_name);
115
-        if (is_null($perm)) {
120
+        $setting = LuticateSettingsDataAccess::getByName($setting_name);
121
+        if (is_null($setting)) {
116
             self::notFound("Permission not found");
122
             self::notFound("Permission not found");
117
         }
123
         }
118
-        $perm->setValue(json_decode($perm->getValue()));
119
-        return $perm;
124
+        $setting->setValue(json_decode($setting->getValue()));
125
+        return $setting;
126
+    }
127
+
128
+    public static function getValue($setting_name)
129
+    {
130
+        $setting = self::get($setting_name);
131
+        return $setting->getValue();
120
     }
132
     }
121
 
133
 
122
     /**
134
     /**

+ 2
- 1
src/Auth/Business/LuticateUsersBusiness.php Parādīt failu

55
      */
55
      */
56
     public static function getToken($user, $data = null)
56
     public static function getToken($user, $data = null)
57
     {
57
     {
58
+        $session_time = LuticateSettingsBusiness::getValue("LU_SESSION_DAYS");
58
         return JwtHelper::encode(array(
59
         return JwtHelper::encode(array(
59
             self::KEY_USER_ID => $user->getId(),
60
             self::KEY_USER_ID => $user->getId(),
60
             self::KEY_SALT => $user->getSalt(),
61
             self::KEY_SALT => $user->getSalt(),
61
             self::KEY_DATA => $data
62
             self::KEY_DATA => $data
62
-            ));
63
+            ), $session_time);
63
     }
64
     }
64
 
65
 
65
     /**
66
     /**

Notiek ielāde…
Atcelt
Saglabāt