@@ -12,8 +12,7 @@ |
||
| 12 | 12 | public function run() |
| 13 | 13 | { |
| 14 | 14 | // Create the test users - note, none are installers - permissions are assigned randomly |
| 15 | - factory(App\User::class, 15)->create()->each(function($user) |
|
| 16 | - { |
|
| 15 | + factory(App\User::class, 15)->create()->each(function($user) { |
|
| 17 | 16 | // $user->UserPermissions()->save(factory(App\UserPermissions::class)->create(['user_id' => $user->user_id])); |
| 18 | 17 | }); |
| 19 | 18 | } |
@@ -191,19 +191,25 @@ discard block |
||
| 191 | 191 | $user = new UserResource(User::findOrFail($id)); |
| 192 | 192 | |
| 193 | 193 | // Make sure that the user is not trying to deactivate someone with more permissions |
| 194 | - if ($user->role_id < Auth::user()->role_id) |
|
| 194 | + if ($user->role_id < Auth::user()->role_id) |
|
| 195 | 195 | { |
| 196 | 196 | return abort(403); |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | // Good to go - update user password |
| 200 | 200 | $roleArr = []; |
| 201 | - foreach ($roles as $role) { |
|
| 202 | - if ($role->role_id == 1 && Auth::user()->role_id != 1) { |
|
| 201 | + foreach ($roles as $role) |
|
| 202 | + { |
|
| 203 | + if ($role->role_id == 1 && Auth::user()->role_id != 1) |
|
| 204 | + { |
|
| 203 | 205 | continue; |
| 204 | - } else if ($role->role_id == 2 && Auth::user()->role_id > 1) { |
|
| 206 | + } |
|
| 207 | + else if ($role->role_id == 2 && Auth::user()->role_id > 1) |
|
| 208 | + { |
|
| 205 | 209 | continue; |
| 206 | - } else { |
|
| 210 | + } |
|
| 211 | + else |
|
| 212 | + { |
|
| 207 | 213 | // $roleArr[$role->role_id] = $role->name; |
| 208 | 214 | $roleArr[] = [ |
| 209 | 215 | 'value' => $role->role_id, |
@@ -239,7 +245,7 @@ discard block |
||
| 239 | 245 | // Update the user data |
| 240 | 246 | $user = User::findOrFail($id); |
| 241 | 247 | |
| 242 | - if ($user->role_id < Auth::user()->role_id) |
|
| 248 | + if ($user->role_id < Auth::user()->role_id) |
|
| 243 | 249 | { |
| 244 | 250 | return abort(403); |
| 245 | 251 | } |
@@ -282,17 +288,20 @@ discard block |
||
| 282 | 288 | $user = User::find($request->user_id); |
| 283 | 289 | |
| 284 | 290 | // Verify this is a valid user ID |
| 285 | - if (!$user) { |
|
| 291 | + if (!$user) |
|
| 292 | + { |
|
| 286 | 293 | $success = false; |
| 287 | 294 | $reason = 'Cannot find user with this ID'; |
| 288 | 295 | } |
| 289 | 296 | // Make sure that the user is not trying to deactivate someone with more permissions |
| 290 | - else if ($user->role_id < Auth::user()->role_id) { |
|
| 297 | + else if ($user->role_id < Auth::user()->role_id) |
|
| 298 | + { |
|
| 291 | 299 | $success = false; |
| 292 | 300 | $reason = 'You cannot change password for a user with higher permissions that you. If this user has locked themselves out, have then use the reset link on the login page.'; |
| 293 | 301 | } |
| 294 | 302 | // Good to go - update user password |
| 295 | - else { |
|
| 303 | + else |
|
| 304 | + { |
|
| 296 | 305 | // Update the user data |
| 297 | 306 | $user->update( |
| 298 | 307 | [ |