@@ -2,25 +2,25 @@ |
||
2 | 2 | |
3 | 3 | return [ |
4 | 4 | |
5 | - /** |
|
6 | - * List of error messages used in core module. |
|
7 | - */ |
|
8 | - 'unAuthorized' => 'Please login before any action', |
|
9 | - 'invalidRefreshToken' => 'Invalid refresh token', |
|
10 | - 'noPermissions' => 'No permissions', |
|
11 | - 'loginFailed' => 'Wrong mail or password', |
|
12 | - 'noSocialEmail' => 'Couldn\'t retrieve email', |
|
13 | - 'userAlreadyRegistered' => 'User already registered. Please login using email and password', |
|
14 | - 'connectionError' => 'Connection error', |
|
15 | - 'redisNotRunning' => 'Your redis notification server is\'t running', |
|
16 | - 'dbQueryError' => 'Please check the given inputes', |
|
17 | - 'cannotCreateSetting' => 'Can\'t create setting', |
|
18 | - 'cannotUpdateSettingKey' => 'Can\'t update setting key', |
|
19 | - 'userIsBlocked' => 'You have been blocked', |
|
20 | - 'invalidResetToken' => 'Reset password token is invalid', |
|
21 | - 'invalidResetPassword' => 'Reset password is invalid', |
|
22 | - 'invalidOldPassword' => 'Old password is invalid', |
|
23 | - 'notFound' => 'The requested :replace not found', |
|
24 | - 'generalError' => 'Something went wrong', |
|
5 | + /** |
|
6 | + * List of error messages used in core module. |
|
7 | + */ |
|
8 | + 'unAuthorized' => 'Please login before any action', |
|
9 | + 'invalidRefreshToken' => 'Invalid refresh token', |
|
10 | + 'noPermissions' => 'No permissions', |
|
11 | + 'loginFailed' => 'Wrong mail or password', |
|
12 | + 'noSocialEmail' => 'Couldn\'t retrieve email', |
|
13 | + 'userAlreadyRegistered' => 'User already registered. Please login using email and password', |
|
14 | + 'connectionError' => 'Connection error', |
|
15 | + 'redisNotRunning' => 'Your redis notification server is\'t running', |
|
16 | + 'dbQueryError' => 'Please check the given inputes', |
|
17 | + 'cannotCreateSetting' => 'Can\'t create setting', |
|
18 | + 'cannotUpdateSettingKey' => 'Can\'t update setting key', |
|
19 | + 'userIsBlocked' => 'You have been blocked', |
|
20 | + 'invalidResetToken' => 'Reset password token is invalid', |
|
21 | + 'invalidResetPassword' => 'Reset password is invalid', |
|
22 | + 'invalidOldPassword' => 'Old password is invalid', |
|
23 | + 'notFound' => 'The requested :replace not found', |
|
24 | + 'generalError' => 'Something went wrong', |
|
25 | 25 | |
26 | 26 | ]; |
27 | 27 | \ No newline at end of file |
@@ -2,25 +2,25 @@ |
||
2 | 2 | |
3 | 3 | return [ |
4 | 4 | |
5 | - /** |
|
6 | - * List of error messages used in core module. |
|
7 | - */ |
|
8 | - 'unAuthorized' => 'من فضلك قم بتسجيل الدخول', |
|
9 | - 'invalidRefreshToken' => 'رمز التحديث غير صالح', |
|
10 | - 'noPermissions' => 'لا توجد صلاحية', |
|
11 | - 'loginFailed' => 'خطأ في البريد لاكتروني او كلمة المرور', |
|
12 | - 'noSocialEmail' => 'لا يمكن الحصول علي تابريد الاكتروني', |
|
13 | - 'userAlreadyRegistered' => 'المستخد مسجل بالفعل.سجل الدخول بالبريد الاكتروني و كلمة السر', |
|
14 | - 'connectionError' => 'خطأ في الاتصال', |
|
15 | - 'redisNotRunning' => 'سيرفير الاشعارات لايعمل', |
|
16 | - 'dbQueryError' => 'خطا في البيانات', |
|
17 | - 'cannotCreateSetting' => 'لا يمكن اضافة اعدادات', |
|
18 | - 'cannotUpdateSettingKey' => 'لا يمكن تعديل اعدادات', |
|
19 | - 'userIsBlocked' => 'لقد تم حظرك', |
|
20 | - 'invalidResetToken' => 'رمز تعديل كلمة المرور خطا', |
|
21 | - 'invalidResetPassword' => 'خطا في نعديل كلمة المرور', |
|
22 | - 'invalidOldPassword' => 'كلمة السر القديمه خطا', |
|
23 | - 'notFound' => 'ال :replace المطلوب غير موجود', |
|
24 | - 'generalError' => 'حدث خطا ما', |
|
5 | + /** |
|
6 | + * List of error messages used in core module. |
|
7 | + */ |
|
8 | + 'unAuthorized' => 'من فضلك قم بتسجيل الدخول', |
|
9 | + 'invalidRefreshToken' => 'رمز التحديث غير صالح', |
|
10 | + 'noPermissions' => 'لا توجد صلاحية', |
|
11 | + 'loginFailed' => 'خطأ في البريد لاكتروني او كلمة المرور', |
|
12 | + 'noSocialEmail' => 'لا يمكن الحصول علي تابريد الاكتروني', |
|
13 | + 'userAlreadyRegistered' => 'المستخد مسجل بالفعل.سجل الدخول بالبريد الاكتروني و كلمة السر', |
|
14 | + 'connectionError' => 'خطأ في الاتصال', |
|
15 | + 'redisNotRunning' => 'سيرفير الاشعارات لايعمل', |
|
16 | + 'dbQueryError' => 'خطا في البيانات', |
|
17 | + 'cannotCreateSetting' => 'لا يمكن اضافة اعدادات', |
|
18 | + 'cannotUpdateSettingKey' => 'لا يمكن تعديل اعدادات', |
|
19 | + 'userIsBlocked' => 'لقد تم حظرك', |
|
20 | + 'invalidResetToken' => 'رمز تعديل كلمة المرور خطا', |
|
21 | + 'invalidResetPassword' => 'خطا في نعديل كلمة المرور', |
|
22 | + 'invalidOldPassword' => 'كلمة السر القديمه خطا', |
|
23 | + 'notFound' => 'ال :replace المطلوب غير موجود', |
|
24 | + 'generalError' => 'حدث خطا ما', |
|
25 | 25 | |
26 | 26 | ]; |
27 | 27 | \ No newline at end of file |
@@ -122,16 +122,13 @@ discard block |
||
122 | 122 | if ( ! $user = $this->first(['email' => $credentials['email']])) |
123 | 123 | { |
124 | 124 | \ErrorHandler::loginFailed(); |
125 | - } |
|
126 | - else if ($adminLogin && $user->groups->pluck('name')->search('Admin', true) === false) |
|
125 | + } else if ($adminLogin && $user->groups->pluck('name')->search('Admin', true) === false) |
|
127 | 126 | { |
128 | 127 | \ErrorHandler::loginFailed(); |
129 | - } |
|
130 | - else if ( ! $adminLogin && $user->groups->pluck('name')->search('Admin', true) !== false) |
|
128 | + } else if ( ! $adminLogin && $user->groups->pluck('name')->search('Admin', true) !== false) |
|
131 | 129 | { |
132 | 130 | \ErrorHandler::loginFailed(); |
133 | - } |
|
134 | - else if ($user->blocked) |
|
131 | + } else if ($user->blocked) |
|
135 | 132 | { |
136 | 133 | \ErrorHandler::userIsBlocked(); |
137 | 134 | } |
@@ -159,8 +156,7 @@ discard block |
||
159 | 156 | { |
160 | 157 | $data = ['email' => $user->email, 'password' => '']; |
161 | 158 | return $this->register($data); |
162 | - } |
|
163 | - else |
|
159 | + } else |
|
164 | 160 | { |
165 | 161 | if ( ! \Auth::attempt(['email' => $registeredUser->email, 'password' => ''])) |
166 | 162 | { |
@@ -198,12 +194,10 @@ discard block |
||
198 | 194 | if ( ! $this->hasGroup('Admin')) |
199 | 195 | { |
200 | 196 | \ErrorHandler::noPermissions(); |
201 | - } |
|
202 | - else if (\Auth::id() == $user_id) |
|
197 | + } else if (\Auth::id() == $user_id) |
|
203 | 198 | { |
204 | 199 | \ErrorHandler::noPermissions(); |
205 | - } |
|
206 | - else if ($user->groups->pluck('name')->search('Admin', true) !== false) |
|
200 | + } else if ($user->groups->pluck('name')->search('Admin', true) !== false) |
|
207 | 201 | { |
208 | 202 | \ErrorHandler::noPermissions(); |
209 | 203 | } |
@@ -259,7 +259,7 @@ |
||
259 | 259 | * Reset the given user's password. |
260 | 260 | * |
261 | 261 | * @param array $credentials |
262 | - * @return array |
|
262 | + * @return string|null |
|
263 | 263 | */ |
264 | 264 | public function resetPassword($credentials) |
265 | 265 | { |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | $user = \Core::users()->find(\Auth::id(), $relations); |
50 | 50 | foreach ($user->groups()->get() as $group) |
51 | 51 | { |
52 | - $group->permissions->each(function ($permission) use (&$permissions){ |
|
52 | + $group->permissions->each(function($permission) use (&$permissions){ |
|
53 | 53 | $permissions[$permission->model][$permission->id] = $permission->name; |
54 | 54 | }); |
55 | 55 | } |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | $user = $user ?: $this->find(\Auth::id(), ['groups.permissions']); |
73 | 73 | $permissions = []; |
74 | 74 | |
75 | - $user->groups->pluck('permissions')->each(function ($permission) use (&$permissions, $model){ |
|
75 | + $user->groups->pluck('permissions')->each(function($permission) use (&$permissions, $model){ |
|
76 | 76 | $permissions = array_merge($permissions, $permission->where('model', $model)->pluck('name')->toArray()); |
77 | 77 | }); |
78 | 78 | |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | */ |
103 | 103 | public function assignGroups($user_id, $group_ids) |
104 | 104 | { |
105 | - \DB::transaction(function () use ($user_id, $group_ids) { |
|
105 | + \DB::transaction(function() use ($user_id, $group_ids) { |
|
106 | 106 | $user = $this->find($user_id); |
107 | 107 | $user->groups()->detach(); |
108 | 108 | $user->groups()->attach($group_ids); |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | $url = $this->config['resetLink']; |
252 | 252 | $token = \Password::getRepository()->create($user); |
253 | 253 | |
254 | - \Mail::send('acl::resetpassword', ['user' => $user, 'url' => $url, 'token' => $token], function ($m) use ($user) { |
|
254 | + \Mail::send('acl::resetpassword', ['user' => $user, 'url' => $url, 'token' => $token], function($m) use ($user) { |
|
255 | 255 | $m->to($user->email, $user->name)->subject('Your Password Reset Link'); |
256 | 256 | }); |
257 | 257 | } |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | */ |
265 | 265 | public function resetPassword($credentials) |
266 | 266 | { |
267 | - $response = \Password::reset($credentials, function ($user, $password) { |
|
267 | + $response = \Password::reset($credentials, function($user, $password) { |
|
268 | 268 | $user->password = $password; |
269 | 269 | $user->save(); |
270 | 270 | }); |
@@ -5,355 +5,355 @@ |
||
5 | 5 | |
6 | 6 | class UserRepository extends AbstractRepository |
7 | 7 | { |
8 | - /** |
|
9 | - * Return the model full namespace. |
|
10 | - * |
|
11 | - * @return string |
|
12 | - */ |
|
13 | - protected function getModel() |
|
14 | - { |
|
15 | - return 'App\Modules\V1\Acl\AclUser'; |
|
16 | - } |
|
17 | - |
|
18 | - |
|
19 | - /** |
|
20 | - * Return the logged in user account. |
|
21 | - * |
|
22 | - * @param array $relations |
|
23 | - * @return boolean |
|
24 | - */ |
|
25 | - public function account($relations = []) |
|
26 | - { |
|
27 | - $permissions = []; |
|
28 | - $user = \Core::users()->find(\Auth::id(), $relations); |
|
29 | - foreach ($user->groups()->get() as $group) |
|
30 | - { |
|
31 | - $group->permissions->each(function ($permission) use (&$permissions){ |
|
32 | - $permissions[$permission->model][$permission->id] = $permission->name; |
|
33 | - }); |
|
34 | - } |
|
35 | - $user->permissions = $permissions; |
|
36 | - |
|
37 | - return $user; |
|
38 | - } |
|
39 | - |
|
40 | - /** |
|
41 | - * Check if the logged in user or the given user |
|
42 | - * has the given permissions on the given model. |
|
43 | - * |
|
44 | - * @param string $nameOfPermission |
|
45 | - * @param string $model |
|
46 | - * @param boolean $user |
|
47 | - * @return boolean |
|
48 | - */ |
|
49 | - public function can($nameOfPermission, $model, $user = false) |
|
50 | - { |
|
51 | - $user = $user ?: $this->find(\Auth::id(), ['groups.permissions']); |
|
52 | - $permissions = []; |
|
53 | - |
|
54 | - $user->groups->pluck('permissions')->each(function ($permission) use (&$permissions, $model){ |
|
55 | - $permissions = array_merge($permissions, $permission->where('model', $model)->pluck('name')->toArray()); |
|
56 | - }); |
|
8 | + /** |
|
9 | + * Return the model full namespace. |
|
10 | + * |
|
11 | + * @return string |
|
12 | + */ |
|
13 | + protected function getModel() |
|
14 | + { |
|
15 | + return 'App\Modules\V1\Acl\AclUser'; |
|
16 | + } |
|
17 | + |
|
18 | + |
|
19 | + /** |
|
20 | + * Return the logged in user account. |
|
21 | + * |
|
22 | + * @param array $relations |
|
23 | + * @return boolean |
|
24 | + */ |
|
25 | + public function account($relations = []) |
|
26 | + { |
|
27 | + $permissions = []; |
|
28 | + $user = \Core::users()->find(\Auth::id(), $relations); |
|
29 | + foreach ($user->groups()->get() as $group) |
|
30 | + { |
|
31 | + $group->permissions->each(function ($permission) use (&$permissions){ |
|
32 | + $permissions[$permission->model][$permission->id] = $permission->name; |
|
33 | + }); |
|
34 | + } |
|
35 | + $user->permissions = $permissions; |
|
36 | + |
|
37 | + return $user; |
|
38 | + } |
|
39 | + |
|
40 | + /** |
|
41 | + * Check if the logged in user or the given user |
|
42 | + * has the given permissions on the given model. |
|
43 | + * |
|
44 | + * @param string $nameOfPermission |
|
45 | + * @param string $model |
|
46 | + * @param boolean $user |
|
47 | + * @return boolean |
|
48 | + */ |
|
49 | + public function can($nameOfPermission, $model, $user = false) |
|
50 | + { |
|
51 | + $user = $user ?: $this->find(\Auth::id(), ['groups.permissions']); |
|
52 | + $permissions = []; |
|
53 | + |
|
54 | + $user->groups->pluck('permissions')->each(function ($permission) use (&$permissions, $model){ |
|
55 | + $permissions = array_merge($permissions, $permission->where('model', $model)->pluck('name')->toArray()); |
|
56 | + }); |
|
57 | 57 | |
58 | - return in_array($nameOfPermission, $permissions); |
|
59 | - } |
|
60 | - |
|
61 | - /** |
|
62 | - * Check if the logged in user has the given group. |
|
63 | - * |
|
64 | - * @param string $groupName |
|
65 | - * @param integer $userId |
|
66 | - * @return boolean |
|
67 | - */ |
|
68 | - public function hasGroup($groupName, $userId = false) |
|
69 | - { |
|
70 | - $userId = $userId ?: \Auth::id(); |
|
71 | - $groups = $this->find($userId)->groups; |
|
72 | - return $groups->pluck('name')->search($groupName, true) === false ? false : true; |
|
73 | - } |
|
74 | - |
|
75 | - /** |
|
76 | - * Assign the given group ids to the given user. |
|
77 | - * |
|
78 | - * @param integer $user_id |
|
79 | - * @param array $group_ids |
|
80 | - * @return object |
|
81 | - */ |
|
82 | - public function assignGroups($user_id, $group_ids) |
|
83 | - { |
|
84 | - \DB::transaction(function () use ($user_id, $group_ids) { |
|
85 | - $user = $this->find($user_id); |
|
86 | - $user->groups()->detach(); |
|
87 | - $user->groups()->attach($group_ids); |
|
88 | - }); |
|
89 | - |
|
90 | - return $this->find($user_id); |
|
91 | - } |
|
92 | - |
|
93 | - /** |
|
94 | - * Handle a login request to the application. |
|
95 | - * |
|
96 | - * @param array $credentials |
|
97 | - * @param boolean $adminLogin |
|
98 | - * @return object |
|
99 | - */ |
|
100 | - public function login($credentials, $adminLogin = false) |
|
101 | - { |
|
102 | - if ( ! $user = $this->first(['email' => $credentials['email']])) |
|
103 | - { |
|
104 | - \ErrorHandler::loginFailed(); |
|
105 | - } |
|
106 | - else if ($adminLogin && $user->groups->pluck('name')->search('Admin', true) === false) |
|
107 | - { |
|
108 | - \ErrorHandler::loginFailed(); |
|
109 | - } |
|
110 | - else if ( ! $adminLogin && $user->groups->pluck('name')->search('Admin', true) !== false) |
|
111 | - { |
|
112 | - \ErrorHandler::loginFailed(); |
|
113 | - } |
|
114 | - else if ($user->blocked) |
|
115 | - { |
|
116 | - \ErrorHandler::userIsBlocked(); |
|
117 | - } |
|
118 | - |
|
119 | - return $user; |
|
120 | - } |
|
121 | - |
|
122 | - /** |
|
123 | - * Handle a social login request of the none admin to the application. |
|
124 | - * |
|
125 | - * @param array $credentials |
|
126 | - * @return array |
|
127 | - */ |
|
128 | - public function loginSocial($credentials) |
|
129 | - { |
|
130 | - $access_token = $credentials['auth_code'] ? \Socialite::driver($credentials['type'])->getAccessToken($credentials['auth_code']) : $credentials['access_token']; |
|
131 | - $user = \Socialite::driver($credentials['type'])->userFromToken($access_token); |
|
132 | - |
|
133 | - if ( ! $user->email) |
|
134 | - { |
|
135 | - \ErrorHandler::noSocialEmail(); |
|
136 | - } |
|
137 | - |
|
138 | - if ( ! $registeredUser = $this->model->where('email', $user->email)->first()) |
|
139 | - { |
|
140 | - $data = ['email' => $user->email, 'password' => '']; |
|
141 | - return $this->register($data); |
|
142 | - } |
|
143 | - else |
|
144 | - { |
|
145 | - if ( ! \Auth::attempt(['email' => $registeredUser->email, 'password' => ''])) |
|
146 | - { |
|
147 | - \ErrorHandler::userAlreadyRegistered(); |
|
148 | - } |
|
149 | - |
|
150 | - $loginProxy = \App::make('App\Modules\V1\Acl\Proxy\LoginProxy'); |
|
151 | - return $loginProxy->login(['email' => $registeredUser->email, 'password' => ''], 0); |
|
152 | - } |
|
153 | - } |
|
58 | + return in_array($nameOfPermission, $permissions); |
|
59 | + } |
|
60 | + |
|
61 | + /** |
|
62 | + * Check if the logged in user has the given group. |
|
63 | + * |
|
64 | + * @param string $groupName |
|
65 | + * @param integer $userId |
|
66 | + * @return boolean |
|
67 | + */ |
|
68 | + public function hasGroup($groupName, $userId = false) |
|
69 | + { |
|
70 | + $userId = $userId ?: \Auth::id(); |
|
71 | + $groups = $this->find($userId)->groups; |
|
72 | + return $groups->pluck('name')->search($groupName, true) === false ? false : true; |
|
73 | + } |
|
74 | + |
|
75 | + /** |
|
76 | + * Assign the given group ids to the given user. |
|
77 | + * |
|
78 | + * @param integer $user_id |
|
79 | + * @param array $group_ids |
|
80 | + * @return object |
|
81 | + */ |
|
82 | + public function assignGroups($user_id, $group_ids) |
|
83 | + { |
|
84 | + \DB::transaction(function () use ($user_id, $group_ids) { |
|
85 | + $user = $this->find($user_id); |
|
86 | + $user->groups()->detach(); |
|
87 | + $user->groups()->attach($group_ids); |
|
88 | + }); |
|
89 | + |
|
90 | + return $this->find($user_id); |
|
91 | + } |
|
92 | + |
|
93 | + /** |
|
94 | + * Handle a login request to the application. |
|
95 | + * |
|
96 | + * @param array $credentials |
|
97 | + * @param boolean $adminLogin |
|
98 | + * @return object |
|
99 | + */ |
|
100 | + public function login($credentials, $adminLogin = false) |
|
101 | + { |
|
102 | + if ( ! $user = $this->first(['email' => $credentials['email']])) |
|
103 | + { |
|
104 | + \ErrorHandler::loginFailed(); |
|
105 | + } |
|
106 | + else if ($adminLogin && $user->groups->pluck('name')->search('Admin', true) === false) |
|
107 | + { |
|
108 | + \ErrorHandler::loginFailed(); |
|
109 | + } |
|
110 | + else if ( ! $adminLogin && $user->groups->pluck('name')->search('Admin', true) !== false) |
|
111 | + { |
|
112 | + \ErrorHandler::loginFailed(); |
|
113 | + } |
|
114 | + else if ($user->blocked) |
|
115 | + { |
|
116 | + \ErrorHandler::userIsBlocked(); |
|
117 | + } |
|
118 | + |
|
119 | + return $user; |
|
120 | + } |
|
121 | + |
|
122 | + /** |
|
123 | + * Handle a social login request of the none admin to the application. |
|
124 | + * |
|
125 | + * @param array $credentials |
|
126 | + * @return array |
|
127 | + */ |
|
128 | + public function loginSocial($credentials) |
|
129 | + { |
|
130 | + $access_token = $credentials['auth_code'] ? \Socialite::driver($credentials['type'])->getAccessToken($credentials['auth_code']) : $credentials['access_token']; |
|
131 | + $user = \Socialite::driver($credentials['type'])->userFromToken($access_token); |
|
132 | + |
|
133 | + if ( ! $user->email) |
|
134 | + { |
|
135 | + \ErrorHandler::noSocialEmail(); |
|
136 | + } |
|
137 | + |
|
138 | + if ( ! $registeredUser = $this->model->where('email', $user->email)->first()) |
|
139 | + { |
|
140 | + $data = ['email' => $user->email, 'password' => '']; |
|
141 | + return $this->register($data); |
|
142 | + } |
|
143 | + else |
|
144 | + { |
|
145 | + if ( ! \Auth::attempt(['email' => $registeredUser->email, 'password' => ''])) |
|
146 | + { |
|
147 | + \ErrorHandler::userAlreadyRegistered(); |
|
148 | + } |
|
149 | + |
|
150 | + $loginProxy = \App::make('App\Modules\V1\Acl\Proxy\LoginProxy'); |
|
151 | + return $loginProxy->login(['email' => $registeredUser->email, 'password' => ''], 0); |
|
152 | + } |
|
153 | + } |
|
154 | 154 | |
155 | - /** |
|
156 | - * Handle a registration request. |
|
157 | - * |
|
158 | - * @param array $credentials |
|
159 | - * @return array |
|
160 | - */ |
|
161 | - public function register($credentials) |
|
162 | - { |
|
163 | - $loginProxy = \App::make('App\Modules\V1\Acl\Proxy\LoginProxy'); |
|
164 | - $this->model->create($credentials); |
|
165 | - |
|
166 | - return $loginProxy->login($credentials, 0); |
|
167 | - } |
|
168 | - |
|
169 | - /** |
|
170 | - * Block the user. |
|
171 | - * |
|
172 | - * @param integer $user_id |
|
173 | - * @return object |
|
174 | - */ |
|
175 | - public function block($user_id) |
|
176 | - { |
|
177 | - if ( ! $user = $this->find($user_id)) |
|
178 | - { |
|
179 | - \ErrorHandler::notFound('user'); |
|
180 | - } |
|
181 | - if ( ! $this->hasGroup('Admin')) |
|
182 | - { |
|
183 | - \ErrorHandler::noPermissions(); |
|
184 | - } |
|
185 | - else if (\Auth::id() == $user_id) |
|
186 | - { |
|
187 | - \ErrorHandler::noPermissions(); |
|
188 | - } |
|
189 | - else if ($user->groups->pluck('name')->search('Admin', true) !== false) |
|
190 | - { |
|
191 | - \ErrorHandler::noPermissions(); |
|
192 | - } |
|
193 | - |
|
194 | - $user->blocked = 1; |
|
195 | - $user->save(); |
|
155 | + /** |
|
156 | + * Handle a registration request. |
|
157 | + * |
|
158 | + * @param array $credentials |
|
159 | + * @return array |
|
160 | + */ |
|
161 | + public function register($credentials) |
|
162 | + { |
|
163 | + $loginProxy = \App::make('App\Modules\V1\Acl\Proxy\LoginProxy'); |
|
164 | + $this->model->create($credentials); |
|
165 | + |
|
166 | + return $loginProxy->login($credentials, 0); |
|
167 | + } |
|
168 | + |
|
169 | + /** |
|
170 | + * Block the user. |
|
171 | + * |
|
172 | + * @param integer $user_id |
|
173 | + * @return object |
|
174 | + */ |
|
175 | + public function block($user_id) |
|
176 | + { |
|
177 | + if ( ! $user = $this->find($user_id)) |
|
178 | + { |
|
179 | + \ErrorHandler::notFound('user'); |
|
180 | + } |
|
181 | + if ( ! $this->hasGroup('Admin')) |
|
182 | + { |
|
183 | + \ErrorHandler::noPermissions(); |
|
184 | + } |
|
185 | + else if (\Auth::id() == $user_id) |
|
186 | + { |
|
187 | + \ErrorHandler::noPermissions(); |
|
188 | + } |
|
189 | + else if ($user->groups->pluck('name')->search('Admin', true) !== false) |
|
190 | + { |
|
191 | + \ErrorHandler::noPermissions(); |
|
192 | + } |
|
193 | + |
|
194 | + $user->blocked = 1; |
|
195 | + $user->save(); |
|
196 | 196 | |
197 | - return $user; |
|
198 | - } |
|
199 | - |
|
200 | - /** |
|
201 | - * Unblock the user. |
|
202 | - * |
|
203 | - * @param integer $user_id |
|
204 | - * @return object |
|
205 | - */ |
|
206 | - public function unblock($user_id) |
|
207 | - { |
|
208 | - if ( ! $this->hasGroup('Admin')) |
|
209 | - { |
|
210 | - \ErrorHandler::noPermissions(); |
|
211 | - } |
|
212 | - |
|
213 | - $user = $this->find($user_id); |
|
214 | - $user->blocked = 0; |
|
215 | - $user->save(); |
|
216 | - |
|
217 | - return $user; |
|
218 | - } |
|
219 | - |
|
220 | - /** |
|
221 | - * Send a reset link to the given user. |
|
222 | - * |
|
223 | - * @param string $email |
|
224 | - * @return void |
|
225 | - */ |
|
226 | - public function sendReset($email) |
|
227 | - { |
|
228 | - if ( ! $user = $this->model->where('email', $email)->first()) |
|
229 | - { |
|
230 | - \ErrorHandler::notFound('email'); |
|
231 | - } |
|
232 | - |
|
233 | - $url = $this->config['resetLink']; |
|
234 | - $token = \Password::getRepository()->create($user); |
|
197 | + return $user; |
|
198 | + } |
|
199 | + |
|
200 | + /** |
|
201 | + * Unblock the user. |
|
202 | + * |
|
203 | + * @param integer $user_id |
|
204 | + * @return object |
|
205 | + */ |
|
206 | + public function unblock($user_id) |
|
207 | + { |
|
208 | + if ( ! $this->hasGroup('Admin')) |
|
209 | + { |
|
210 | + \ErrorHandler::noPermissions(); |
|
211 | + } |
|
212 | + |
|
213 | + $user = $this->find($user_id); |
|
214 | + $user->blocked = 0; |
|
215 | + $user->save(); |
|
216 | + |
|
217 | + return $user; |
|
218 | + } |
|
219 | + |
|
220 | + /** |
|
221 | + * Send a reset link to the given user. |
|
222 | + * |
|
223 | + * @param string $email |
|
224 | + * @return void |
|
225 | + */ |
|
226 | + public function sendReset($email) |
|
227 | + { |
|
228 | + if ( ! $user = $this->model->where('email', $email)->first()) |
|
229 | + { |
|
230 | + \ErrorHandler::notFound('email'); |
|
231 | + } |
|
232 | + |
|
233 | + $url = $this->config['resetLink']; |
|
234 | + $token = \Password::getRepository()->create($user); |
|
235 | 235 | |
236 | - \Mail::send('acl::resetpassword', ['user' => $user, 'url' => $url, 'token' => $token], function ($m) use ($user) { |
|
237 | - $m->to($user->email, $user->name)->subject('Your Password Reset Link'); |
|
238 | - }); |
|
239 | - } |
|
240 | - |
|
241 | - /** |
|
242 | - * Reset the given user's password. |
|
243 | - * |
|
244 | - * @param array $credentials |
|
245 | - * @return array |
|
246 | - */ |
|
247 | - public function resetPassword($credentials) |
|
248 | - { |
|
249 | - $response = \Password::reset($credentials, function ($user, $password) { |
|
250 | - $user->password = $password; |
|
251 | - $user->save(); |
|
252 | - }); |
|
253 | - |
|
254 | - switch ($response) { |
|
255 | - case \Password::PASSWORD_RESET: |
|
256 | - return 'success'; |
|
236 | + \Mail::send('acl::resetpassword', ['user' => $user, 'url' => $url, 'token' => $token], function ($m) use ($user) { |
|
237 | + $m->to($user->email, $user->name)->subject('Your Password Reset Link'); |
|
238 | + }); |
|
239 | + } |
|
240 | + |
|
241 | + /** |
|
242 | + * Reset the given user's password. |
|
243 | + * |
|
244 | + * @param array $credentials |
|
245 | + * @return array |
|
246 | + */ |
|
247 | + public function resetPassword($credentials) |
|
248 | + { |
|
249 | + $response = \Password::reset($credentials, function ($user, $password) { |
|
250 | + $user->password = $password; |
|
251 | + $user->save(); |
|
252 | + }); |
|
253 | + |
|
254 | + switch ($response) { |
|
255 | + case \Password::PASSWORD_RESET: |
|
256 | + return 'success'; |
|
257 | 257 | |
258 | - case \Password::INVALID_TOKEN: |
|
259 | - \ErrorHandler::invalidResetToken('token'); |
|
260 | - |
|
261 | - case \Password::INVALID_PASSWORD: |
|
262 | - \ErrorHandler::invalidResetPassword('email'); |
|
263 | - |
|
264 | - case \Password::INVALID_USER: |
|
265 | - \ErrorHandler::notFound('user'); |
|
266 | - |
|
267 | - default: |
|
268 | - \ErrorHandler::generalError(); |
|
269 | - } |
|
270 | - } |
|
271 | - |
|
272 | - /** |
|
273 | - * Change the logged in user password. |
|
274 | - * |
|
275 | - * @param array $credentials |
|
276 | - * @return void |
|
277 | - */ |
|
278 | - public function changePassword($credentials) |
|
279 | - { |
|
280 | - $user = \Auth::user(); |
|
281 | - if ( ! \Hash::check($credentials['old_password'], $user->password)) |
|
282 | - { |
|
283 | - \ErrorHandler::invalidOldPassword(); |
|
284 | - } |
|
285 | - |
|
286 | - $user->password = $credentials['password']; |
|
287 | - $user->save(); |
|
288 | - } |
|
289 | - |
|
290 | - /** |
|
291 | - * Paginate all users in the given group based on the given conditions. |
|
292 | - * |
|
293 | - * @param string $groupName |
|
294 | - * @param array $relations |
|
295 | - * @param integer $perPage |
|
296 | - * @param string $sortBy |
|
297 | - * @param boolean $desc |
|
298 | - * @return \Illuminate\Http\Response |
|
299 | - */ |
|
300 | - public function group($conditions, $groupName, $relations, $perPage, $sortBy, $desc) |
|
301 | - { |
|
302 | - unset($conditions['page']); |
|
303 | - $conditions = $this->constructConditions($conditions, $this->model); |
|
304 | - $sort = $desc ? 'desc' : 'asc'; |
|
305 | - $model = call_user_func_array("{$this->getModel()}::with", array($relations)); |
|
306 | - |
|
307 | - $model->whereHas('groups', function($q) use ($groupName){ |
|
308 | - $q->where('name', $groupName); |
|
309 | - }); |
|
258 | + case \Password::INVALID_TOKEN: |
|
259 | + \ErrorHandler::invalidResetToken('token'); |
|
260 | + |
|
261 | + case \Password::INVALID_PASSWORD: |
|
262 | + \ErrorHandler::invalidResetPassword('email'); |
|
263 | + |
|
264 | + case \Password::INVALID_USER: |
|
265 | + \ErrorHandler::notFound('user'); |
|
266 | + |
|
267 | + default: |
|
268 | + \ErrorHandler::generalError(); |
|
269 | + } |
|
270 | + } |
|
271 | + |
|
272 | + /** |
|
273 | + * Change the logged in user password. |
|
274 | + * |
|
275 | + * @param array $credentials |
|
276 | + * @return void |
|
277 | + */ |
|
278 | + public function changePassword($credentials) |
|
279 | + { |
|
280 | + $user = \Auth::user(); |
|
281 | + if ( ! \Hash::check($credentials['old_password'], $user->password)) |
|
282 | + { |
|
283 | + \ErrorHandler::invalidOldPassword(); |
|
284 | + } |
|
285 | + |
|
286 | + $user->password = $credentials['password']; |
|
287 | + $user->save(); |
|
288 | + } |
|
289 | + |
|
290 | + /** |
|
291 | + * Paginate all users in the given group based on the given conditions. |
|
292 | + * |
|
293 | + * @param string $groupName |
|
294 | + * @param array $relations |
|
295 | + * @param integer $perPage |
|
296 | + * @param string $sortBy |
|
297 | + * @param boolean $desc |
|
298 | + * @return \Illuminate\Http\Response |
|
299 | + */ |
|
300 | + public function group($conditions, $groupName, $relations, $perPage, $sortBy, $desc) |
|
301 | + { |
|
302 | + unset($conditions['page']); |
|
303 | + $conditions = $this->constructConditions($conditions, $this->model); |
|
304 | + $sort = $desc ? 'desc' : 'asc'; |
|
305 | + $model = call_user_func_array("{$this->getModel()}::with", array($relations)); |
|
306 | + |
|
307 | + $model->whereHas('groups', function($q) use ($groupName){ |
|
308 | + $q->where('name', $groupName); |
|
309 | + }); |
|
310 | 310 | |
311 | 311 | |
312 | - if (count($conditions['conditionValues'])) |
|
313 | - { |
|
314 | - $model->whereRaw($conditions['conditionString'], $conditions['conditionValues']); |
|
315 | - } |
|
316 | - |
|
317 | - if ($perPage) |
|
318 | - { |
|
319 | - return $model->orderBy($sortBy, $sort)->paginate($perPage); |
|
320 | - } |
|
321 | - |
|
322 | - return $model->orderBy($sortBy, $sort)->get(); |
|
323 | - } |
|
324 | - |
|
325 | - /** |
|
326 | - * Save the given data to the logged in user. |
|
327 | - * |
|
328 | - * @param array $credentials |
|
329 | - * @return object |
|
330 | - */ |
|
331 | - public function saveProfile($credentials) |
|
332 | - { |
|
333 | - $user = \Auth::user(); |
|
334 | - $user->save($credentials); |
|
335 | - |
|
336 | - return $user; |
|
337 | - } |
|
338 | - |
|
339 | - /** |
|
340 | - * Ensure access token hasn't expired or revoked. |
|
341 | - * |
|
342 | - * @param string $accessToken |
|
343 | - * @return boolean |
|
344 | - */ |
|
345 | - public function accessTokenExpiredOrRevoked($accessToken) |
|
346 | - { |
|
347 | - |
|
348 | - $accessTokenRepository = \App::make('League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface'); |
|
349 | - $data = new ValidationData(); |
|
350 | - $data->setCurrentTime(time()); |
|
351 | - |
|
352 | - if ($accessToken->validate($data) === false || $accessTokenRepository->isAccessTokenRevoked($accessToken->getClaim('jti'))) |
|
353 | - { |
|
354 | - return true; |
|
355 | - } |
|
356 | - |
|
357 | - return false; |
|
358 | - } |
|
312 | + if (count($conditions['conditionValues'])) |
|
313 | + { |
|
314 | + $model->whereRaw($conditions['conditionString'], $conditions['conditionValues']); |
|
315 | + } |
|
316 | + |
|
317 | + if ($perPage) |
|
318 | + { |
|
319 | + return $model->orderBy($sortBy, $sort)->paginate($perPage); |
|
320 | + } |
|
321 | + |
|
322 | + return $model->orderBy($sortBy, $sort)->get(); |
|
323 | + } |
|
324 | + |
|
325 | + /** |
|
326 | + * Save the given data to the logged in user. |
|
327 | + * |
|
328 | + * @param array $credentials |
|
329 | + * @return object |
|
330 | + */ |
|
331 | + public function saveProfile($credentials) |
|
332 | + { |
|
333 | + $user = \Auth::user(); |
|
334 | + $user->save($credentials); |
|
335 | + |
|
336 | + return $user; |
|
337 | + } |
|
338 | + |
|
339 | + /** |
|
340 | + * Ensure access token hasn't expired or revoked. |
|
341 | + * |
|
342 | + * @param string $accessToken |
|
343 | + * @return boolean |
|
344 | + */ |
|
345 | + public function accessTokenExpiredOrRevoked($accessToken) |
|
346 | + { |
|
347 | + |
|
348 | + $accessTokenRepository = \App::make('League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface'); |
|
349 | + $data = new ValidationData(); |
|
350 | + $data->setCurrentTime(time()); |
|
351 | + |
|
352 | + if ($accessToken->validate($data) === false || $accessTokenRepository->isAccessTokenRevoked($accessToken->getClaim('jti'))) |
|
353 | + { |
|
354 | + return true; |
|
355 | + } |
|
356 | + |
|
357 | + return false; |
|
358 | + } |
|
359 | 359 | } |
@@ -6,23 +6,23 @@ |
||
6 | 6 | |
7 | 7 | class OauthClient extends Client |
8 | 8 | { |
9 | - protected $dates = ['created_at', 'updated_at']; |
|
10 | - protected $fillable = ['name', 'redirect', 'user_id', 'personal_access_client', 'password_client', 'revoked']; |
|
11 | - public $searchable = ['name']; |
|
9 | + protected $dates = ['created_at', 'updated_at']; |
|
10 | + protected $fillable = ['name', 'redirect', 'user_id', 'personal_access_client', 'password_client', 'revoked']; |
|
11 | + public $searchable = ['name']; |
|
12 | 12 | |
13 | - public function getCreatedAtAttribute($value) |
|
14 | - { |
|
15 | - return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString(); |
|
16 | - } |
|
13 | + public function getCreatedAtAttribute($value) |
|
14 | + { |
|
15 | + return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString(); |
|
16 | + } |
|
17 | 17 | |
18 | - public function getUpdatedAtAttribute($value) |
|
19 | - { |
|
20 | - return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString(); |
|
21 | - } |
|
18 | + public function getUpdatedAtAttribute($value) |
|
19 | + { |
|
20 | + return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString(); |
|
21 | + } |
|
22 | 22 | |
23 | - public static function boot() |
|
24 | - { |
|
25 | - parent::boot(); |
|
26 | - parent::observe(\App::make('App\Modules\V1\Acl\ModelObservers\OauthClientObserver')); |
|
27 | - } |
|
23 | + public static function boot() |
|
24 | + { |
|
25 | + parent::boot(); |
|
26 | + parent::observe(\App::make('App\Modules\V1\Acl\ModelObservers\OauthClientObserver')); |
|
27 | + } |
|
28 | 28 | } |
@@ -5,66 +5,66 @@ |
||
5 | 5 | */ |
6 | 6 | class AclUserObserver { |
7 | 7 | |
8 | - public function saving($model) |
|
9 | - { |
|
10 | - // |
|
11 | - } |
|
8 | + public function saving($model) |
|
9 | + { |
|
10 | + // |
|
11 | + } |
|
12 | 12 | |
13 | - public function saved($model) |
|
14 | - { |
|
15 | - // |
|
16 | - } |
|
13 | + public function saved($model) |
|
14 | + { |
|
15 | + // |
|
16 | + } |
|
17 | 17 | |
18 | - public function creating($model) |
|
19 | - { |
|
20 | - // |
|
21 | - } |
|
18 | + public function creating($model) |
|
19 | + { |
|
20 | + // |
|
21 | + } |
|
22 | 22 | |
23 | - public function created($model) |
|
24 | - { |
|
25 | - // |
|
26 | - } |
|
23 | + public function created($model) |
|
24 | + { |
|
25 | + // |
|
26 | + } |
|
27 | 27 | |
28 | - public function updating($model) |
|
29 | - { |
|
30 | - if ($model->password) |
|
31 | - { |
|
32 | - $model->last_change_password = \Carbon\Carbon::now()->toDateTimeString(); |
|
33 | - } |
|
34 | - } |
|
28 | + public function updating($model) |
|
29 | + { |
|
30 | + if ($model->password) |
|
31 | + { |
|
32 | + $model->last_change_password = \Carbon\Carbon::now()->toDateTimeString(); |
|
33 | + } |
|
34 | + } |
|
35 | 35 | |
36 | - public function updated($model) |
|
37 | - { |
|
38 | - // |
|
39 | - } |
|
36 | + public function updated($model) |
|
37 | + { |
|
38 | + // |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * Soft delete user logs. |
|
43 | - * |
|
44 | - * @param object $model the delted model. |
|
45 | - * @return void |
|
46 | - */ |
|
47 | - public function deleting($model) |
|
48 | - { |
|
49 | - if ($model->getOriginal('id') == \Auth::id()) |
|
50 | - { |
|
51 | - \ErrorHandler::noPermissions(); |
|
52 | - } |
|
53 | - $model->logs()->delete(); |
|
54 | - } |
|
41 | + /** |
|
42 | + * Soft delete user logs. |
|
43 | + * |
|
44 | + * @param object $model the delted model. |
|
45 | + * @return void |
|
46 | + */ |
|
47 | + public function deleting($model) |
|
48 | + { |
|
49 | + if ($model->getOriginal('id') == \Auth::id()) |
|
50 | + { |
|
51 | + \ErrorHandler::noPermissions(); |
|
52 | + } |
|
53 | + $model->logs()->delete(); |
|
54 | + } |
|
55 | 55 | |
56 | - public function deleted($model) |
|
57 | - { |
|
58 | - // |
|
59 | - } |
|
56 | + public function deleted($model) |
|
57 | + { |
|
58 | + // |
|
59 | + } |
|
60 | 60 | |
61 | - public function restoring($model) |
|
62 | - { |
|
63 | - $model->logs()->restore(); |
|
64 | - } |
|
61 | + public function restoring($model) |
|
62 | + { |
|
63 | + $model->logs()->restore(); |
|
64 | + } |
|
65 | 65 | |
66 | - public function restored($model) |
|
67 | - { |
|
68 | - // |
|
69 | - } |
|
66 | + public function restored($model) |
|
67 | + { |
|
68 | + // |
|
69 | + } |
|
70 | 70 | } |
71 | 71 | \ No newline at end of file |
@@ -5,53 +5,53 @@ |
||
5 | 5 | */ |
6 | 6 | class OauthClientObserver { |
7 | 7 | |
8 | - public function saving($model) |
|
9 | - { |
|
10 | - // |
|
11 | - } |
|
12 | - |
|
13 | - public function saved($model) |
|
14 | - { |
|
15 | - // |
|
16 | - } |
|
17 | - |
|
18 | - public function creating($model) |
|
19 | - { |
|
20 | - $model->secret = str_random(40); |
|
21 | - } |
|
22 | - |
|
23 | - public function created($model) |
|
24 | - { |
|
25 | - // |
|
26 | - } |
|
27 | - |
|
28 | - public function updating($model) |
|
29 | - { |
|
30 | - // |
|
31 | - } |
|
32 | - |
|
33 | - public function updated($model) |
|
34 | - { |
|
35 | - // |
|
36 | - } |
|
37 | - |
|
38 | - public function deleting($model) |
|
39 | - { |
|
40 | - // |
|
41 | - } |
|
42 | - |
|
43 | - public function deleted($model) |
|
44 | - { |
|
45 | - // |
|
46 | - } |
|
47 | - |
|
48 | - public function restoring($model) |
|
49 | - { |
|
50 | - // |
|
51 | - } |
|
52 | - |
|
53 | - public function restored($model) |
|
54 | - { |
|
55 | - // |
|
56 | - } |
|
8 | + public function saving($model) |
|
9 | + { |
|
10 | + // |
|
11 | + } |
|
12 | + |
|
13 | + public function saved($model) |
|
14 | + { |
|
15 | + // |
|
16 | + } |
|
17 | + |
|
18 | + public function creating($model) |
|
19 | + { |
|
20 | + $model->secret = str_random(40); |
|
21 | + } |
|
22 | + |
|
23 | + public function created($model) |
|
24 | + { |
|
25 | + // |
|
26 | + } |
|
27 | + |
|
28 | + public function updating($model) |
|
29 | + { |
|
30 | + // |
|
31 | + } |
|
32 | + |
|
33 | + public function updated($model) |
|
34 | + { |
|
35 | + // |
|
36 | + } |
|
37 | + |
|
38 | + public function deleting($model) |
|
39 | + { |
|
40 | + // |
|
41 | + } |
|
42 | + |
|
43 | + public function deleted($model) |
|
44 | + { |
|
45 | + // |
|
46 | + } |
|
47 | + |
|
48 | + public function restoring($model) |
|
49 | + { |
|
50 | + // |
|
51 | + } |
|
52 | + |
|
53 | + public function restored($model) |
|
54 | + { |
|
55 | + // |
|
56 | + } |
|
57 | 57 | } |
58 | 58 | \ No newline at end of file |
@@ -6,18 +6,18 @@ |
||
6 | 6 | |
7 | 7 | class AclDatabaseSeeder extends Seeder |
8 | 8 | { |
9 | - /** |
|
10 | - * Run the database seeds. |
|
11 | - * |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function run() |
|
15 | - { |
|
16 | - $this->call(ClearDataSeeder::class); |
|
17 | - $this->call(UsersTableSeeder::class); |
|
18 | - $this->call(GroupsTableSeeder::class); |
|
19 | - $this->call(PermissionsTableSeeder::class); |
|
20 | - $this->call(OauthClientsTableSeeder::class); |
|
21 | - $this->call(AssignRelationsSeeder::class); |
|
22 | - } |
|
9 | + /** |
|
10 | + * Run the database seeds. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function run() |
|
15 | + { |
|
16 | + $this->call(ClearDataSeeder::class); |
|
17 | + $this->call(UsersTableSeeder::class); |
|
18 | + $this->call(GroupsTableSeeder::class); |
|
19 | + $this->call(PermissionsTableSeeder::class); |
|
20 | + $this->call(OauthClientsTableSeeder::class); |
|
21 | + $this->call(AssignRelationsSeeder::class); |
|
22 | + } |
|
23 | 23 | } |
@@ -6,112 +6,112 @@ |
||
6 | 6 | |
7 | 7 | class OauthClientsTableSeeder extends Seeder |
8 | 8 | { |
9 | - /** |
|
10 | - * Run the database seeds. |
|
11 | - * |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function run() |
|
15 | - { |
|
16 | - /** |
|
17 | - * Insert the permissions related to oauthClients table. |
|
18 | - */ |
|
19 | - \DB::table('permissions')->insert( |
|
20 | - [ |
|
21 | - /** |
|
22 | - * Users model permissions. |
|
23 | - */ |
|
24 | - [ |
|
25 | - 'name' => 'save', |
|
26 | - 'model' => 'oauthClients', |
|
27 | - 'created_at' => \DB::raw('NOW()'), |
|
28 | - 'updated_at' => \DB::raw('NOW()') |
|
29 | - ], |
|
30 | - [ |
|
31 | - 'name' => 'delete', |
|
32 | - 'model' => 'oauthClients', |
|
33 | - 'created_at' => \DB::raw('NOW()'), |
|
34 | - 'updated_at' => \DB::raw('NOW()') |
|
35 | - ], |
|
36 | - [ |
|
37 | - 'name' => 'find', |
|
38 | - 'model' => 'oauthClients', |
|
39 | - 'created_at' => \DB::raw('NOW()'), |
|
40 | - 'updated_at' => \DB::raw('NOW()') |
|
41 | - ], |
|
42 | - [ |
|
43 | - 'name' => 'list', |
|
44 | - 'model' => 'oauthClients', |
|
45 | - 'created_at' => \DB::raw('NOW()'), |
|
46 | - 'updated_at' => \DB::raw('NOW()') |
|
47 | - ], |
|
48 | - [ |
|
49 | - 'name' => 'search', |
|
50 | - 'model' => 'oauthClients', |
|
51 | - 'created_at' => \DB::raw('NOW()'), |
|
52 | - 'updated_at' => \DB::raw('NOW()') |
|
53 | - ], |
|
54 | - [ |
|
55 | - 'name' => 'findby', |
|
56 | - 'model' => 'oauthClients', |
|
57 | - 'created_at' => \DB::raw('NOW()'), |
|
58 | - 'updated_at' => \DB::raw('NOW()') |
|
59 | - ], |
|
60 | - [ |
|
61 | - 'name' => 'first', |
|
62 | - 'model' => 'oauthClients', |
|
63 | - 'created_at' => \DB::raw('NOW()'), |
|
64 | - 'updated_at' => \DB::raw('NOW()') |
|
65 | - ], |
|
66 | - [ |
|
67 | - 'name' => 'paginate', |
|
68 | - 'model' => 'oauthClients', |
|
69 | - 'created_at' => \DB::raw('NOW()'), |
|
70 | - 'updated_at' => \DB::raw('NOW()') |
|
71 | - ], |
|
72 | - [ |
|
73 | - 'name' => 'paginateby', |
|
74 | - 'model' => 'oauthClients', |
|
75 | - 'created_at' => \DB::raw('NOW()'), |
|
76 | - 'updated_at' => \DB::raw('NOW()') |
|
77 | - ], |
|
78 | - [ |
|
79 | - 'name' => 'assigngroups', |
|
80 | - 'model' => 'oauthClients', |
|
81 | - 'created_at' => \DB::raw('NOW()'), |
|
82 | - 'updated_at' => \DB::raw('NOW()') |
|
83 | - ], |
|
84 | - [ |
|
85 | - 'name' => 'block', |
|
86 | - 'model' => 'oauthClients', |
|
87 | - 'created_at' => \DB::raw('NOW()'), |
|
88 | - 'updated_at' => \DB::raw('NOW()') |
|
89 | - ], |
|
90 | - [ |
|
91 | - 'name' => 'unblock', |
|
92 | - 'model' => 'oauthClients', |
|
93 | - 'created_at' => \DB::raw('NOW()'), |
|
94 | - 'updated_at' => \DB::raw('NOW()') |
|
95 | - ], |
|
96 | - [ |
|
97 | - 'name' => 'group', |
|
98 | - 'model' => 'oauthClients', |
|
99 | - 'created_at' => \DB::raw('NOW()'), |
|
100 | - 'updated_at' => \DB::raw('NOW()') |
|
101 | - ], |
|
102 | - [ |
|
103 | - 'name' => 'deleted', |
|
104 | - 'model' => 'oauthClients', |
|
105 | - 'created_at' => \DB::raw('NOW()'), |
|
106 | - 'updated_at' => \DB::raw('NOW()') |
|
107 | - ], |
|
108 | - [ |
|
109 | - 'name' => 'restore', |
|
110 | - 'model' => 'oauthClients', |
|
111 | - 'created_at' => \DB::raw('NOW()'), |
|
112 | - 'updated_at' => \DB::raw('NOW()') |
|
113 | - ] |
|
114 | - ] |
|
115 | - ); |
|
116 | - } |
|
9 | + /** |
|
10 | + * Run the database seeds. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function run() |
|
15 | + { |
|
16 | + /** |
|
17 | + * Insert the permissions related to oauthClients table. |
|
18 | + */ |
|
19 | + \DB::table('permissions')->insert( |
|
20 | + [ |
|
21 | + /** |
|
22 | + * Users model permissions. |
|
23 | + */ |
|
24 | + [ |
|
25 | + 'name' => 'save', |
|
26 | + 'model' => 'oauthClients', |
|
27 | + 'created_at' => \DB::raw('NOW()'), |
|
28 | + 'updated_at' => \DB::raw('NOW()') |
|
29 | + ], |
|
30 | + [ |
|
31 | + 'name' => 'delete', |
|
32 | + 'model' => 'oauthClients', |
|
33 | + 'created_at' => \DB::raw('NOW()'), |
|
34 | + 'updated_at' => \DB::raw('NOW()') |
|
35 | + ], |
|
36 | + [ |
|
37 | + 'name' => 'find', |
|
38 | + 'model' => 'oauthClients', |
|
39 | + 'created_at' => \DB::raw('NOW()'), |
|
40 | + 'updated_at' => \DB::raw('NOW()') |
|
41 | + ], |
|
42 | + [ |
|
43 | + 'name' => 'list', |
|
44 | + 'model' => 'oauthClients', |
|
45 | + 'created_at' => \DB::raw('NOW()'), |
|
46 | + 'updated_at' => \DB::raw('NOW()') |
|
47 | + ], |
|
48 | + [ |
|
49 | + 'name' => 'search', |
|
50 | + 'model' => 'oauthClients', |
|
51 | + 'created_at' => \DB::raw('NOW()'), |
|
52 | + 'updated_at' => \DB::raw('NOW()') |
|
53 | + ], |
|
54 | + [ |
|
55 | + 'name' => 'findby', |
|
56 | + 'model' => 'oauthClients', |
|
57 | + 'created_at' => \DB::raw('NOW()'), |
|
58 | + 'updated_at' => \DB::raw('NOW()') |
|
59 | + ], |
|
60 | + [ |
|
61 | + 'name' => 'first', |
|
62 | + 'model' => 'oauthClients', |
|
63 | + 'created_at' => \DB::raw('NOW()'), |
|
64 | + 'updated_at' => \DB::raw('NOW()') |
|
65 | + ], |
|
66 | + [ |
|
67 | + 'name' => 'paginate', |
|
68 | + 'model' => 'oauthClients', |
|
69 | + 'created_at' => \DB::raw('NOW()'), |
|
70 | + 'updated_at' => \DB::raw('NOW()') |
|
71 | + ], |
|
72 | + [ |
|
73 | + 'name' => 'paginateby', |
|
74 | + 'model' => 'oauthClients', |
|
75 | + 'created_at' => \DB::raw('NOW()'), |
|
76 | + 'updated_at' => \DB::raw('NOW()') |
|
77 | + ], |
|
78 | + [ |
|
79 | + 'name' => 'assigngroups', |
|
80 | + 'model' => 'oauthClients', |
|
81 | + 'created_at' => \DB::raw('NOW()'), |
|
82 | + 'updated_at' => \DB::raw('NOW()') |
|
83 | + ], |
|
84 | + [ |
|
85 | + 'name' => 'block', |
|
86 | + 'model' => 'oauthClients', |
|
87 | + 'created_at' => \DB::raw('NOW()'), |
|
88 | + 'updated_at' => \DB::raw('NOW()') |
|
89 | + ], |
|
90 | + [ |
|
91 | + 'name' => 'unblock', |
|
92 | + 'model' => 'oauthClients', |
|
93 | + 'created_at' => \DB::raw('NOW()'), |
|
94 | + 'updated_at' => \DB::raw('NOW()') |
|
95 | + ], |
|
96 | + [ |
|
97 | + 'name' => 'group', |
|
98 | + 'model' => 'oauthClients', |
|
99 | + 'created_at' => \DB::raw('NOW()'), |
|
100 | + 'updated_at' => \DB::raw('NOW()') |
|
101 | + ], |
|
102 | + [ |
|
103 | + 'name' => 'deleted', |
|
104 | + 'model' => 'oauthClients', |
|
105 | + 'created_at' => \DB::raw('NOW()'), |
|
106 | + 'updated_at' => \DB::raw('NOW()') |
|
107 | + ], |
|
108 | + [ |
|
109 | + 'name' => 'restore', |
|
110 | + 'model' => 'oauthClients', |
|
111 | + 'created_at' => \DB::raw('NOW()'), |
|
112 | + 'updated_at' => \DB::raw('NOW()') |
|
113 | + ] |
|
114 | + ] |
|
115 | + ); |
|
116 | + } |
|
117 | 117 | } |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | $factory->define(App\Modules\V1\Acl\OauthClient::class, function (Faker\Generator $faker) { |
4 | - return [ |
|
5 | - 'user_id' => $faker->randomDigit(), |
|
4 | + return [ |
|
5 | + 'user_id' => $faker->randomDigit(), |
|
6 | 6 | 'name' => $faker->name(), |
7 | 7 | 'secret' => str_random(40), |
8 | 8 | 'redirect' => $faker->url(), |
@@ -11,5 +11,5 @@ discard block |
||
11 | 11 | 'revoked' => $faker->boolean(), |
12 | 12 | 'created_at' => $faker->dateTimeBetween('-1 years', 'now'), |
13 | 13 | 'updated_at' => $faker->dateTimeBetween('-1 years', 'now') |
14 | - ]; |
|
14 | + ]; |
|
15 | 15 | }); |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -$factory->define(App\Modules\V1\Acl\OauthClient::class, function (Faker\Generator $faker) { |
|
3 | +$factory->define(App\Modules\V1\Acl\OauthClient::class, function(Faker\Generator $faker) { |
|
4 | 4 | return [ |
5 | 5 | 'user_id' => $faker->randomDigit(), |
6 | 6 | 'name' => $faker->name(), |