@@ -1,7 +1,5 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -use Illuminate\Http\Request; |
|
| 4 | - |
|
| 5 | 3 | /* |
| 6 | 4 | |-------------------------------------------------------------------------- |
| 7 | 5 | | API Routes |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | | |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -Route::group(['prefix' => 'push/notification/devices'], function () { |
|
| 16 | +Route::group(['prefix' => 'push/notification/devices'], function() { |
|
| 17 | 17 | |
| 18 | 18 | Route::get('/', 'PushNotificationDeviceController@index'); |
| 19 | 19 | Route::get('/{id}', 'PushNotificationDeviceController@find'); |
@@ -15,12 +15,12 @@ |
||
| 15 | 15 | |
| 16 | 16 | Route::group(['prefix' => 'push/notification/devices'], function () { |
| 17 | 17 | |
| 18 | - Route::get('/', 'PushNotificationDeviceController@index'); |
|
| 19 | - Route::get('/{id}', 'PushNotificationDeviceController@find'); |
|
| 20 | - Route::post('/', 'PushNotificationDeviceController@insert'); |
|
| 21 | - Route::put('/', 'PushNotificationDeviceController@update'); |
|
| 22 | - Route::delete('/{id}', 'PushNotificationDeviceController@delete'); |
|
| 23 | - Route::get('list/deleted', 'PushNotificationDeviceController@deleted'); |
|
| 24 | - Route::patch('restore/{id}', 'PushNotificationDeviceController@restore'); |
|
| 25 | - Route::post('register/device', 'PushNotificationDeviceController@registerDevice'); |
|
| 18 | + Route::get('/', 'PushNotificationDeviceController@index'); |
|
| 19 | + Route::get('/{id}', 'PushNotificationDeviceController@find'); |
|
| 20 | + Route::post('/', 'PushNotificationDeviceController@insert'); |
|
| 21 | + Route::put('/', 'PushNotificationDeviceController@update'); |
|
| 22 | + Route::delete('/{id}', 'PushNotificationDeviceController@delete'); |
|
| 23 | + Route::get('list/deleted', 'PushNotificationDeviceController@deleted'); |
|
| 24 | + Route::patch('restore/{id}', 'PushNotificationDeviceController@restore'); |
|
| 25 | + Route::post('register/device', 'PushNotificationDeviceController@registerDevice'); |
|
| 26 | 26 | }); |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | * |
| 145 | 145 | * @param array $credentials |
| 146 | 146 | * @param boolean $skipConfirmEmail |
| 147 | - * @return array |
|
| 147 | + * @return boolean |
|
| 148 | 148 | */ |
| 149 | 149 | public function register($credentials, $skipConfirmEmail = false) |
| 150 | 150 | { |
@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | * Save the given data to the logged in user. |
| 345 | 345 | * |
| 346 | 346 | * @param array $data |
| 347 | - * @return void |
|
| 347 | + * @return boolean |
|
| 348 | 348 | */ |
| 349 | 349 | public function saveProfile($data) |
| 350 | 350 | { |
@@ -6,400 +6,400 @@ |
||
| 6 | 6 | |
| 7 | 7 | class UserRepository extends BaseRepository |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * Init new object. |
|
| 11 | - * |
|
| 12 | - * @param AclUser $model |
|
| 13 | - * @return void |
|
| 14 | - */ |
|
| 15 | - public function __construct(AclUser $model) |
|
| 16 | - { |
|
| 17 | - parent::__construct($model); |
|
| 18 | - } |
|
| 19 | - |
|
| 20 | - /** |
|
| 21 | - * Return the logged in user account. |
|
| 22 | - * |
|
| 23 | - * @param array $relations |
|
| 24 | - * @return boolean |
|
| 25 | - */ |
|
| 26 | - public function account($relations = []) |
|
| 27 | - { |
|
| 28 | - $permissions = []; |
|
| 29 | - $user = $this->find(\Auth::id(), $relations); |
|
| 30 | - foreach ($user->roles()->get() as $role) { |
|
| 31 | - $role->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 mixed $user |
|
| 47 | - * @return boolean |
|
| 48 | - */ |
|
| 49 | - public function can($nameOfPermission, $model, $user = false) |
|
| 50 | - { |
|
| 51 | - $user = $user ?: $this->find(\Auth::id(), ['roles.permissions']); |
|
| 52 | - $permissions = []; |
|
| 53 | - |
|
| 54 | - $user->roles->pluck('permissions')->each(function ($permission) use (&$permissions, $model) { |
|
| 55 | - $permissions = array_merge($permissions, $permission->where('model', $model)->pluck('name')->toArray()); |
|
| 56 | - }); |
|
| 57 | - |
|
| 58 | - return in_array($nameOfPermission, $permissions); |
|
| 59 | - } |
|
| 60 | - |
|
| 61 | - /** |
|
| 62 | - * Check if the logged in user has the given role. |
|
| 63 | - * |
|
| 64 | - * @param string[] $roles |
|
| 65 | - * @param mixed $user |
|
| 66 | - * @return boolean |
|
| 67 | - */ |
|
| 68 | - public function hasRole($roles, $user = false) |
|
| 69 | - { |
|
| 70 | - $user = $user ?: $this->find(\Auth::id()); |
|
| 71 | - return $user->roles->whereIn('name', $roles)->count() ? true : false; |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - /** |
|
| 75 | - * Assign the given role ids to the given user. |
|
| 76 | - * |
|
| 77 | - * @param integer $userId |
|
| 78 | - * @param array $roleIds |
|
| 79 | - * @return object |
|
| 80 | - */ |
|
| 81 | - public function assignRoles($userId, $roleIds) |
|
| 82 | - { |
|
| 83 | - \DB::transaction(function () use ($userId, $roleIds) { |
|
| 84 | - $user = $this->find($userId); |
|
| 85 | - $user->roles()->detach(); |
|
| 86 | - $user->roles()->attach($roleIds); |
|
| 87 | - }); |
|
| 88 | - |
|
| 89 | - return $this->find($userId); |
|
| 90 | - } |
|
| 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 | - \ErrorHandler::loginFailed(); |
|
| 104 | - } elseif ($adminLogin && ! $user->roles->whereIn('name', ['Admin'])->count()) { |
|
| 105 | - \ErrorHandler::loginFailed(); |
|
| 106 | - } elseif (! $adminLogin && $user->roles->whereIn('name', ['Admin'])->count()) { |
|
| 107 | - \ErrorHandler::loginFailed(); |
|
| 108 | - } elseif ($user->blocked) { |
|
| 109 | - \ErrorHandler::userIsBlocked(); |
|
| 110 | - } elseif (! config('skeleton.disable_confirm_email') && ! $user->confirmed) { |
|
| 111 | - \ErrorHandler::emailNotConfirmed(); |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - return $user; |
|
| 115 | - } |
|
| 116 | - |
|
| 117 | - /** |
|
| 118 | - * Handle a social login request of the none admin to the application. |
|
| 119 | - * |
|
| 120 | - * @param string $authCode |
|
| 121 | - * @param string $accessToken |
|
| 122 | - * @param string $type |
|
| 123 | - * @return array |
|
| 124 | - */ |
|
| 125 | - public function loginSocial($authCode, $accessToken, $type) |
|
| 126 | - { |
|
| 127 | - $access_token = $authCode ? Arr::get(\Socialite::driver($type)->getAccessTokenResponse($authCode), 'access_token') : $accessToken; |
|
| 128 | - $user = \Socialite::driver($type)->userFromToken($access_token); |
|
| 129 | - |
|
| 130 | - if (! $user->email) { |
|
| 131 | - \ErrorHandler::noSocialEmail(); |
|
| 132 | - } |
|
| 133 | - |
|
| 134 | - if (! $this->model->where('email', $user->email)->first()) { |
|
| 135 | - $this->register(['email' => $user->email, 'password' => ''], true); |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - $loginProxy = \App::make('App\Modules\Users\Proxy\LoginProxy'); |
|
| 139 | - return $loginProxy->login(['email' => $user->email, 'password' => config('skeleton.social_pass')], 0); |
|
| 140 | - } |
|
| 9 | + /** |
|
| 10 | + * Init new object. |
|
| 11 | + * |
|
| 12 | + * @param AclUser $model |
|
| 13 | + * @return void |
|
| 14 | + */ |
|
| 15 | + public function __construct(AclUser $model) |
|
| 16 | + { |
|
| 17 | + parent::__construct($model); |
|
| 18 | + } |
|
| 19 | + |
|
| 20 | + /** |
|
| 21 | + * Return the logged in user account. |
|
| 22 | + * |
|
| 23 | + * @param array $relations |
|
| 24 | + * @return boolean |
|
| 25 | + */ |
|
| 26 | + public function account($relations = []) |
|
| 27 | + { |
|
| 28 | + $permissions = []; |
|
| 29 | + $user = $this->find(\Auth::id(), $relations); |
|
| 30 | + foreach ($user->roles()->get() as $role) { |
|
| 31 | + $role->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 mixed $user |
|
| 47 | + * @return boolean |
|
| 48 | + */ |
|
| 49 | + public function can($nameOfPermission, $model, $user = false) |
|
| 50 | + { |
|
| 51 | + $user = $user ?: $this->find(\Auth::id(), ['roles.permissions']); |
|
| 52 | + $permissions = []; |
|
| 53 | + |
|
| 54 | + $user->roles->pluck('permissions')->each(function ($permission) use (&$permissions, $model) { |
|
| 55 | + $permissions = array_merge($permissions, $permission->where('model', $model)->pluck('name')->toArray()); |
|
| 56 | + }); |
|
| 57 | + |
|
| 58 | + return in_array($nameOfPermission, $permissions); |
|
| 59 | + } |
|
| 60 | + |
|
| 61 | + /** |
|
| 62 | + * Check if the logged in user has the given role. |
|
| 63 | + * |
|
| 64 | + * @param string[] $roles |
|
| 65 | + * @param mixed $user |
|
| 66 | + * @return boolean |
|
| 67 | + */ |
|
| 68 | + public function hasRole($roles, $user = false) |
|
| 69 | + { |
|
| 70 | + $user = $user ?: $this->find(\Auth::id()); |
|
| 71 | + return $user->roles->whereIn('name', $roles)->count() ? true : false; |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + /** |
|
| 75 | + * Assign the given role ids to the given user. |
|
| 76 | + * |
|
| 77 | + * @param integer $userId |
|
| 78 | + * @param array $roleIds |
|
| 79 | + * @return object |
|
| 80 | + */ |
|
| 81 | + public function assignRoles($userId, $roleIds) |
|
| 82 | + { |
|
| 83 | + \DB::transaction(function () use ($userId, $roleIds) { |
|
| 84 | + $user = $this->find($userId); |
|
| 85 | + $user->roles()->detach(); |
|
| 86 | + $user->roles()->attach($roleIds); |
|
| 87 | + }); |
|
| 88 | + |
|
| 89 | + return $this->find($userId); |
|
| 90 | + } |
|
| 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 | + \ErrorHandler::loginFailed(); |
|
| 104 | + } elseif ($adminLogin && ! $user->roles->whereIn('name', ['Admin'])->count()) { |
|
| 105 | + \ErrorHandler::loginFailed(); |
|
| 106 | + } elseif (! $adminLogin && $user->roles->whereIn('name', ['Admin'])->count()) { |
|
| 107 | + \ErrorHandler::loginFailed(); |
|
| 108 | + } elseif ($user->blocked) { |
|
| 109 | + \ErrorHandler::userIsBlocked(); |
|
| 110 | + } elseif (! config('skeleton.disable_confirm_email') && ! $user->confirmed) { |
|
| 111 | + \ErrorHandler::emailNotConfirmed(); |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + return $user; |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + /** |
|
| 118 | + * Handle a social login request of the none admin to the application. |
|
| 119 | + * |
|
| 120 | + * @param string $authCode |
|
| 121 | + * @param string $accessToken |
|
| 122 | + * @param string $type |
|
| 123 | + * @return array |
|
| 124 | + */ |
|
| 125 | + public function loginSocial($authCode, $accessToken, $type) |
|
| 126 | + { |
|
| 127 | + $access_token = $authCode ? Arr::get(\Socialite::driver($type)->getAccessTokenResponse($authCode), 'access_token') : $accessToken; |
|
| 128 | + $user = \Socialite::driver($type)->userFromToken($access_token); |
|
| 129 | + |
|
| 130 | + if (! $user->email) { |
|
| 131 | + \ErrorHandler::noSocialEmail(); |
|
| 132 | + } |
|
| 133 | + |
|
| 134 | + if (! $this->model->where('email', $user->email)->first()) { |
|
| 135 | + $this->register(['email' => $user->email, 'password' => ''], true); |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + $loginProxy = \App::make('App\Modules\Users\Proxy\LoginProxy'); |
|
| 139 | + return $loginProxy->login(['email' => $user->email, 'password' => config('skeleton.social_pass')], 0); |
|
| 140 | + } |
|
| 141 | 141 | |
| 142 | - /** |
|
| 143 | - * Handle a registration request. |
|
| 144 | - * |
|
| 145 | - * @param array $credentials |
|
| 146 | - * @param boolean $skipConfirmEmail |
|
| 147 | - * @return array |
|
| 148 | - */ |
|
| 149 | - public function register($credentials, $skipConfirmEmail = false) |
|
| 150 | - { |
|
| 151 | - $user = $this->save($credentials); |
|
| 152 | - |
|
| 153 | - if ($skipConfirmEmail) { |
|
| 154 | - $user->confirmed = 1; |
|
| 155 | - $user->save(); |
|
| 156 | - } elseif (! config('skeleton.disable_confirm_email')) { |
|
| 157 | - $this->sendConfirmationEmail($user->email); |
|
| 158 | - } |
|
| 159 | - |
|
| 160 | - return $user; |
|
| 161 | - } |
|
| 142 | + /** |
|
| 143 | + * Handle a registration request. |
|
| 144 | + * |
|
| 145 | + * @param array $credentials |
|
| 146 | + * @param boolean $skipConfirmEmail |
|
| 147 | + * @return array |
|
| 148 | + */ |
|
| 149 | + public function register($credentials, $skipConfirmEmail = false) |
|
| 150 | + { |
|
| 151 | + $user = $this->save($credentials); |
|
| 152 | + |
|
| 153 | + if ($skipConfirmEmail) { |
|
| 154 | + $user->confirmed = 1; |
|
| 155 | + $user->save(); |
|
| 156 | + } elseif (! config('skeleton.disable_confirm_email')) { |
|
| 157 | + $this->sendConfirmationEmail($user->email); |
|
| 158 | + } |
|
| 159 | + |
|
| 160 | + return $user; |
|
| 161 | + } |
|
| 162 | 162 | |
| 163 | - /** |
|
| 164 | - * Block the user. |
|
| 165 | - * |
|
| 166 | - * @param integer $userId |
|
| 167 | - * @return object |
|
| 168 | - */ |
|
| 169 | - public function block($userId) |
|
| 170 | - { |
|
| 171 | - if (! $user = $this->find($userId)) { |
|
| 172 | - \ErrorHandler::notFound('user'); |
|
| 173 | - } |
|
| 174 | - if (! $this->hasRole(['Admin'])) { |
|
| 175 | - \ErrorHandler::noPermissions(); |
|
| 176 | - } elseif (\Auth::id() == $userId) { |
|
| 177 | - \ErrorHandler::noPermissions(); |
|
| 178 | - } elseif ($user->roles->pluck('name')->search('Admin', true) !== false) { |
|
| 179 | - \ErrorHandler::noPermissions(); |
|
| 180 | - } |
|
| 181 | - |
|
| 182 | - $user->blocked = 1; |
|
| 183 | - $user->save(); |
|
| 163 | + /** |
|
| 164 | + * Block the user. |
|
| 165 | + * |
|
| 166 | + * @param integer $userId |
|
| 167 | + * @return object |
|
| 168 | + */ |
|
| 169 | + public function block($userId) |
|
| 170 | + { |
|
| 171 | + if (! $user = $this->find($userId)) { |
|
| 172 | + \ErrorHandler::notFound('user'); |
|
| 173 | + } |
|
| 174 | + if (! $this->hasRole(['Admin'])) { |
|
| 175 | + \ErrorHandler::noPermissions(); |
|
| 176 | + } elseif (\Auth::id() == $userId) { |
|
| 177 | + \ErrorHandler::noPermissions(); |
|
| 178 | + } elseif ($user->roles->pluck('name')->search('Admin', true) !== false) { |
|
| 179 | + \ErrorHandler::noPermissions(); |
|
| 180 | + } |
|
| 181 | + |
|
| 182 | + $user->blocked = 1; |
|
| 183 | + $user->save(); |
|
| 184 | 184 | |
| 185 | - return $user; |
|
| 186 | - } |
|
| 187 | - |
|
| 188 | - /** |
|
| 189 | - * Unblock the user. |
|
| 190 | - * |
|
| 191 | - * @param integer $userId |
|
| 192 | - * @return object |
|
| 193 | - */ |
|
| 194 | - public function unblock($userId) |
|
| 195 | - { |
|
| 196 | - if (! $this->hasRole(['Admin'])) { |
|
| 197 | - \ErrorHandler::noPermissions(); |
|
| 198 | - } |
|
| 199 | - |
|
| 200 | - $user = $this->find($userId); |
|
| 201 | - $user->blocked = 0; |
|
| 202 | - $user->save(); |
|
| 203 | - |
|
| 204 | - return $user; |
|
| 205 | - } |
|
| 206 | - |
|
| 207 | - /** |
|
| 208 | - * Send a reset link to the given user. |
|
| 209 | - * |
|
| 210 | - * @param string $email |
|
| 211 | - * @return void |
|
| 212 | - */ |
|
| 213 | - public function sendReset($email) |
|
| 214 | - { |
|
| 215 | - if (! $user = $this->model->where('email', $email)->first()) { |
|
| 216 | - \ErrorHandler::notFound('email'); |
|
| 217 | - } |
|
| 218 | - |
|
| 219 | - $token = \Password::getRepository()->create($user); |
|
| 220 | - \Core::notifications()->notify($user, 'ResetPassword', $token); |
|
| 221 | - } |
|
| 222 | - |
|
| 223 | - /** |
|
| 224 | - * Reset the given user's password. |
|
| 225 | - * |
|
| 226 | - * @param string $email |
|
| 227 | - * @param string $password |
|
| 228 | - * @param string $passwordConfirmation |
|
| 229 | - * @param string $token |
|
| 230 | - * @return string|void |
|
| 231 | - */ |
|
| 232 | - public function resetPassword($email, $password, $passwordConfirmation, $token) |
|
| 233 | - { |
|
| 234 | - $response = \Password::reset([ |
|
| 235 | - 'email' => $email, |
|
| 236 | - 'password' => $password, |
|
| 237 | - 'password_confirmation' => $passwordConfirmation, |
|
| 238 | - 'token' => $token |
|
| 239 | - ], function ($user, $password) { |
|
| 240 | - $user->password = $password; |
|
| 241 | - $user->save(); |
|
| 242 | - }); |
|
| 243 | - |
|
| 244 | - switch ($response) { |
|
| 245 | - case \Password::PASSWORD_RESET: |
|
| 246 | - return 'success'; |
|
| 247 | - |
|
| 248 | - case \Password::INVALID_TOKEN: |
|
| 249 | - \ErrorHandler::invalidResetToken('token'); |
|
| 250 | - //no break |
|
| 251 | - |
|
| 252 | - case \Password::INVALID_PASSWORD: |
|
| 253 | - \ErrorHandler::invalidResetPassword('email'); |
|
| 254 | - //no break |
|
| 255 | - |
|
| 256 | - case \Password::INVALID_USER: |
|
| 257 | - \ErrorHandler::notFound('user'); |
|
| 258 | - //no break |
|
| 259 | - |
|
| 260 | - default: |
|
| 261 | - \ErrorHandler::generalError(); |
|
| 262 | - } |
|
| 263 | - } |
|
| 264 | - |
|
| 265 | - /** |
|
| 266 | - * Change the logged in user password. |
|
| 267 | - * |
|
| 268 | - * @param string $password |
|
| 269 | - * @param string $oldPassword |
|
| 270 | - * @return void |
|
| 271 | - */ |
|
| 272 | - public function changePassword($password, $oldPassword) |
|
| 273 | - { |
|
| 274 | - $user = \Auth::user(); |
|
| 275 | - if (! \Hash::check($oldPassword, $user->password)) { |
|
| 276 | - \ErrorHandler::invalidOldPassword(); |
|
| 277 | - } |
|
| 278 | - |
|
| 279 | - $user->password = $password; |
|
| 280 | - $user->save(); |
|
| 281 | - } |
|
| 282 | - |
|
| 283 | - /** |
|
| 284 | - * Confirm email using the confirmation code. |
|
| 285 | - * |
|
| 286 | - * @param string $confirmationCode |
|
| 287 | - * @return void |
|
| 288 | - */ |
|
| 289 | - public function confirmEmail($confirmationCode) |
|
| 290 | - { |
|
| 291 | - if (! $user = $this->first(['confirmation_code' => $confirmationCode])) { |
|
| 292 | - \ErrorHandler::invalidConfirmationCode(); |
|
| 293 | - } |
|
| 294 | - |
|
| 295 | - $user->confirmed = 1; |
|
| 296 | - $user->confirmation_code = null; |
|
| 297 | - $user->save(); |
|
| 298 | - } |
|
| 299 | - |
|
| 300 | - /** |
|
| 301 | - * Send the confirmation mail. |
|
| 302 | - * |
|
| 303 | - * @param string $email |
|
| 304 | - * @return void |
|
| 305 | - */ |
|
| 306 | - public function sendConfirmationEmail($email) |
|
| 307 | - { |
|
| 308 | - $user = $this->first(['email' => $email]); |
|
| 309 | - if ($user->confirmed) { |
|
| 310 | - \ErrorHandler::emailAlreadyConfirmed(); |
|
| 311 | - } |
|
| 312 | - |
|
| 313 | - $user->confirmed = 0; |
|
| 314 | - $user->confirmation_code = sha1(microtime()); |
|
| 315 | - $user->save(); |
|
| 316 | - \Core::notifications()->notify($user, 'ConfirmEmail'); |
|
| 317 | - } |
|
| 318 | - |
|
| 319 | - /** |
|
| 320 | - * Paginate all users in the given role based on the given conditions. |
|
| 321 | - * |
|
| 322 | - * @param string $roleName |
|
| 323 | - * @param array $relations |
|
| 324 | - * @param integer $perPage |
|
| 325 | - * @param string $sortBy |
|
| 326 | - * @param boolean $desc |
|
| 327 | - * @return \Illuminate\Http\Response |
|
| 328 | - */ |
|
| 329 | - public function role($conditions, $roleName, $relations, $perPage, $sortBy, $desc) |
|
| 330 | - { |
|
| 331 | - unset($conditions['page']); |
|
| 332 | - $conditions = $this->constructConditions($conditions, $this->model); |
|
| 333 | - $sort = $desc ? 'desc' : 'asc'; |
|
| 334 | - $model = $this->model->with($relations); |
|
| 335 | - |
|
| 336 | - $model->whereHas('roles', function ($q) use ($roleName) { |
|
| 337 | - $q->where('name', $roleName); |
|
| 338 | - }); |
|
| 185 | + return $user; |
|
| 186 | + } |
|
| 187 | + |
|
| 188 | + /** |
|
| 189 | + * Unblock the user. |
|
| 190 | + * |
|
| 191 | + * @param integer $userId |
|
| 192 | + * @return object |
|
| 193 | + */ |
|
| 194 | + public function unblock($userId) |
|
| 195 | + { |
|
| 196 | + if (! $this->hasRole(['Admin'])) { |
|
| 197 | + \ErrorHandler::noPermissions(); |
|
| 198 | + } |
|
| 199 | + |
|
| 200 | + $user = $this->find($userId); |
|
| 201 | + $user->blocked = 0; |
|
| 202 | + $user->save(); |
|
| 203 | + |
|
| 204 | + return $user; |
|
| 205 | + } |
|
| 206 | + |
|
| 207 | + /** |
|
| 208 | + * Send a reset link to the given user. |
|
| 209 | + * |
|
| 210 | + * @param string $email |
|
| 211 | + * @return void |
|
| 212 | + */ |
|
| 213 | + public function sendReset($email) |
|
| 214 | + { |
|
| 215 | + if (! $user = $this->model->where('email', $email)->first()) { |
|
| 216 | + \ErrorHandler::notFound('email'); |
|
| 217 | + } |
|
| 218 | + |
|
| 219 | + $token = \Password::getRepository()->create($user); |
|
| 220 | + \Core::notifications()->notify($user, 'ResetPassword', $token); |
|
| 221 | + } |
|
| 222 | + |
|
| 223 | + /** |
|
| 224 | + * Reset the given user's password. |
|
| 225 | + * |
|
| 226 | + * @param string $email |
|
| 227 | + * @param string $password |
|
| 228 | + * @param string $passwordConfirmation |
|
| 229 | + * @param string $token |
|
| 230 | + * @return string|void |
|
| 231 | + */ |
|
| 232 | + public function resetPassword($email, $password, $passwordConfirmation, $token) |
|
| 233 | + { |
|
| 234 | + $response = \Password::reset([ |
|
| 235 | + 'email' => $email, |
|
| 236 | + 'password' => $password, |
|
| 237 | + 'password_confirmation' => $passwordConfirmation, |
|
| 238 | + 'token' => $token |
|
| 239 | + ], function ($user, $password) { |
|
| 240 | + $user->password = $password; |
|
| 241 | + $user->save(); |
|
| 242 | + }); |
|
| 243 | + |
|
| 244 | + switch ($response) { |
|
| 245 | + case \Password::PASSWORD_RESET: |
|
| 246 | + return 'success'; |
|
| 247 | + |
|
| 248 | + case \Password::INVALID_TOKEN: |
|
| 249 | + \ErrorHandler::invalidResetToken('token'); |
|
| 250 | + //no break |
|
| 251 | + |
|
| 252 | + case \Password::INVALID_PASSWORD: |
|
| 253 | + \ErrorHandler::invalidResetPassword('email'); |
|
| 254 | + //no break |
|
| 255 | + |
|
| 256 | + case \Password::INVALID_USER: |
|
| 257 | + \ErrorHandler::notFound('user'); |
|
| 258 | + //no break |
|
| 259 | + |
|
| 260 | + default: |
|
| 261 | + \ErrorHandler::generalError(); |
|
| 262 | + } |
|
| 263 | + } |
|
| 264 | + |
|
| 265 | + /** |
|
| 266 | + * Change the logged in user password. |
|
| 267 | + * |
|
| 268 | + * @param string $password |
|
| 269 | + * @param string $oldPassword |
|
| 270 | + * @return void |
|
| 271 | + */ |
|
| 272 | + public function changePassword($password, $oldPassword) |
|
| 273 | + { |
|
| 274 | + $user = \Auth::user(); |
|
| 275 | + if (! \Hash::check($oldPassword, $user->password)) { |
|
| 276 | + \ErrorHandler::invalidOldPassword(); |
|
| 277 | + } |
|
| 278 | + |
|
| 279 | + $user->password = $password; |
|
| 280 | + $user->save(); |
|
| 281 | + } |
|
| 282 | + |
|
| 283 | + /** |
|
| 284 | + * Confirm email using the confirmation code. |
|
| 285 | + * |
|
| 286 | + * @param string $confirmationCode |
|
| 287 | + * @return void |
|
| 288 | + */ |
|
| 289 | + public function confirmEmail($confirmationCode) |
|
| 290 | + { |
|
| 291 | + if (! $user = $this->first(['confirmation_code' => $confirmationCode])) { |
|
| 292 | + \ErrorHandler::invalidConfirmationCode(); |
|
| 293 | + } |
|
| 294 | + |
|
| 295 | + $user->confirmed = 1; |
|
| 296 | + $user->confirmation_code = null; |
|
| 297 | + $user->save(); |
|
| 298 | + } |
|
| 299 | + |
|
| 300 | + /** |
|
| 301 | + * Send the confirmation mail. |
|
| 302 | + * |
|
| 303 | + * @param string $email |
|
| 304 | + * @return void |
|
| 305 | + */ |
|
| 306 | + public function sendConfirmationEmail($email) |
|
| 307 | + { |
|
| 308 | + $user = $this->first(['email' => $email]); |
|
| 309 | + if ($user->confirmed) { |
|
| 310 | + \ErrorHandler::emailAlreadyConfirmed(); |
|
| 311 | + } |
|
| 312 | + |
|
| 313 | + $user->confirmed = 0; |
|
| 314 | + $user->confirmation_code = sha1(microtime()); |
|
| 315 | + $user->save(); |
|
| 316 | + \Core::notifications()->notify($user, 'ConfirmEmail'); |
|
| 317 | + } |
|
| 318 | + |
|
| 319 | + /** |
|
| 320 | + * Paginate all users in the given role based on the given conditions. |
|
| 321 | + * |
|
| 322 | + * @param string $roleName |
|
| 323 | + * @param array $relations |
|
| 324 | + * @param integer $perPage |
|
| 325 | + * @param string $sortBy |
|
| 326 | + * @param boolean $desc |
|
| 327 | + * @return \Illuminate\Http\Response |
|
| 328 | + */ |
|
| 329 | + public function role($conditions, $roleName, $relations, $perPage, $sortBy, $desc) |
|
| 330 | + { |
|
| 331 | + unset($conditions['page']); |
|
| 332 | + $conditions = $this->constructConditions($conditions, $this->model); |
|
| 333 | + $sort = $desc ? 'desc' : 'asc'; |
|
| 334 | + $model = $this->model->with($relations); |
|
| 335 | + |
|
| 336 | + $model->whereHas('roles', function ($q) use ($roleName) { |
|
| 337 | + $q->where('name', $roleName); |
|
| 338 | + }); |
|
| 339 | 339 | |
| 340 | 340 | |
| 341 | - if (count($conditions['conditionValues'])) { |
|
| 342 | - $model->whereRaw($conditions['conditionString'], $conditions['conditionValues']); |
|
| 343 | - } |
|
| 344 | - |
|
| 345 | - if ($perPage) { |
|
| 346 | - return $model->orderBy($sortBy, $sort)->paginate($perPage); |
|
| 347 | - } |
|
| 348 | - |
|
| 349 | - return $model->orderBy($sortBy, $sort)->get(); |
|
| 350 | - } |
|
| 351 | - |
|
| 352 | - /** |
|
| 353 | - * Save the given data to the logged in user. |
|
| 354 | - * |
|
| 355 | - * @param array $data |
|
| 356 | - * @return void |
|
| 357 | - */ |
|
| 358 | - public function saveProfile($data) |
|
| 359 | - { |
|
| 360 | - if (Arr::has($data, 'profile_picture')) { |
|
| 361 | - $data['profile_picture'] = \Media::uploadImageBas64($data['profile_picture'], 'admins/profile_pictures'); |
|
| 362 | - } |
|
| 341 | + if (count($conditions['conditionValues'])) { |
|
| 342 | + $model->whereRaw($conditions['conditionString'], $conditions['conditionValues']); |
|
| 343 | + } |
|
| 344 | + |
|
| 345 | + if ($perPage) { |
|
| 346 | + return $model->orderBy($sortBy, $sort)->paginate($perPage); |
|
| 347 | + } |
|
| 348 | + |
|
| 349 | + return $model->orderBy($sortBy, $sort)->get(); |
|
| 350 | + } |
|
| 351 | + |
|
| 352 | + /** |
|
| 353 | + * Save the given data to the logged in user. |
|
| 354 | + * |
|
| 355 | + * @param array $data |
|
| 356 | + * @return void |
|
| 357 | + */ |
|
| 358 | + public function saveProfile($data) |
|
| 359 | + { |
|
| 360 | + if (Arr::has($data, 'profile_picture')) { |
|
| 361 | + $data['profile_picture'] = \Media::uploadImageBas64($data['profile_picture'], 'admins/profile_pictures'); |
|
| 362 | + } |
|
| 363 | 363 | |
| 364 | - $data['id'] = \Auth::id(); |
|
| 365 | - return $this->save($data); |
|
| 366 | - } |
|
| 367 | - |
|
| 368 | - /** |
|
| 369 | - * Ensure access token hasn't expired or revoked. |
|
| 370 | - * |
|
| 371 | - * @param string $accessToken |
|
| 372 | - * @return boolean |
|
| 373 | - */ |
|
| 374 | - public function accessTokenExpiredOrRevoked($accessToken) |
|
| 375 | - { |
|
| 376 | - $accessTokenId = json_decode($accessToken, true)['id']; |
|
| 377 | - $accessToken = \DB::table('oauth_access_tokens') |
|
| 378 | - ->where('id', $accessTokenId) |
|
| 379 | - ->first(); |
|
| 364 | + $data['id'] = \Auth::id(); |
|
| 365 | + return $this->save($data); |
|
| 366 | + } |
|
| 367 | + |
|
| 368 | + /** |
|
| 369 | + * Ensure access token hasn't expired or revoked. |
|
| 370 | + * |
|
| 371 | + * @param string $accessToken |
|
| 372 | + * @return boolean |
|
| 373 | + */ |
|
| 374 | + public function accessTokenExpiredOrRevoked($accessToken) |
|
| 375 | + { |
|
| 376 | + $accessTokenId = json_decode($accessToken, true)['id']; |
|
| 377 | + $accessToken = \DB::table('oauth_access_tokens') |
|
| 378 | + ->where('id', $accessTokenId) |
|
| 379 | + ->first(); |
|
| 380 | 380 | |
| 381 | - if (\Carbon\Carbon::parse($accessToken->expires_at)->isPast() || $accessToken->revoked) { |
|
| 382 | - return true; |
|
| 383 | - } |
|
| 384 | - |
|
| 385 | - return false; |
|
| 386 | - } |
|
| 387 | - |
|
| 388 | - /** |
|
| 389 | - * Revoke the given access token and all |
|
| 390 | - * associated refresh tokens. |
|
| 391 | - * |
|
| 392 | - * @param oject $accessToken |
|
| 393 | - * @return void |
|
| 394 | - */ |
|
| 395 | - public function revokeAccessToken($accessToken) |
|
| 396 | - { |
|
| 397 | - \DB::table('oauth_refresh_tokens') |
|
| 398 | - ->where('access_token_id', $accessToken->id) |
|
| 399 | - ->update([ |
|
| 400 | - 'revoked' => true |
|
| 401 | - ]); |
|
| 402 | - |
|
| 403 | - $accessToken->revoke(); |
|
| 404 | - } |
|
| 381 | + if (\Carbon\Carbon::parse($accessToken->expires_at)->isPast() || $accessToken->revoked) { |
|
| 382 | + return true; |
|
| 383 | + } |
|
| 384 | + |
|
| 385 | + return false; |
|
| 386 | + } |
|
| 387 | + |
|
| 388 | + /** |
|
| 389 | + * Revoke the given access token and all |
|
| 390 | + * associated refresh tokens. |
|
| 391 | + * |
|
| 392 | + * @param oject $accessToken |
|
| 393 | + * @return void |
|
| 394 | + */ |
|
| 395 | + public function revokeAccessToken($accessToken) |
|
| 396 | + { |
|
| 397 | + \DB::table('oauth_refresh_tokens') |
|
| 398 | + ->where('access_token_id', $accessToken->id) |
|
| 399 | + ->update([ |
|
| 400 | + 'revoked' => true |
|
| 401 | + ]); |
|
| 402 | + |
|
| 403 | + $accessToken->revoke(); |
|
| 404 | + } |
|
| 405 | 405 | } |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | $permissions = []; |
| 29 | 29 | $user = $this->find(\Auth::id(), $relations); |
| 30 | 30 | foreach ($user->roles()->get() as $role) { |
| 31 | - $role->permissions->each(function ($permission) use (&$permissions) { |
|
| 31 | + $role->permissions->each(function($permission) use (&$permissions) { |
|
| 32 | 32 | $permissions[$permission->model][$permission->id] = $permission->name; |
| 33 | 33 | }); |
| 34 | 34 | } |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | $user = $user ?: $this->find(\Auth::id(), ['roles.permissions']); |
| 52 | 52 | $permissions = []; |
| 53 | 53 | |
| 54 | - $user->roles->pluck('permissions')->each(function ($permission) use (&$permissions, $model) { |
|
| 54 | + $user->roles->pluck('permissions')->each(function($permission) use (&$permissions, $model) { |
|
| 55 | 55 | $permissions = array_merge($permissions, $permission->where('model', $model)->pluck('name')->toArray()); |
| 56 | 56 | }); |
| 57 | 57 | |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | */ |
| 81 | 81 | public function assignRoles($userId, $roleIds) |
| 82 | 82 | { |
| 83 | - \DB::transaction(function () use ($userId, $roleIds) { |
|
| 83 | + \DB::transaction(function() use ($userId, $roleIds) { |
|
| 84 | 84 | $user = $this->find($userId); |
| 85 | 85 | $user->roles()->detach(); |
| 86 | 86 | $user->roles()->attach($roleIds); |
@@ -99,15 +99,15 @@ discard block |
||
| 99 | 99 | */ |
| 100 | 100 | public function login($credentials, $adminLogin = false) |
| 101 | 101 | { |
| 102 | - if (! $user = $this->first(['email' => $credentials['email']])) { |
|
| 102 | + if ( ! $user = $this->first(['email' => $credentials['email']])) { |
|
| 103 | 103 | \ErrorHandler::loginFailed(); |
| 104 | 104 | } elseif ($adminLogin && ! $user->roles->whereIn('name', ['Admin'])->count()) { |
| 105 | 105 | \ErrorHandler::loginFailed(); |
| 106 | - } elseif (! $adminLogin && $user->roles->whereIn('name', ['Admin'])->count()) { |
|
| 106 | + } elseif ( ! $adminLogin && $user->roles->whereIn('name', ['Admin'])->count()) { |
|
| 107 | 107 | \ErrorHandler::loginFailed(); |
| 108 | 108 | } elseif ($user->blocked) { |
| 109 | 109 | \ErrorHandler::userIsBlocked(); |
| 110 | - } elseif (! config('skeleton.disable_confirm_email') && ! $user->confirmed) { |
|
| 110 | + } elseif ( ! config('skeleton.disable_confirm_email') && ! $user->confirmed) { |
|
| 111 | 111 | \ErrorHandler::emailNotConfirmed(); |
| 112 | 112 | } |
| 113 | 113 | |
@@ -127,11 +127,11 @@ discard block |
||
| 127 | 127 | $access_token = $authCode ? Arr::get(\Socialite::driver($type)->getAccessTokenResponse($authCode), 'access_token') : $accessToken; |
| 128 | 128 | $user = \Socialite::driver($type)->userFromToken($access_token); |
| 129 | 129 | |
| 130 | - if (! $user->email) { |
|
| 130 | + if ( ! $user->email) { |
|
| 131 | 131 | \ErrorHandler::noSocialEmail(); |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - if (! $this->model->where('email', $user->email)->first()) { |
|
| 134 | + if ( ! $this->model->where('email', $user->email)->first()) { |
|
| 135 | 135 | $this->register(['email' => $user->email, 'password' => ''], true); |
| 136 | 136 | } |
| 137 | 137 | |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | if ($skipConfirmEmail) { |
| 154 | 154 | $user->confirmed = 1; |
| 155 | 155 | $user->save(); |
| 156 | - } elseif (! config('skeleton.disable_confirm_email')) { |
|
| 156 | + } elseif ( ! config('skeleton.disable_confirm_email')) { |
|
| 157 | 157 | $this->sendConfirmationEmail($user->email); |
| 158 | 158 | } |
| 159 | 159 | |
@@ -168,10 +168,10 @@ discard block |
||
| 168 | 168 | */ |
| 169 | 169 | public function block($userId) |
| 170 | 170 | { |
| 171 | - if (! $user = $this->find($userId)) { |
|
| 171 | + if ( ! $user = $this->find($userId)) { |
|
| 172 | 172 | \ErrorHandler::notFound('user'); |
| 173 | 173 | } |
| 174 | - if (! $this->hasRole(['Admin'])) { |
|
| 174 | + if ( ! $this->hasRole(['Admin'])) { |
|
| 175 | 175 | \ErrorHandler::noPermissions(); |
| 176 | 176 | } elseif (\Auth::id() == $userId) { |
| 177 | 177 | \ErrorHandler::noPermissions(); |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | */ |
| 194 | 194 | public function unblock($userId) |
| 195 | 195 | { |
| 196 | - if (! $this->hasRole(['Admin'])) { |
|
| 196 | + if ( ! $this->hasRole(['Admin'])) { |
|
| 197 | 197 | \ErrorHandler::noPermissions(); |
| 198 | 198 | } |
| 199 | 199 | |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | */ |
| 213 | 213 | public function sendReset($email) |
| 214 | 214 | { |
| 215 | - if (! $user = $this->model->where('email', $email)->first()) { |
|
| 215 | + if ( ! $user = $this->model->where('email', $email)->first()) { |
|
| 216 | 216 | \ErrorHandler::notFound('email'); |
| 217 | 217 | } |
| 218 | 218 | |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | 'password' => $password, |
| 237 | 237 | 'password_confirmation' => $passwordConfirmation, |
| 238 | 238 | 'token' => $token |
| 239 | - ], function ($user, $password) { |
|
| 239 | + ], function($user, $password) { |
|
| 240 | 240 | $user->password = $password; |
| 241 | 241 | $user->save(); |
| 242 | 242 | }); |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | public function changePassword($password, $oldPassword) |
| 273 | 273 | { |
| 274 | 274 | $user = \Auth::user(); |
| 275 | - if (! \Hash::check($oldPassword, $user->password)) { |
|
| 275 | + if ( ! \Hash::check($oldPassword, $user->password)) { |
|
| 276 | 276 | \ErrorHandler::invalidOldPassword(); |
| 277 | 277 | } |
| 278 | 278 | |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | */ |
| 289 | 289 | public function confirmEmail($confirmationCode) |
| 290 | 290 | { |
| 291 | - if (! $user = $this->first(['confirmation_code' => $confirmationCode])) { |
|
| 291 | + if ( ! $user = $this->first(['confirmation_code' => $confirmationCode])) { |
|
| 292 | 292 | \ErrorHandler::invalidConfirmationCode(); |
| 293 | 293 | } |
| 294 | 294 | |
@@ -333,7 +333,7 @@ discard block |
||
| 333 | 333 | $sort = $desc ? 'desc' : 'asc'; |
| 334 | 334 | $model = $this->model->with($relations); |
| 335 | 335 | |
| 336 | - $model->whereHas('roles', function ($q) use ($roleName) { |
|
| 336 | + $model->whereHas('roles', function($q) use ($roleName) { |
|
| 337 | 337 | $q->where('name', $roleName); |
| 338 | 338 | }); |
| 339 | 339 | |
@@ -1,7 +1,5 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -use Illuminate\Http\Request; |
|
| 4 | - |
|
| 5 | 3 | /* |
| 6 | 4 | |-------------------------------------------------------------------------- |
| 7 | 5 | | API Routes |
@@ -15,31 +15,31 @@ |
||
| 15 | 15 | |
| 16 | 16 | Route::group(['prefix' => 'users'], function () { |
| 17 | 17 | |
| 18 | - Route::get('/', 'UserController@index'); |
|
| 19 | - Route::get('/{id}', 'UserController@find'); |
|
| 20 | - Route::post('/', 'UserController@insert'); |
|
| 21 | - Route::put('/', 'UserController@update'); |
|
| 22 | - Route::delete('/{id}', 'UserController@delete'); |
|
| 23 | - Route::get('list/deleted', 'UserController@deleted'); |
|
| 24 | - Route::patch('restore/{id}', 'UserController@restore'); |
|
| 25 | - Route::get('block/{id}', 'UserController@block'); |
|
| 26 | - Route::get('unblock/{id}', 'UserController@unblock'); |
|
| 27 | - Route::post('assign/roles', 'UserController@assignRoles'); |
|
| 28 | - Route::post('role/{roleName}', 'UserController@role'); |
|
| 18 | + Route::get('/', 'UserController@index'); |
|
| 19 | + Route::get('/{id}', 'UserController@find'); |
|
| 20 | + Route::post('/', 'UserController@insert'); |
|
| 21 | + Route::put('/', 'UserController@update'); |
|
| 22 | + Route::delete('/{id}', 'UserController@delete'); |
|
| 23 | + Route::get('list/deleted', 'UserController@deleted'); |
|
| 24 | + Route::patch('restore/{id}', 'UserController@restore'); |
|
| 25 | + Route::get('block/{id}', 'UserController@block'); |
|
| 26 | + Route::get('unblock/{id}', 'UserController@unblock'); |
|
| 27 | + Route::post('assign/roles', 'UserController@assignRoles'); |
|
| 28 | + Route::post('role/{roleName}', 'UserController@role'); |
|
| 29 | 29 | |
| 30 | - Route::group(['prefix' => 'account'], function () { |
|
| 30 | + Route::group(['prefix' => 'account'], function () { |
|
| 31 | 31 | |
| 32 | - Route::get('my', 'UserController@account'); |
|
| 33 | - Route::get('logout', 'UserController@logout'); |
|
| 34 | - Route::post('refresh/token', 'UserController@refreshToken'); |
|
| 35 | - Route::post('save', 'UserController@saveProfile'); |
|
| 36 | - Route::post('register', 'UserController@register'); |
|
| 37 | - Route::post('login', 'UserController@login'); |
|
| 38 | - Route::post('login/social', 'UserController@loginSocial'); |
|
| 39 | - Route::post('send/reset', 'UserController@sendReset'); |
|
| 40 | - Route::post('reset/password', 'UserController@resetPassword'); |
|
| 41 | - Route::post('change/password', 'UserController@changePassword'); |
|
| 42 | - Route::post('confirm/email', 'UserController@confirmEmail'); |
|
| 43 | - Route::post('resend/email/confirmation', 'UserController@resendEmailConfirmation'); |
|
| 44 | - }); |
|
| 32 | + Route::get('my', 'UserController@account'); |
|
| 33 | + Route::get('logout', 'UserController@logout'); |
|
| 34 | + Route::post('refresh/token', 'UserController@refreshToken'); |
|
| 35 | + Route::post('save', 'UserController@saveProfile'); |
|
| 36 | + Route::post('register', 'UserController@register'); |
|
| 37 | + Route::post('login', 'UserController@login'); |
|
| 38 | + Route::post('login/social', 'UserController@loginSocial'); |
|
| 39 | + Route::post('send/reset', 'UserController@sendReset'); |
|
| 40 | + Route::post('reset/password', 'UserController@resetPassword'); |
|
| 41 | + Route::post('change/password', 'UserController@changePassword'); |
|
| 42 | + Route::post('confirm/email', 'UserController@confirmEmail'); |
|
| 43 | + Route::post('resend/email/confirmation', 'UserController@resendEmailConfirmation'); |
|
| 44 | + }); |
|
| 45 | 45 | }); |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | | |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -Route::group(['prefix' => 'users'], function () { |
|
| 16 | +Route::group(['prefix' => 'users'], function() { |
|
| 17 | 17 | |
| 18 | 18 | Route::get('/', 'UserController@index'); |
| 19 | 19 | Route::get('/{id}', 'UserController@find'); |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | Route::post('assign/roles', 'UserController@assignRoles'); |
| 28 | 28 | Route::post('role/{roleName}', 'UserController@role'); |
| 29 | 29 | |
| 30 | - Route::group(['prefix' => 'account'], function () { |
|
| 30 | + Route::group(['prefix' => 'account'], function() { |
|
| 31 | 31 | |
| 32 | 32 | Route::get('my', 'UserController@account'); |
| 33 | 33 | Route::get('logout', 'UserController@logout'); |
@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | return [ |
| 4 | 4 | |
| 5 | - /* |
|
| 5 | + /* |
|
| 6 | 6 | |-------------------------------------------------------------------------- |
| 7 | 7 | | Authentication Defaults |
| 8 | 8 | |-------------------------------------------------------------------------- |
@@ -13,12 +13,12 @@ discard block |
||
| 13 | 13 | | |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | - 'defaults' => [ |
|
| 17 | - 'guard' => 'web', |
|
| 18 | - 'passwords' => 'users', |
|
| 19 | - ], |
|
| 16 | + 'defaults' => [ |
|
| 17 | + 'guard' => 'web', |
|
| 18 | + 'passwords' => 'users', |
|
| 19 | + ], |
|
| 20 | 20 | |
| 21 | - /* |
|
| 21 | + /* |
|
| 22 | 22 | |-------------------------------------------------------------------------- |
| 23 | 23 | | Authentication Guards |
| 24 | 24 | |-------------------------------------------------------------------------- |
@@ -35,19 +35,19 @@ discard block |
||
| 35 | 35 | | |
| 36 | 36 | */ |
| 37 | 37 | |
| 38 | - 'guards' => [ |
|
| 39 | - 'web' => [ |
|
| 40 | - 'driver' => 'session', |
|
| 41 | - 'provider' => 'users', |
|
| 42 | - ], |
|
| 38 | + 'guards' => [ |
|
| 39 | + 'web' => [ |
|
| 40 | + 'driver' => 'session', |
|
| 41 | + 'provider' => 'users', |
|
| 42 | + ], |
|
| 43 | 43 | |
| 44 | - 'api' => [ |
|
| 45 | - 'driver' => 'passport', |
|
| 46 | - 'provider' => 'users', |
|
| 47 | - ], |
|
| 48 | - ], |
|
| 44 | + 'api' => [ |
|
| 45 | + 'driver' => 'passport', |
|
| 46 | + 'provider' => 'users', |
|
| 47 | + ], |
|
| 48 | + ], |
|
| 49 | 49 | |
| 50 | - /* |
|
| 50 | + /* |
|
| 51 | 51 | |-------------------------------------------------------------------------- |
| 52 | 52 | | User Providers |
| 53 | 53 | |-------------------------------------------------------------------------- |
@@ -64,19 +64,19 @@ discard block |
||
| 64 | 64 | | |
| 65 | 65 | */ |
| 66 | 66 | |
| 67 | - 'providers' => [ |
|
| 68 | - 'users' => [ |
|
| 69 | - 'driver' => 'eloquent', |
|
| 70 | - 'model' => App\Modules\Users\AclUser::class, |
|
| 71 | - ], |
|
| 67 | + 'providers' => [ |
|
| 68 | + 'users' => [ |
|
| 69 | + 'driver' => 'eloquent', |
|
| 70 | + 'model' => App\Modules\Users\AclUser::class, |
|
| 71 | + ], |
|
| 72 | 72 | |
| 73 | - // 'users' => [ |
|
| 74 | - // 'driver' => 'database', |
|
| 75 | - // 'table' => 'users', |
|
| 76 | - // ], |
|
| 77 | - ], |
|
| 73 | + // 'users' => [ |
|
| 74 | + // 'driver' => 'database', |
|
| 75 | + // 'table' => 'users', |
|
| 76 | + // ], |
|
| 77 | + ], |
|
| 78 | 78 | |
| 79 | - /* |
|
| 79 | + /* |
|
| 80 | 80 | |-------------------------------------------------------------------------- |
| 81 | 81 | | Resetting Passwords |
| 82 | 82 | |-------------------------------------------------------------------------- |
@@ -91,12 +91,12 @@ discard block |
||
| 91 | 91 | | |
| 92 | 92 | */ |
| 93 | 93 | |
| 94 | - 'passwords' => [ |
|
| 95 | - 'users' => [ |
|
| 96 | - 'provider' => 'users', |
|
| 97 | - 'table' => 'password_resets', |
|
| 98 | - 'expire' => 60, |
|
| 99 | - ], |
|
| 100 | - ], |
|
| 94 | + 'passwords' => [ |
|
| 95 | + 'users' => [ |
|
| 96 | + 'provider' => 'users', |
|
| 97 | + 'table' => 'password_resets', |
|
| 98 | + 'expire' => 60, |
|
| 99 | + ], |
|
| 100 | + ], |
|
| 101 | 101 | |
| 102 | 102 | ]; |
@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | return [ |
| 4 | 4 | |
| 5 | - /* |
|
| 5 | + /* |
|
| 6 | 6 | |-------------------------------------------------------------------------- |
| 7 | 7 | | Disable Confirm Email |
| 8 | 8 | |-------------------------------------------------------------------------- |
@@ -11,9 +11,9 @@ discard block |
||
| 11 | 11 | | |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | - 'disable_confirm_email' => env('DISABLE_CONFIRM_EMAIL', false), |
|
| 14 | + 'disable_confirm_email' => env('DISABLE_CONFIRM_EMAIL', false), |
|
| 15 | 15 | |
| 16 | - /* |
|
| 16 | + /* |
|
| 17 | 17 | |-------------------------------------------------------------------------- |
| 18 | 18 | | Confirm Email URL |
| 19 | 19 | |-------------------------------------------------------------------------- |
@@ -22,9 +22,9 @@ discard block |
||
| 22 | 22 | | |
| 23 | 23 | */ |
| 24 | 24 | |
| 25 | - 'confrim_email_url' => env('CONFIRM_EMAIL_URL'), |
|
| 25 | + 'confrim_email_url' => env('CONFIRM_EMAIL_URL'), |
|
| 26 | 26 | |
| 27 | - /* |
|
| 27 | + /* |
|
| 28 | 28 | |-------------------------------------------------------------------------- |
| 29 | 29 | | Reset Password URL |
| 30 | 30 | |-------------------------------------------------------------------------- |
@@ -33,9 +33,9 @@ discard block |
||
| 33 | 33 | | |
| 34 | 34 | */ |
| 35 | 35 | |
| 36 | - 'reset_password_url' => env('RESET_PASSWORD_URL'), |
|
| 36 | + 'reset_password_url' => env('RESET_PASSWORD_URL'), |
|
| 37 | 37 | |
| 38 | - /* |
|
| 38 | + /* |
|
| 39 | 39 | |-------------------------------------------------------------------------- |
| 40 | 40 | | Passport Client Id |
| 41 | 41 | |-------------------------------------------------------------------------- |
@@ -44,9 +44,9 @@ discard block |
||
| 44 | 44 | | |
| 45 | 45 | */ |
| 46 | 46 | |
| 47 | - 'passport_client_id' => env('PASSWORD_CLIENT_ID'), |
|
| 47 | + 'passport_client_id' => env('PASSWORD_CLIENT_ID'), |
|
| 48 | 48 | |
| 49 | - /* |
|
| 49 | + /* |
|
| 50 | 50 | |-------------------------------------------------------------------------- |
| 51 | 51 | | Passport Client Secret |
| 52 | 52 | |-------------------------------------------------------------------------- |
@@ -55,9 +55,9 @@ discard block |
||
| 55 | 55 | | |
| 56 | 56 | */ |
| 57 | 57 | |
| 58 | - 'passport_client_secret' => env('PASSWORD_CLIENT_SECRET'), |
|
| 58 | + 'passport_client_secret' => env('PASSWORD_CLIENT_SECRET'), |
|
| 59 | 59 | |
| 60 | - /* |
|
| 60 | + /* |
|
| 61 | 61 | |-------------------------------------------------------------------------- |
| 62 | 62 | | Social Pass |
| 63 | 63 | |-------------------------------------------------------------------------- |
@@ -66,9 +66,9 @@ discard block |
||
| 66 | 66 | | |
| 67 | 67 | */ |
| 68 | 68 | |
| 69 | - 'social_pass' => env('SOCIAL_PASS', false), |
|
| 69 | + 'social_pass' => env('SOCIAL_PASS', false), |
|
| 70 | 70 | |
| 71 | - /* |
|
| 71 | + /* |
|
| 72 | 72 | |-------------------------------------------------------------------------- |
| 73 | 73 | | Relations Between Models |
| 74 | 74 | |-------------------------------------------------------------------------- |
@@ -77,88 +77,88 @@ discard block |
||
| 77 | 77 | | |
| 78 | 78 | */ |
| 79 | 79 | |
| 80 | - 'relations' => [ |
|
| 81 | - 'user' => [ |
|
| 82 | - 'list' => [], |
|
| 83 | - 'find' => [], |
|
| 84 | - 'findby' => [], |
|
| 85 | - 'paginate' => [], |
|
| 86 | - 'paginateby' => [], |
|
| 87 | - 'first' => [], |
|
| 88 | - 'search' => [], |
|
| 89 | - 'account' => [], |
|
| 90 | - 'group' => [], |
|
| 91 | - 'deleted' => [], |
|
| 92 | - ], |
|
| 93 | - 'permission' => [ |
|
| 94 | - 'list' => [], |
|
| 95 | - 'find' => [], |
|
| 96 | - 'findby' => [], |
|
| 97 | - 'paginate' => [], |
|
| 98 | - 'paginateby' => [], |
|
| 99 | - 'first' => [], |
|
| 100 | - 'search' => [], |
|
| 101 | - 'deleted' => [], |
|
| 102 | - ], |
|
| 103 | - 'group' => [ |
|
| 104 | - 'list' => [], |
|
| 105 | - 'find' => [], |
|
| 106 | - 'findby' => [], |
|
| 107 | - 'paginate' => [], |
|
| 108 | - 'paginateby' => [], |
|
| 109 | - 'first' => [], |
|
| 110 | - 'search' => [], |
|
| 111 | - 'deleted' => [], |
|
| 112 | - ], |
|
| 113 | - 'oauthClient' => [ |
|
| 114 | - 'list' => [], |
|
| 115 | - 'find' => [], |
|
| 116 | - 'findby' => [], |
|
| 117 | - 'paginate' => [], |
|
| 118 | - 'paginateby' => [], |
|
| 119 | - 'first' => [], |
|
| 120 | - 'search' => [], |
|
| 121 | - 'account' => [], |
|
| 122 | - 'group' => [], |
|
| 123 | - 'deleted' => [], |
|
| 124 | - ], |
|
| 125 | - 'notification' => [ |
|
| 126 | - 'list' => [], |
|
| 127 | - 'unread' => [], |
|
| 128 | - ], |
|
| 129 | - 'pushNotificationDevice' => [ |
|
| 130 | - 'list' => [], |
|
| 131 | - 'find' => [], |
|
| 132 | - 'findby' => [], |
|
| 133 | - 'paginate' => [], |
|
| 134 | - 'paginateby' => [], |
|
| 135 | - 'first' => [], |
|
| 136 | - 'search' => [], |
|
| 137 | - 'deleted' => [], |
|
| 138 | - ], |
|
| 139 | - 'report' => [ |
|
| 140 | - 'list' => [], |
|
| 141 | - 'find' => [], |
|
| 142 | - 'findby' => [], |
|
| 143 | - 'paginate' => [], |
|
| 144 | - 'paginateby' => [], |
|
| 145 | - 'first' => [], |
|
| 146 | - 'search' => [], |
|
| 147 | - 'deleted' => [], |
|
| 148 | - ], |
|
| 149 | - 'setting' => [ |
|
| 150 | - 'list' => [], |
|
| 151 | - 'find' => [], |
|
| 152 | - 'findby' => [], |
|
| 153 | - 'paginate' => [], |
|
| 154 | - 'paginateby' => [], |
|
| 155 | - 'first' => [], |
|
| 156 | - 'search' => [], |
|
| 157 | - 'deleted' => [], |
|
| 158 | - ] |
|
| 159 | - ], |
|
| 80 | + 'relations' => [ |
|
| 81 | + 'user' => [ |
|
| 82 | + 'list' => [], |
|
| 83 | + 'find' => [], |
|
| 84 | + 'findby' => [], |
|
| 85 | + 'paginate' => [], |
|
| 86 | + 'paginateby' => [], |
|
| 87 | + 'first' => [], |
|
| 88 | + 'search' => [], |
|
| 89 | + 'account' => [], |
|
| 90 | + 'group' => [], |
|
| 91 | + 'deleted' => [], |
|
| 92 | + ], |
|
| 93 | + 'permission' => [ |
|
| 94 | + 'list' => [], |
|
| 95 | + 'find' => [], |
|
| 96 | + 'findby' => [], |
|
| 97 | + 'paginate' => [], |
|
| 98 | + 'paginateby' => [], |
|
| 99 | + 'first' => [], |
|
| 100 | + 'search' => [], |
|
| 101 | + 'deleted' => [], |
|
| 102 | + ], |
|
| 103 | + 'group' => [ |
|
| 104 | + 'list' => [], |
|
| 105 | + 'find' => [], |
|
| 106 | + 'findby' => [], |
|
| 107 | + 'paginate' => [], |
|
| 108 | + 'paginateby' => [], |
|
| 109 | + 'first' => [], |
|
| 110 | + 'search' => [], |
|
| 111 | + 'deleted' => [], |
|
| 112 | + ], |
|
| 113 | + 'oauthClient' => [ |
|
| 114 | + 'list' => [], |
|
| 115 | + 'find' => [], |
|
| 116 | + 'findby' => [], |
|
| 117 | + 'paginate' => [], |
|
| 118 | + 'paginateby' => [], |
|
| 119 | + 'first' => [], |
|
| 120 | + 'search' => [], |
|
| 121 | + 'account' => [], |
|
| 122 | + 'group' => [], |
|
| 123 | + 'deleted' => [], |
|
| 124 | + ], |
|
| 125 | + 'notification' => [ |
|
| 126 | + 'list' => [], |
|
| 127 | + 'unread' => [], |
|
| 128 | + ], |
|
| 129 | + 'pushNotificationDevice' => [ |
|
| 130 | + 'list' => [], |
|
| 131 | + 'find' => [], |
|
| 132 | + 'findby' => [], |
|
| 133 | + 'paginate' => [], |
|
| 134 | + 'paginateby' => [], |
|
| 135 | + 'first' => [], |
|
| 136 | + 'search' => [], |
|
| 137 | + 'deleted' => [], |
|
| 138 | + ], |
|
| 139 | + 'report' => [ |
|
| 140 | + 'list' => [], |
|
| 141 | + 'find' => [], |
|
| 142 | + 'findby' => [], |
|
| 143 | + 'paginate' => [], |
|
| 144 | + 'paginateby' => [], |
|
| 145 | + 'first' => [], |
|
| 146 | + 'search' => [], |
|
| 147 | + 'deleted' => [], |
|
| 148 | + ], |
|
| 149 | + 'setting' => [ |
|
| 150 | + 'list' => [], |
|
| 151 | + 'find' => [], |
|
| 152 | + 'findby' => [], |
|
| 153 | + 'paginate' => [], |
|
| 154 | + 'paginateby' => [], |
|
| 155 | + 'first' => [], |
|
| 156 | + 'search' => [], |
|
| 157 | + 'deleted' => [], |
|
| 158 | + ] |
|
| 159 | + ], |
|
| 160 | 160 | |
| 161 | - /* |
|
| 161 | + /* |
|
| 162 | 162 | |-------------------------------------------------------------------------- |
| 163 | 163 | | Cache Configurations |
| 164 | 164 | |-------------------------------------------------------------------------- |
@@ -167,46 +167,46 @@ discard block |
||
| 167 | 167 | | |
| 168 | 168 | */ |
| 169 | 169 | |
| 170 | - 'cache_config' => [ |
|
| 171 | - 'oauthClient' => [ |
|
| 172 | - 'cache' => [ |
|
| 173 | - 'all', |
|
| 174 | - 'find', |
|
| 175 | - 'findBy', |
|
| 176 | - 'paginate', |
|
| 177 | - 'paginateBy', |
|
| 178 | - 'first', |
|
| 179 | - 'search', |
|
| 180 | - 'deleted' |
|
| 181 | - ], |
|
| 182 | - 'clear' => [ |
|
| 183 | - 'update' => ['oauthClients', 'users', 'groups'], |
|
| 184 | - 'save' => ['oauthClients', 'users', 'groups'], |
|
| 185 | - 'delete' => ['oauthClients', 'users', 'groups'], |
|
| 186 | - 'restore' => ['oauthClients', 'users', 'groups'], |
|
| 187 | - 'revoke' => ['oauthClients', 'users', 'groups'], |
|
| 188 | - 'ubRevoke' => ['oauthClients', 'users', 'groups'], |
|
| 189 | - 'regenerateSecret' => ['oauthClients', 'users', 'groups'], |
|
| 190 | - ], |
|
| 191 | - ], |
|
| 192 | - 'setting' => [ |
|
| 193 | - 'cache' => [ |
|
| 194 | - 'all', |
|
| 195 | - 'find', |
|
| 196 | - 'findBy', |
|
| 197 | - 'paginate', |
|
| 198 | - 'paginateBy', |
|
| 199 | - 'first', |
|
| 200 | - 'search', |
|
| 201 | - 'deleted' |
|
| 202 | - ], |
|
| 203 | - 'clear' => [ |
|
| 204 | - 'update' => ['settings'], |
|
| 205 | - 'save' => ['settings'], |
|
| 206 | - 'delete' => ['settings'], |
|
| 207 | - 'restore' => ['settings'], |
|
| 208 | - 'saveMany' => ['settings'], |
|
| 209 | - ] |
|
| 210 | - ] |
|
| 211 | - ] |
|
| 170 | + 'cache_config' => [ |
|
| 171 | + 'oauthClient' => [ |
|
| 172 | + 'cache' => [ |
|
| 173 | + 'all', |
|
| 174 | + 'find', |
|
| 175 | + 'findBy', |
|
| 176 | + 'paginate', |
|
| 177 | + 'paginateBy', |
|
| 178 | + 'first', |
|
| 179 | + 'search', |
|
| 180 | + 'deleted' |
|
| 181 | + ], |
|
| 182 | + 'clear' => [ |
|
| 183 | + 'update' => ['oauthClients', 'users', 'groups'], |
|
| 184 | + 'save' => ['oauthClients', 'users', 'groups'], |
|
| 185 | + 'delete' => ['oauthClients', 'users', 'groups'], |
|
| 186 | + 'restore' => ['oauthClients', 'users', 'groups'], |
|
| 187 | + 'revoke' => ['oauthClients', 'users', 'groups'], |
|
| 188 | + 'ubRevoke' => ['oauthClients', 'users', 'groups'], |
|
| 189 | + 'regenerateSecret' => ['oauthClients', 'users', 'groups'], |
|
| 190 | + ], |
|
| 191 | + ], |
|
| 192 | + 'setting' => [ |
|
| 193 | + 'cache' => [ |
|
| 194 | + 'all', |
|
| 195 | + 'find', |
|
| 196 | + 'findBy', |
|
| 197 | + 'paginate', |
|
| 198 | + 'paginateBy', |
|
| 199 | + 'first', |
|
| 200 | + 'search', |
|
| 201 | + 'deleted' |
|
| 202 | + ], |
|
| 203 | + 'clear' => [ |
|
| 204 | + 'update' => ['settings'], |
|
| 205 | + 'save' => ['settings'], |
|
| 206 | + 'delete' => ['settings'], |
|
| 207 | + 'restore' => ['settings'], |
|
| 208 | + 'saveMany' => ['settings'], |
|
| 209 | + ] |
|
| 210 | + ] |
|
| 211 | + ] |
|
| 212 | 212 | ]; |
@@ -6,62 +6,62 @@ |
||
| 6 | 6 | class AclUserObserver |
| 7 | 7 | { |
| 8 | 8 | |
| 9 | - public function saving($model) |
|
| 10 | - { |
|
| 11 | - if ($model->isDirty('profile_picture')) { |
|
| 12 | - \Media::deleteImage($model->getOriginal('profile_picture')); |
|
| 13 | - } |
|
| 14 | - } |
|
| 9 | + public function saving($model) |
|
| 10 | + { |
|
| 11 | + if ($model->isDirty('profile_picture')) { |
|
| 12 | + \Media::deleteImage($model->getOriginal('profile_picture')); |
|
| 13 | + } |
|
| 14 | + } |
|
| 15 | 15 | |
| 16 | - public function saved($model) |
|
| 17 | - { |
|
| 18 | - // |
|
| 19 | - } |
|
| 16 | + public function saved($model) |
|
| 17 | + { |
|
| 18 | + // |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | - public function creating($model) |
|
| 22 | - { |
|
| 23 | - // |
|
| 24 | - } |
|
| 21 | + public function creating($model) |
|
| 22 | + { |
|
| 23 | + // |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | - public function created($model) |
|
| 27 | - { |
|
| 28 | - // |
|
| 29 | - } |
|
| 26 | + public function created($model) |
|
| 27 | + { |
|
| 28 | + // |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - public function updating($model) |
|
| 32 | - { |
|
| 33 | - // |
|
| 34 | - } |
|
| 31 | + public function updating($model) |
|
| 32 | + { |
|
| 33 | + // |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - public function updated($model) |
|
| 37 | - { |
|
| 38 | - if ($model->isDirty('blocked') && $model->blocked) { |
|
| 39 | - $model->tokens()->each(function ($token) { |
|
| 36 | + public function updated($model) |
|
| 37 | + { |
|
| 38 | + if ($model->isDirty('blocked') && $model->blocked) { |
|
| 39 | + $model->tokens()->each(function ($token) { |
|
| 40 | 40 | |
| 41 | - \Core::users()->revokeAccessToken($token); |
|
| 42 | - }); |
|
| 43 | - } |
|
| 44 | - } |
|
| 41 | + \Core::users()->revokeAccessToken($token); |
|
| 42 | + }); |
|
| 43 | + } |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - public function deleting($model) |
|
| 47 | - { |
|
| 48 | - if ($model->getOriginal('id') == \Auth::id()) { |
|
| 49 | - \ErrorHandler::noPermissions(); |
|
| 50 | - } |
|
| 51 | - } |
|
| 46 | + public function deleting($model) |
|
| 47 | + { |
|
| 48 | + if ($model->getOriginal('id') == \Auth::id()) { |
|
| 49 | + \ErrorHandler::noPermissions(); |
|
| 50 | + } |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - public function deleted($model) |
|
| 54 | - { |
|
| 55 | - // |
|
| 56 | - } |
|
| 53 | + public function deleted($model) |
|
| 54 | + { |
|
| 55 | + // |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - public function restoring($model) |
|
| 59 | - { |
|
| 60 | - // |
|
| 61 | - } |
|
| 58 | + public function restoring($model) |
|
| 59 | + { |
|
| 60 | + // |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - public function restored($model) |
|
| 64 | - { |
|
| 65 | - // |
|
| 66 | - } |
|
| 63 | + public function restored($model) |
|
| 64 | + { |
|
| 65 | + // |
|
| 66 | + } |
|
| 67 | 67 | } |
@@ -36,7 +36,7 @@ |
||
| 36 | 36 | public function updated($model) |
| 37 | 37 | { |
| 38 | 38 | if ($model->isDirty('blocked') && $model->blocked) { |
| 39 | - $model->tokens()->each(function ($token) { |
|
| 39 | + $model->tokens()->each(function($token) { |
|
| 40 | 40 | |
| 41 | 41 | \Core::users()->revokeAccessToken($token); |
| 42 | 42 | }); |
@@ -6,27 +6,27 @@ |
||
| 6 | 6 | |
| 7 | 7 | class ModuleServiceProvider extends ServiceProvider |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * Bootstrap the module services. |
|
| 11 | - * |
|
| 12 | - * @return void |
|
| 13 | - */ |
|
| 14 | - public function boot() |
|
| 15 | - { |
|
| 16 | - $this->loadTranslationsFrom(__DIR__.'/../Resources/Lang', 'users'); |
|
| 17 | - $this->loadViewsFrom(__DIR__.'/../Resources/Views', 'users'); |
|
| 9 | + /** |
|
| 10 | + * Bootstrap the module services. |
|
| 11 | + * |
|
| 12 | + * @return void |
|
| 13 | + */ |
|
| 14 | + public function boot() |
|
| 15 | + { |
|
| 16 | + $this->loadTranslationsFrom(__DIR__.'/../Resources/Lang', 'users'); |
|
| 17 | + $this->loadViewsFrom(__DIR__.'/../Resources/Views', 'users'); |
|
| 18 | 18 | |
| 19 | - $this->loadMigrationsFrom(module_path('users', 'Database/Migrations', 'app')); |
|
| 20 | - $this->loadFactoriesFrom(module_path('users', 'Database/Factories', 'app')); |
|
| 21 | - } |
|
| 19 | + $this->loadMigrationsFrom(module_path('users', 'Database/Migrations', 'app')); |
|
| 20 | + $this->loadFactoriesFrom(module_path('users', 'Database/Factories', 'app')); |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * Register the module services. |
|
| 25 | - * |
|
| 26 | - * @return void |
|
| 27 | - */ |
|
| 28 | - public function register() |
|
| 29 | - { |
|
| 30 | - $this->app->register(RouteServiceProvider::class); |
|
| 31 | - } |
|
| 23 | + /** |
|
| 24 | + * Register the module services. |
|
| 25 | + * |
|
| 26 | + * @return void |
|
| 27 | + */ |
|
| 28 | + public function register() |
|
| 29 | + { |
|
| 30 | + $this->app->register(RouteServiceProvider::class); |
|
| 31 | + } |
|
| 32 | 32 | } |
@@ -7,73 +7,73 @@ |
||
| 7 | 7 | |
| 8 | 8 | class RouteServiceProvider extends ServiceProvider |
| 9 | 9 | { |
| 10 | - /** |
|
| 11 | - * This namespace is applied to your controller routes. |
|
| 12 | - * |
|
| 13 | - * In addition, it is set as the URL generator's root namespace. |
|
| 14 | - * |
|
| 15 | - * @var string |
|
| 16 | - */ |
|
| 17 | - protected $namespace = 'App\Modules\Users\Http\Controllers'; |
|
| 10 | + /** |
|
| 11 | + * This namespace is applied to your controller routes. |
|
| 12 | + * |
|
| 13 | + * In addition, it is set as the URL generator's root namespace. |
|
| 14 | + * |
|
| 15 | + * @var string |
|
| 16 | + */ |
|
| 17 | + protected $namespace = 'App\Modules\Users\Http\Controllers'; |
|
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Define your route model bindings, pattern filters, etc. |
|
| 21 | - * |
|
| 22 | - * @return void |
|
| 23 | - */ |
|
| 24 | - public function boot() |
|
| 25 | - { |
|
| 26 | - // |
|
| 19 | + /** |
|
| 20 | + * Define your route model bindings, pattern filters, etc. |
|
| 21 | + * |
|
| 22 | + * @return void |
|
| 23 | + */ |
|
| 24 | + public function boot() |
|
| 25 | + { |
|
| 26 | + // |
|
| 27 | 27 | |
| 28 | - parent::boot(); |
|
| 29 | - } |
|
| 28 | + parent::boot(); |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * Define the routes for the module. |
|
| 33 | - * |
|
| 34 | - * @return void |
|
| 35 | - */ |
|
| 36 | - public function map() |
|
| 37 | - { |
|
| 38 | - $this->mapWebRoutes(); |
|
| 31 | + /** |
|
| 32 | + * Define the routes for the module. |
|
| 33 | + * |
|
| 34 | + * @return void |
|
| 35 | + */ |
|
| 36 | + public function map() |
|
| 37 | + { |
|
| 38 | + $this->mapWebRoutes(); |
|
| 39 | 39 | |
| 40 | - $this->mapApiRoutes(); |
|
| 40 | + $this->mapApiRoutes(); |
|
| 41 | 41 | |
| 42 | - // |
|
| 43 | - } |
|
| 42 | + // |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * Define the "web" routes for the module. |
|
| 47 | - * |
|
| 48 | - * These routes all receive session state, CSRF protection, etc. |
|
| 49 | - * |
|
| 50 | - * @return void |
|
| 51 | - */ |
|
| 52 | - protected function mapWebRoutes() |
|
| 53 | - { |
|
| 54 | - Route::group([ |
|
| 55 | - 'middleware' => 'web', |
|
| 56 | - 'namespace' => $this->namespace, |
|
| 57 | - ], function ($router) { |
|
| 58 | - require module_path('users', 'Routes/web.php', 'app'); |
|
| 59 | - }); |
|
| 60 | - } |
|
| 45 | + /** |
|
| 46 | + * Define the "web" routes for the module. |
|
| 47 | + * |
|
| 48 | + * These routes all receive session state, CSRF protection, etc. |
|
| 49 | + * |
|
| 50 | + * @return void |
|
| 51 | + */ |
|
| 52 | + protected function mapWebRoutes() |
|
| 53 | + { |
|
| 54 | + Route::group([ |
|
| 55 | + 'middleware' => 'web', |
|
| 56 | + 'namespace' => $this->namespace, |
|
| 57 | + ], function ($router) { |
|
| 58 | + require module_path('users', 'Routes/web.php', 'app'); |
|
| 59 | + }); |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - /** |
|
| 63 | - * Define the "api" routes for the module. |
|
| 64 | - * |
|
| 65 | - * These routes are typically stateless. |
|
| 66 | - * |
|
| 67 | - * @return void |
|
| 68 | - */ |
|
| 69 | - protected function mapApiRoutes() |
|
| 70 | - { |
|
| 71 | - Route::group([ |
|
| 72 | - 'middleware' => 'api', |
|
| 73 | - 'namespace' => $this->namespace, |
|
| 74 | - 'prefix' => 'api', |
|
| 75 | - ], function ($router) { |
|
| 76 | - require module_path('users', 'Routes/api.php', 'app'); |
|
| 77 | - }); |
|
| 78 | - } |
|
| 62 | + /** |
|
| 63 | + * Define the "api" routes for the module. |
|
| 64 | + * |
|
| 65 | + * These routes are typically stateless. |
|
| 66 | + * |
|
| 67 | + * @return void |
|
| 68 | + */ |
|
| 69 | + protected function mapApiRoutes() |
|
| 70 | + { |
|
| 71 | + Route::group([ |
|
| 72 | + 'middleware' => 'api', |
|
| 73 | + 'namespace' => $this->namespace, |
|
| 74 | + 'prefix' => 'api', |
|
| 75 | + ], function ($router) { |
|
| 76 | + require module_path('users', 'Routes/api.php', 'app'); |
|
| 77 | + }); |
|
| 78 | + } |
|
| 79 | 79 | } |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | Route::group([ |
| 55 | 55 | 'middleware' => 'web', |
| 56 | 56 | 'namespace' => $this->namespace, |
| 57 | - ], function ($router) { |
|
| 57 | + ], function($router) { |
|
| 58 | 58 | require module_path('users', 'Routes/web.php', 'app'); |
| 59 | 59 | }); |
| 60 | 60 | } |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | 'middleware' => 'api', |
| 73 | 73 | 'namespace' => $this->namespace, |
| 74 | 74 | 'prefix' => 'api', |
| 75 | - ], function ($router) { |
|
| 75 | + ], function($router) { |
|
| 76 | 76 | require module_path('users', 'Routes/api.php', 'app'); |
| 77 | 77 | }); |
| 78 | 78 | } |
@@ -1,12 +1,12 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | $factory->define(App\Modules\Users\AclUser::class, function (Faker\Generator $faker) { |
| 4 | - return [ |
|
| 5 | - 'profile_picture' => 'http://lorempixel.com/400/200/', |
|
| 6 | - 'name' => $faker->name(), |
|
| 7 | - 'email' => $faker->safeEmail(), |
|
| 8 | - 'password' => 123456, |
|
| 9 | - 'created_at' => $faker->dateTimeBetween('-1 years', 'now'), |
|
| 10 | - 'updated_at' => $faker->dateTimeBetween('-1 years', 'now') |
|
| 11 | - ]; |
|
| 4 | + return [ |
|
| 5 | + 'profile_picture' => 'http://lorempixel.com/400/200/', |
|
| 6 | + 'name' => $faker->name(), |
|
| 7 | + 'email' => $faker->safeEmail(), |
|
| 8 | + 'password' => 123456, |
|
| 9 | + 'created_at' => $faker->dateTimeBetween('-1 years', 'now'), |
|
| 10 | + 'updated_at' => $faker->dateTimeBetween('-1 years', 'now') |
|
| 11 | + ]; |
|
| 12 | 12 | }); |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -$factory->define(App\Modules\Users\AclUser::class, function (Faker\Generator $faker) { |
|
| 3 | +$factory->define(App\Modules\Users\AclUser::class, function(Faker\Generator $faker) { |
|
| 4 | 4 | return [ |
| 5 | 5 | 'profile_picture' => 'http://lorempixel.com/400/200/', |
| 6 | 6 | 'name' => $faker->name(), |