浏览代码

added all permissions; added all routes; users controller and business

develop
Robin Thoni 8 年前
父节点
当前提交
b786f2e883

+ 123
- 21
src/Auth/Business/LuUsersBusiness.php 查看文件

@@ -8,13 +8,15 @@
8 8
 
9 9
 namespace Luticate\Auth\Business;
10 10
 
11
-use Illuminate\Database\Query\Builder;
12 11
 use Luticate\Auth\DataAccess\LuUserDataAccess;
13
-use Luticate\Auth\Dbo\LuUsersDbo;
14
-use Luticate\Auth\Dbo\LuUsersLiteDbo;
15
-use Luticate\Auth\Dbo\LuUsersLoginDbo;
16
-use Luticate\Auth\Dbo\LuUsersLoginResultDbo;
12
+use Luticate\Auth\Dbo\Users\LuUsersAddDbo;
13
+use Luticate\Auth\Dbo\Users\LuUsersDbo;
14
+use Luticate\Auth\Dbo\Users\LuUsersEditDbo;
15
+use Luticate\Auth\Dbo\Users\LuUsersLiteDbo;
16
+use Luticate\Auth\Dbo\Users\LuUsersLoginDbo;
17
+use Luticate\Auth\Dbo\Users\LuUsersLoginResultDbo;
17 18
 use Luticate\Utils\Business\LuBusiness;
19
+use Luticate\Utils\Dbo\LuPaginatedDbo;
18 20
 use Luticate\Utils\Dbo\LuQueryDbo;
19 21
 
20 22
 class LuUsersBusiness extends LuBusiness
@@ -31,22 +33,29 @@ class LuUsersBusiness extends LuBusiness
31 33
         return new LuUserDataAccess();
32 34
     }
33 35
 
34
-    protected static function badPassword()
36
+    protected function badPassword()
35 37
     {
36 38
         static::unauthorized("Bad username/password");
37 39
     }
38 40
 
39
-    public static function hashPassword($password)
41
+    public function hashPassword(string $password)
40 42
     {
41 43
         return password_hash($password, PASSWORD_BCRYPT);
42 44
     }
43 45
 
44
-    public static function verifyPassword($password, $hash)
46
+    public function verifyPassword(string $password, string $hash)
45 47
     {
46 48
         return password_verify($password, $hash);
47 49
     }
48 50
 
49
-    public static function getSalt($length = 10)
51
+    public function checkPasswordRequirements(string $password)
52
+    {
53
+        if (strlen($password) < 5) { //TODO: add a setting
54
+            self::badInput("Password must have at least 5 characters");
55
+        }
56
+    }
57
+
58
+    public function getSalt($length = 10)
50 59
     {
51 60
         $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
52 61
         $charactersLength = strlen($characters);
@@ -57,14 +66,9 @@ class LuUsersBusiness extends LuBusiness
57 66
         return $randomString;
58 67
     }
59 68
 
60
-    /**
61
-     * @param $user LuUsersDbo
62
-     * @param $data mixed
63
-     * @return string
64
-     */
65
-    public static function getToken($user, $data = null)
69
+    public function getToken(LuUsersDbo $user, $data = null)
66 70
     {
67
-        $session_time = 30;//LuticateSettingsBusiness::getValue("LU_SESSION_DAYS");
71
+        $session_time = 30;//TODO add a setting
68 72
         return JwtHelper::encode(array(
69 73
             self::KEY_USER_ID => $user->getId(),
70 74
             self::KEY_SALT => $user->getSalt(),
@@ -72,7 +76,7 @@ class LuUsersBusiness extends LuBusiness
72 76
         ), $session_time);
73 77
     }
74 78
 
75
-    public static function login(LuUsersLoginDbo $login)
79
+    public function login(LuUsersLoginDbo $login)
76 80
     {
77 81
         $user = static::getDataAccess()->getByUsernameOrEmail($login->getUsername());
78 82
         if (is_null($user))
@@ -88,7 +92,7 @@ class LuUsersBusiness extends LuBusiness
88 92
         return $result;
89 93
     }
90 94
 
91
-    public static function logout(LuUsersDbo $user)
95
+    public function logout(LuUsersDbo $user)
92 96
     {
93 97
         if ($user->getId() != 0) {
94 98
             $user->setSalt(self::getSalt());
@@ -97,18 +101,116 @@ class LuUsersBusiness extends LuBusiness
97 101
         return true;
98 102
     }
99 103
 
104
+    public function getSingleLiteById($userId)
105
+    {
106
+        /**
107
+         * @var $user LuUsersDbo
108
+         */
109
+        $user = static::getById($userId);
110
+        return $user->toLite();
111
+    }
112
+
100 113
     /**
101 114
      * @param LuQueryDbo $query
102
-     * @return LuUsersLiteDbo[]
115
+     * @return LuPaginatedDbo
103 116
      */
104
-    public static function getAllLite(LuQueryDbo $query)
117
+    public function getAllLite(LuQueryDbo $query)
105 118
     {
106 119
         return static::getDataAccess()->getAll($query)->map(function($user)
107 120
         {
108 121
             /**
109 122
              * @var $user LuUsersDbo
110 123
              */
111
-            return $user->castAs(LuUsersLiteDbo::class);
124
+            return $user->toLite();
112 125
         });
113 126
     }
127
+
128
+    public function add(LuUsersAddDbo $user)
129
+    {
130
+        static::checkPasswordRequirements($user->getPassword());
131
+
132
+        if (filter_var($user->getUsername(), FILTER_VALIDATE_EMAIL)) {
133
+            self::badInput("Username can not be an email");
134
+        }
135
+        if (!preg_match("/^[A-Za-z0-9\\-_\\.]+$/", $user->getUsername())) {
136
+            self::badInput("Username can only contain letters (A-Z a-z), numbers (0-9), hyphen (-), underscore (_) and dot (.)");
137
+        }
138
+        if (!filter_var($user->getEmail(), FILTER_VALIDATE_EMAIL)) {
139
+            self::badInput("Invalid email address");
140
+        }
141
+        $existingUser = static::getDataAccess()->getByUsernameOrEmail($user->getUsername());
142
+        if ($existingUser != null) {
143
+            self::badInput("Username already exists");
144
+        }
145
+        $existingUser = static::getDataAccess()->getByUsernameOrEmail($user->getEmail());
146
+        if ($existingUser != null) {
147
+            self::badInput("Email already used");
148
+        }
149
+        $user->setPassword(self::hashPassword($user->getPassword()));
150
+        $user->setExternalAuth(null);
151
+        $user->setProfileId(null);
152
+
153
+        /**
154
+         * @var LuUsersDbo $newUser
155
+         */
156
+        $newUser = $user->castAs(LuUsersDbo::class);
157
+        $newUser->setSalt(static::getSalt());
158
+
159
+        $id = static::getDataAccess()->addSingleId($newUser);
160
+        return self::getById($id);
161
+    }
162
+
163
+    public function del(int $userId)
164
+    {
165
+        $user = static::getSingleLiteById($userId);
166
+        if ($userId != 0) {
167
+            static::deleteById($user->getId());
168
+        }
169
+        return $user;
170
+    }
171
+
172
+    public function edit(int $userId, LuUsersEditDbo $user)
173
+    {
174
+        $existingUser = static::getSingleLiteById($userId);
175
+        if (!filter_var($user->getEmail(), FILTER_VALIDATE_EMAIL)) {
176
+            self::badInput("Invalid email address");
177
+        }
178
+        $anotherExistingUser = static::getDataAccess()->getByUsernameOrEmail($user->getEmail());
179
+        if ($anotherExistingUser != null && $anotherExistingUser->getId() != $existingUser->getId()) {
180
+            self::badInput("Email already used");
181
+        }
182
+
183
+        $existingUser->setEmail($user->getEmail());
184
+        $existingUser->setFirstname($user->getFirstname());
185
+        $existingUser->setLastname($user->getLastname());
186
+
187
+        static::getDataAccess()->editSingleById($existingUser);
188
+
189
+        return static::getSingleLiteById($existingUser->getId());
190
+    }
191
+
192
+    public function setPassword(int $userId, string $password)
193
+    {
194
+        $this->checkPasswordRequirements($password);
195
+
196
+        /**
197
+         * @var $existingUser LuUsersDbo
198
+         */
199
+        $existingUser = static::getDataAccess()->getSingleById($userId);
200
+        $existingUser->setPassword(static::hashPassword($password));
201
+        $existingUser->setSalt(static::getSalt());
202
+
203
+        static::getDataAccess()->editSingleById($existingUser);
204
+
205
+        return true;
206
+    }
207
+
208
+    public function setPasswordMe(LuUsersDbo $_user, string $password, string $oldPassword)
209
+    {
210
+        $loginDbo = new LuUsersLoginDbo();
211
+        $loginDbo->setUsername($_user->getUsername());
212
+        $loginDbo->setPassword($oldPassword);
213
+        static::login($loginDbo);
214
+        return static::setPassword($_user->getId(), $password);
215
+    }
114 216
 }

+ 144
- 0
src/Auth/Controller/LuAuthController.php 查看文件

@@ -0,0 +1,144 @@
1
+<?php
2
+/**
3
+ * Created by PhpStorm.
4
+ * User: robin
5
+ * Date: 9/17/16
6
+ * Time: 6:02 PM
7
+ */
8
+
9
+namespace Luticate\Auth\Controller;
10
+
11
+
12
+use Luticate\Auth\Dbo\LuBuiltInPermissions;
13
+use Luticate\Utils\Business\LuStringUtils;
14
+use Luticate\Utils\Controller\LuRoute;
15
+
16
+class LuAuthController
17
+{
18
+    private $_route = null;
19
+
20
+    private $_prefix = null;
21
+
22
+    private $_namespace = 'Luticate\Auth\Controller\\';
23
+
24
+    /**
25
+     * @param LuRoute $route
26
+     * @param string $prefix
27
+     */
28
+    function __construct(LuRoute $route, $prefix = '/luticate/')
29
+    {
30
+        $this->_route = $route;
31
+        if (!LuStringUtils::endsWith($prefix, '/')) {
32
+            $prefix .= '/';
33
+        }
34
+        $this->_prefix = $prefix;
35
+    }
36
+
37
+    function setup()
38
+    {
39
+        $int = LuRoute::REG_UINT;
40
+        $name = "[A-Z0-9_]+";
41
+
42
+        $user_id = "{user_id:$int}";
43
+        $group_id = "{group_id:$int}";
44
+        $permission_name = "{permission_name:$name}";
45
+        $setting_name = "{setting_name:$name}";
46
+
47
+        $this->post("users/login", "LuUsersController", "login");
48
+        $this->post("users/logout", "LuUsersController", "logout");
49
+        $this->get("users/me", "LuUsersController", "getMe");
50
+        $this->get("users/$user_id", "LuUsersController", "getById", LuBuiltInPermissions::USER_GET);
51
+        $this->get("users", "LuUsersController", "getAll", LuBuiltInPermissions::USER_LIST);
52
+        $this->post("users/add", "LuUsersController", "add", LuBuiltInPermissions::USER_ADD);
53
+        $this->post("users/$user_id/del", "LuUsersController", "del", LuBuiltInPermissions::USER_DEL);
54
+        $this->post("users/$user_id/edit", "LuUsersController", "edit", LuBuiltInPermissions::USER_EDIT);
55
+        $this->post("users/me/edit", "LuUsersController", "editMe", LuBuiltInPermissions::USER_EDIT_ME);
56
+        $this->post("users/$user_id/setPassword", "LuUsersController", "setPassword", LuBuiltInPermissions::USER_SET_PASSWORD);
57
+        $this->post("users/me/setPassword", "LuUsersController", "setPasswordMe", LuBuiltInPermissions::USER_SET_PASSWORD_ME);
58
+
59
+
60
+        $this->get("groups/$group_id", "LuGroupsController", "getById", LuBuiltInPermissions::GROUP_GET);
61
+        $this->get("groups", "LuGroupsController", "getAll", LuBuiltInPermissions::GROUP_LIST);
62
+        $this->post("groups/add", "LuGroupsController", "add", LuBuiltInPermissions::GROUP_ADD);
63
+        $this->post("groups/$group_id/del", "LuGroupsController", "del", LuBuiltInPermissions::GROUP_DEL);
64
+        $this->post("groups/$group_id/edit", "LuGroupsController", "edit", LuBuiltInPermissions::GROUP_EDIT);
65
+
66
+        $this->get("groups/$group_id/users/", "LuGroupsController", "getUsers", LuBuiltInPermissions::GROUP_GET);
67
+        $this->post("groups/$group_id/users/$user_id/add", "LuGroupsController", "addUser", LuBuiltInPermissions::GROUP_USER_ADD);
68
+        $this->post("groups/$group_id/users/$user_id/del", "LuGroupsController", "delUser", LuBuiltInPermissions::GROUP_USER_DEL);
69
+
70
+
71
+        $this->get("permissions/effective/$user_id/$permission_name", "LuPermissionsController",
72
+            "getEffectivePermission", LuBuiltInPermissions::PERM_EFFECTIVE_GET);
73
+        $this->get("permissions/effective/$user_id", "LuPermissionsController",
74
+            "getAllEffectivePermission", LuBuiltInPermissions::PERM_EFFECTIVE_GET);
75
+        $this->get("permissions/effective/me/$permission_name", "LuPermissionsController", "getEffectivePermissionMe");
76
+        $this->get("permissions/effective/me", "LuPermissionsController", "getAllEffectivePermissionMe");
77
+
78
+        $this->get("permissions/$permission_name", "LuPermissionsController", "get", LuBuiltInPermissions::PERM_GET);
79
+        $this->get("permissions", "LuPermissionsController", "getAll", LuBuiltInPermissions::PERM_LIST);
80
+        $this->post("permissions/add/$permission_name", "LuPermissionsController", "add", LuBuiltInPermissions::PERM_ADD);
81
+        $this->post("permissions/$permission_name/del", "LuPermissionsController", "del", LuBuiltInPermissions::PERM_DEL);
82
+        $this->post("permissions/$permission_name/edit", "LuPermissionsController", "edit", LuBuiltInPermissions::PERM_EDIT);
83
+
84
+        $this->get("permissions/group/$group_id/$permission_name", "LuPermissionsGroupsController",
85
+            "get", LuBuiltInPermissions::PERM_GROUP_GET);
86
+        $this->get("permissions/group/$group_id", "LuPermissionsGroupsController",
87
+            "getAllByGroup", LuBuiltInPermissions::PERM_GROUP_LIST);
88
+        $this->post("permissions/group/$group_id/add/$permission_name", "LuPermissionsGroupsController",
89
+            "add", LuBuiltInPermissions::PERM_GROUP_ADD);
90
+        $this->post("permissions/group/$group_id/$permission_name/del", "LuPermissionsGroupsController",
91
+            "del", LuBuiltInPermissions::PERM_GROUP_DEL);
92
+        $this->post("permissions/group/$group_id/$permission_name/edit", "LuPermissionsGroupsController",
93
+            "edit", LuBuiltInPermissions::PERM_GROUP_EDIT);
94
+
95
+        $this->get("permissions/user/$user_id/$permission_name", "LuPermissionsUsersController",
96
+            "get", LuBuiltInPermissions::PERM_USER_GET);
97
+        $this->get("permissions/user/$user_id", "LuPermissionsUsersController",
98
+            "getAllByUser", LuBuiltInPermissions::PERM_USER_LIST);
99
+        $this->post("permissions/user/$user_id/add/$permission_name", "LuPermissionsUsersController",
100
+            "add", LuBuiltInPermissions::PERM_USER_ADD);
101
+        $this->post("permissions/user/$user_id/$permission_name/del", "LuPermissionsUsersController",
102
+            "del", LuBuiltInPermissions::PERM_USER_DEL);
103
+        $this->post("permissions/user/$user_id/$permission_name/edit", "LuPermissionsUsersController",
104
+            "edit", LuBuiltInPermissions::PERM_USER_EDIT);
105
+
106
+
107
+        $this->get("settings/effective/$user_id/$setting_name", "LuSettingsController",
108
+            "getEffectiveSetting", LuBuiltInPermissions::SETTING_EFFECTIVE_GET);
109
+        $this->get("settings/effective/$user_id", "LuSettingsController",
110
+            "getAllEffectiveSetting", LuBuiltInPermissions::SETTING_GET);
111
+        $this->get("settings/effective/me/$setting_name", "LuSettingsController", "getEffectiveSettingMe");
112
+        $this->get("settings/effective/me", "LuSettingsController", "getAllEffectiveSettingMe");
113
+
114
+        $this->get("settings/$setting_name", "LuSettingsController", "get", LuBuiltInPermissions::SETTING_GET);
115
+        $this->get("settings", "LuSettingsController", "getAll", LuBuiltInPermissions::SETTING_GET);
116
+        $this->post("settings/add", "LuSettingsController", "add", LuBuiltInPermissions::SETTING_ADD);
117
+        $this->post("settings/$setting_name/del", "LuSettingsController", "del", LuBuiltInPermissions::SETTING_DEL);
118
+        $this->post("settings/$setting_name/edit", "LuSettingsController", "edit", LuBuiltInPermissions::SETTING_EDIT);
119
+
120
+        $this->get("settings/user/$user_id/$setting_name", "LuSettingsUsersController",
121
+            "get", LuBuiltInPermissions::SETTING_USER_GET);
122
+        $this->get("settings/user/$user_id", "LuSettingsUsersController",
123
+            "getAllByUser", LuBuiltInPermissions::SETTING_USER_GET);
124
+        $this->post("settings/user/$user_id/$setting_name/edit", "LuSettingsUsersController",
125
+            "edit", LuBuiltInPermissions::SETTING_USER_EDIT);
126
+        $this->post("settings/user/me/$setting_name/edit", "LuSettingsUsersController",
127
+            "editMe", LuBuiltInPermissions::SETTING_EDIT_ME);
128
+    }
129
+
130
+    function get(string $url, string $controller, string $method, string ...$permissions)
131
+    {
132
+        $this->_route->get($this->_prefix . $url, $this->_namespace . $controller, $method, ["permissions" => $permissions]);
133
+    }
134
+
135
+    function post(string $url, string $controller, string $method, string ...$permissions)
136
+    {
137
+        $this->_route->post($this->_prefix . $url, $this->_namespace . $controller, $method, ["permissions" => $permissions]);
138
+    }
139
+
140
+    function delete(string $url, string $controller, string $method, string ...$permissions)
141
+    {
142
+        $this->_route->delete($this->_prefix . $url, $this->_namespace . $controller, $method, ["permissions" => $permissions]);
143
+    }
144
+}

+ 93
- 6
src/Auth/Controller/LuUsersController.php 查看文件

@@ -9,10 +9,12 @@
9 9
 namespace Luticate\Auth\Controller;
10 10
 
11 11
 use Luticate\Auth\Business\LuUsersBusiness;
12
-use Luticate\Auth\Dbo\LuUsersDbo;
13
-use Luticate\Auth\Dbo\LuUsersLiteDbo;
14
-use Luticate\Auth\Dbo\LuUsersLoginDbo;
15
-use Luticate\Auth\Dbo\LuUsersLoginResultDbo;
12
+use Luticate\Auth\Dbo\Users\LuUsersDbo;
13
+use Luticate\Auth\Dbo\Users\LuUsersEditDbo;
14
+use Luticate\Auth\Dbo\Users\LuUsersLiteDbo;
15
+use Luticate\Auth\Dbo\Users\LuUsersLoginDbo;
16
+use Luticate\Auth\Dbo\Users\LuUsersLoginResultDbo;
17
+use Luticate\Auth\Dbo\Users\LuUsersAddDbo;
16 18
 use Luticate\Utils\Controller\LuController;
17 19
 use Luticate\Utils\Dbo\LuQueryDbo;
18 20
 
@@ -34,7 +36,7 @@ class LuUsersController extends LuController
34 36
     }
35 37
 
36 38
     /**
37
-     * Logout the logged user
39
+     * Logout the logged user. All tokens will be revoked
38 40
      * @param $_user LuUsersDbo The logged user
39 41
      * @return bool
40 42
      */
@@ -43,13 +45,98 @@ class LuUsersController extends LuController
43 45
         return static::getBusiness()->logout($_user);
44 46
     }
45 47
 
48
+    /**
49
+     * Get the logged user
50
+     * @param $_user LuUsersDbo The user id
51
+     * @return LuUsersLiteDbo
52
+     */
53
+    public function getMe(LuUsersDbo $_user)
54
+    {
55
+        return static::getBusiness()->getSingleLiteById($_user->getId());
56
+    }
57
+
58
+    /**
59
+     * Get a user by its id
60
+     * @param $userId int The user id
61
+     * @return LuUsersLiteDbo
62
+     */
63
+    public function getById(int $userId)
64
+    {
65
+        return static::getBusiness()->getSingleLiteById($userId);
66
+    }
67
+
46 68
     /**
47 69
      * Get all users
48 70
      * @param LuQueryDbo $query The filter query
49 71
      * @return LuUsersLiteDbo[]
50 72
      */
51
-    public function getAllLite(LuQueryDbo $query)
73
+    public function getAll(LuQueryDbo $query)
52 74
     {
53 75
         return static::getBusiness()->getAllLite($query);
54 76
     }
77
+
78
+    /**
79
+     * Add a new user
80
+     * @param LuUsersAddDbo $user The new user
81
+     * @return LuUsersLiteDbo
82
+     */
83
+    public function add(LuUsersAddDbo $user)
84
+    {
85
+        return static::getBusiness()->add($user);
86
+    }
87
+
88
+    /**
89
+     * Delete a user by its id
90
+     * @param $userId int The user id
91
+     * @return LuUsersDbo
92
+     */
93
+    public function del(int $userId)
94
+    {
95
+        return static::getBusiness()->del($userId);
96
+    }
97
+
98
+    /**
99
+     * Edit a user by its id
100
+     * @param int $userId The user id
101
+     * @param LuUsersEditDbo $user The edited user
102
+     * @return LuUsersDbo
103
+     */
104
+    public function edit(int $userId, LuUsersEditDbo $user)
105
+    {
106
+        return static::getBusiness()->edit($userId, $user);
107
+    }
108
+
109
+    /**
110
+     * Edit the logged user
111
+     * @param LuUsersDbo $_user The logged user
112
+     * @param LuUsersEditDbo $user The edited user
113
+     * @return LuUsersDbo
114
+     */
115
+    public function editMe(LuUsersDbo $_user, LuUsersEditDbo $user)
116
+    {
117
+        return static::getBusiness()->edit($_user->getId(), $user);
118
+    }
119
+
120
+    /**
121
+     * Set the user's password by its id
122
+     * @param int $userId The user id
123
+     * @param string $password Ths new user password
124
+     * @return bool
125
+     */
126
+    public function setPassword(int $userId, string $password)
127
+    {
128
+        return static::getBusiness()->setPassword($userId, $password);
129
+    }
130
+
131
+    /**
132
+     * Set the logged user's password
133
+     * @param LuUsersDbo $_user The logged user
134
+     * @param string $password The new user password
135
+     * @param string $oldPassword The current user password
136
+     * @return bool
137
+     */
138
+    public function setPasswordMe(LuUsersDbo $_user, string $password, string $oldPassword)
139
+    {
140
+        return static::getBusiness()->setPasswordMe($_user, $password, $oldPassword);
141
+    }
55 142
 }

+ 2
- 2
src/Auth/DataAccess/LuUserDataAccess.php 查看文件

@@ -10,7 +10,7 @@ namespace Luticate\Auth\DataAccess;
10 10
 
11 11
 
12 12
 use Illuminate\Database\Query\Builder;
13
-use Luticate\Auth\Dbo\LuUsersDbo;
13
+use Luticate\Auth\Dbo\Users\LuUsersDbo;
14 14
 use Luticate\Utils\DataAccess\LuDataAccess;
15 15
 use Luticate\Utils\Dbo\LuQueryDbo;
16 16
 
@@ -31,7 +31,7 @@ class LuUserDataAccess extends LuDataAccess
31 31
             /**
32 32
              * @var $q Builder
33 33
              */
34
-            $q->where("username", "=", $username)->orWhere("email", "=", $username);
34
+            $q->where("username", "=", $username)->orWhere("email", "=", $username);//TODO lowercase
35 35
             return $q;
36 36
         });
37 37
     }

+ 51
- 0
src/Auth/Dbo/LuBuiltInPermissions.php 查看文件

@@ -12,4 +12,55 @@ namespace Luticate\Auth\Dbo;
12 12
 class LuBuiltInPermissions
13 13
 {
14 14
     const USER_LOGIN = "LU_USER_LOGIN";
15
+    const USER_GET = "LU_USER_GET";
16
+    const USER_LIST = "LU_USER_LIST";
17
+    const USER_ADD = "LU_USER_ADD";
18
+    const USER_DEL = "LU_USER_DEL";
19
+    const USER_EDIT = "LU_USER_EDIT";
20
+    const USER_EDIT_ME = "LU_USER_EDIT_ME";
21
+    const USER_SET_PASSWORD = "LU_USER_SET_PASSWORD";
22
+    const USER_SET_PASSWORD_ME = "LU_USER_SET_PASSWORD_ME";
23
+
24
+
25
+    const GROUP_GET = "LU_GROUP_GET";
26
+    const GROUP_LIST = "LU_GROUP_LIST";
27
+    const GROUP_ADD = "LU_GROUP_ADD";
28
+    const GROUP_DEL = "LU_GROUP_DEL";
29
+    const GROUP_EDIT = "LU_GROUP_EDIT";
30
+
31
+    const GROUP_USER_ADD = "LU_GROUP_USER_ADD";
32
+    const GROUP_USER_DEL = "LU_GROUP_USER_DEL";
33
+
34
+
35
+    const PERM_EFFECTIVE_GET = "LU_PERM_EFFECTIVE_GET";
36
+    const PERM_GET = "LU_PERM_GET";
37
+    const PERM_LIST = "LU_PERM_LIST";
38
+    const PERM_ADD = "LU_PERM_ADD";
39
+    const PERM_EDIT = "LU_PERM_EDIT";
40
+    const PERM_DEL = "LU_PERM_DEL";
41
+
42
+    const PERM_GROUP_GET = "LU_PERM_GROUP_GET";
43
+    const PERM_GROUP_LIST = "LU_PERM_GROUP_LIST";
44
+    const PERM_GROUP_ADD = "LU_PERM_GROUP_ADD";
45
+    const PERM_GROUP_EDIT = "LU_PERM_GROUP_EDIT";
46
+    const PERM_GROUP_DEL = "LU_PERM_GROUP_DEL";
47
+
48
+    const PERM_USER_GET = "LU_PERM_USER_GET";
49
+    const PERM_USER_LIST = "LU_PERM_USER_LIST";
50
+    const PERM_USER_ADD = "LU_PERM_USER_ADD";
51
+    const PERM_USER_EDIT = "LU_PERM_USER_EDIT";
52
+    const PERM_USER_DEL = "LU_PERM_USER_DEL";
53
+
54
+
55
+    const SETTING_EFFECTIVE_GET = "LU_SETTING_EFFECTIVE_GET";
56
+    const SETTING_GET = "LU_SETTING_GET";
57
+    const SETTING_LIST = "LU_SETTING_LIST";
58
+    const SETTING_ADD = "LU_SETTING_ADD";
59
+    const SETTING_EDIT = "LU_SETTING_EDIT";
60
+    const SETTING_DEL = "LU_SETTING_DEL";
61
+
62
+    const SETTING_USER_GET = "LU_SETTING_USER_GET";
63
+    const SETTING_USER_LIST = "LU_SETTING_USER_LIST";
64
+    const SETTING_USER_EDIT = "LU_SETTING_USER_EDIT";
65
+    const SETTING_EDIT_ME = "LU_SETTING_EDIT_ME";
15 66
 }

+ 99
- 0
src/Auth/Dbo/Users/LuUsersAddDbo.php 查看文件

@@ -0,0 +1,99 @@
1
+<?php
2
+/**
3
+ * Created by PhpStorm.
4
+ * User: robin
5
+ * Date: 9/17/16
6
+ * Time: 7:58 PM
7
+ */
8
+
9
+namespace Luticate\Auth\Dbo\Users;
10
+
11
+
12
+class LuUsersAddDbo extends LuUsersEditDbo
13
+{
14
+    /**
15
+     * @var $_username string
16
+     */
17
+    protected $_username;
18
+
19
+    /**
20
+     * @var $_profileId int
21
+     * @nullable
22
+     */
23
+    protected $_profileId;
24
+
25
+    /**
26
+     * @var $_externalAuth int
27
+     * @nullable
28
+     */
29
+    protected $_externalAuth;
30
+
31
+    /**
32
+     * @var $_password string
33
+     */
34
+    protected $_password;
35
+
36
+    /**
37
+     * @return string
38
+     */
39
+    public function getUsername()
40
+    {
41
+        return $this->_username;
42
+    }
43
+
44
+    /**
45
+     * @param string $username
46
+     */
47
+    public function setUsername($username)
48
+    {
49
+        $this->_username = $username;
50
+    }
51
+
52
+    /**
53
+     * @return int
54
+     */
55
+    public function getProfileId()
56
+    {
57
+        return $this->_profileId;
58
+    }
59
+
60
+    /**
61
+     * @param int $profileId
62
+     */
63
+    public function setProfileId($profileId)
64
+    {
65
+        $this->_profileId = $profileId;
66
+    }
67
+
68
+    /**
69
+     * @return int
70
+     */
71
+    public function getExternalAuth()
72
+    {
73
+        return $this->_externalAuth;
74
+    }
75
+
76
+    /**
77
+     * @param int $externalAuth
78
+     */
79
+    public function setExternalAuth($externalAuth)
80
+    {
81
+        $this->_externalAuth = $externalAuth;
82
+    }
83
+
84
+    /**
85
+     * @return string
86
+     */
87
+    public function getPassword()
88
+    {
89
+        return $this->_password;
90
+    }
91
+
92
+    /**
93
+     * @param string $password
94
+     */
95
+    public function setPassword(string $password)
96
+    {
97
+        $this->_password = $password;
98
+    }
99
+}

src/Auth/Dbo/LuUsersDbo.php → src/Auth/Dbo/Users/LuUsersDbo.php 查看文件

@@ -6,7 +6,7 @@
6 6
  * Time: 4:36 PM
7 7
  */
8 8
 
9
-namespace Luticate\Auth\Dbo;
9
+namespace Luticate\Auth\Dbo\Users;
10 10
 
11 11
 use Luticate\Utils\Dbo\LuDbo;
12 12
 
@@ -206,4 +206,12 @@ class LuUsersDbo extends LuDbo
206 206
     {
207 207
         $this->_lastname = $lastname;
208 208
     }
209
+
210
+    /**
211
+     * @return LuUsersLiteDbo
212
+     */
213
+    public function toLite()
214
+    {
215
+        return $this->castAs(LuUsersLiteDbo::class);
216
+    }
209 217
 }

+ 80
- 0
src/Auth/Dbo/Users/LuUsersEditDbo.php 查看文件

@@ -0,0 +1,80 @@
1
+<?php
2
+/**
3
+ * Created by PhpStorm.
4
+ * User: robin
5
+ * Date: 9/17/16
6
+ * Time: 8:10 PM
7
+ */
8
+
9
+namespace Luticate\Auth\Dbo\Users;
10
+
11
+
12
+use Luticate\Utils\Dbo\LuDbo;
13
+
14
+class LuUsersEditDbo extends LuDbo
15
+{
16
+    /**
17
+     * @var $_email string
18
+     */
19
+    protected $_email;
20
+
21
+    /**
22
+     * @var $_firstname string
23
+     * @nullable
24
+     */
25
+    protected $_firstname;
26
+
27
+    /**
28
+     * @var $_lastname string
29
+     * @nullable
30
+     */
31
+    protected $_lastname;
32
+
33
+    /**
34
+     * @return string
35
+     */
36
+    public function getEmail()
37
+    {
38
+        return $this->_email;
39
+    }
40
+
41
+    /**
42
+     * @param string $email
43
+     */
44
+    public function setEmail($email)
45
+    {
46
+        $this->_email = $email;
47
+    }
48
+
49
+    /**
50
+     * @return string
51
+     */
52
+    public function getFirstname()
53
+    {
54
+        return $this->_firstname;
55
+    }
56
+
57
+    /**
58
+     * @param string $firstname
59
+     */
60
+    public function setFirstname($firstname)
61
+    {
62
+        $this->_firstname = $firstname;
63
+    }
64
+
65
+    /**
66
+     * @return string
67
+     */
68
+    public function getLastname()
69
+    {
70
+        return $this->_lastname;
71
+    }
72
+
73
+    /**
74
+     * @param string $lastname
75
+     */
76
+    public function setLastname($lastname)
77
+    {
78
+        $this->_lastname = $lastname;
79
+    }
80
+}

src/Auth/Dbo/LuUsersLiteDbo.php → src/Auth/Dbo/Users/LuUsersLiteDbo.php 查看文件

@@ -6,7 +6,7 @@
6 6
  * Time: 1:52 PM
7 7
  */
8 8
 
9
-namespace Luticate\Auth\Dbo;
9
+namespace Luticate\Auth\Dbo\Users;
10 10
 
11 11
 use Luticate\Utils\Dbo\LuDbo;
12 12
 
@@ -162,6 +162,5 @@ class LuUsersLiteDbo extends LuDbo
162 162
     {
163 163
         $this->_lastname = $lastname;
164 164
     }
165
-    
166
-    
165
+
167 166
 }

src/Auth/Dbo/LuUsersLoginDbo.php → src/Auth/Dbo/Users/LuUsersLoginDbo.php 查看文件

@@ -6,7 +6,7 @@
6 6
  * Time: 4:46 PM
7 7
  */
8 8
 
9
-namespace Luticate\Auth\Dbo;
9
+namespace Luticate\Auth\Dbo\Users;
10 10
 
11 11
 
12 12
 use Luticate\Utils\Dbo\LuDbo;

src/Auth/Dbo/LuUsersLoginResultDbo.php → src/Auth/Dbo/Users/LuUsersLoginResultDbo.php 查看文件

@@ -6,7 +6,7 @@
6 6
  * Time: 4:53 PM
7 7
  */
8 8
 
9
-namespace Luticate\Auth\Dbo;
9
+namespace Luticate\Auth\Dbo\Users;
10 10
 
11 11
 class LuUsersLoginResultDbo extends LuUsersLiteDbo
12 12
 {

正在加载...
取消
保存