Browse Source

added default user

tags/0.1.0
Robin Thoni 8 years ago
parent
commit
03403b4b03

+ 5
- 6
src/Auth/Business/LuticateBusiness.php View File

@@ -47,13 +47,12 @@ class LuticateBusiness
47 47
                 }
48 48
             }
49 49
         }
50
+        if (is_null(self::$_currentUser)) {
51
+            self::$_currentUser = LuticateUsersBusiness::getById(0);
52
+        }
50 53
 
51 54
         LuController::$parameters["user"] = self::$_currentUser;
52 55
 
53
-        if (self::$_currentUser == null && count($permissions) != 0) {
54
-            return false;
55
-        }
56
-
57 56
         foreach ($permissions as $permission) {
58 57
             $value = LuticatePermissionsBusiness::getUserPermission(self::$_currentUser->getId(), $permission);
59 58
             if (!$value->getVal()) {
@@ -82,7 +81,7 @@ class LuticateBusiness
82 81
         $prefix = "/luticate";
83 82
         $ns = 'Luticate\Auth\Business\\';
84 83
         $route->post("$prefix/login", "${ns}LuticateUsersBusiness", "login");
85
-        $route->put("$prefix/logout", "${ns}LuticateUsersBusiness", "logout", LuticatePermissions::USER_LOGIN);
86
-        $route->post("$prefix/add", "${ns}LuticateUsersBusiness", "add");
84
+        $route->put("$prefix/logout", "${ns}LuticateUsersBusiness", "logout");
85
+        $route->post("$prefix/add", "${ns}LuticateUsersBusiness", "add", LuticatePermissions::USER_ADD);
87 86
     }
88 87
 }

+ 10
- 2
src/Auth/Business/LuticateUsersBusiness.php View File

@@ -32,8 +32,16 @@ class LuticateUsersBusiness extends LuBusiness {
32 32
         return password_verify($password, $hash);
33 33
     }
34 34
 
35
-    public static function getSalt($length = 10)
35
+    /**
36
+     * @param $user LuticateUsersDbo
37
+     * @param int $length
38
+     * @return string
39
+     */
40
+    public static function getSalt($user, $length = 10)
36 41
     {
42
+        if ($user->getId() == 0) {
43
+            return "";
44
+        }
37 45
         $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
38 46
         $charactersLength = strlen($characters);
39 47
         $randomString = '';
@@ -73,7 +81,7 @@ class LuticateUsersBusiness extends LuBusiness {
73 81
      */
74 82
     public static function logout($user)
75 83
     {
76
-        $user->setSalt(self::getSalt());
84
+        $user->setSalt(self::getSalt($user));
77 85
         LuticateUsersDataAccess::editById($user->getId(), $user);
78 86
         return true;
79 87
     }

Loading…
Cancel
Save