From 42449ae0916447c6485a844f548800f4d699792a Mon Sep 17 00:00:00 2001 From: Anders Date: Mon, 27 Jul 2020 14:01:04 +0200 Subject: [PATCH] Comments Added --- skolehjem/app/Http/Controllers/UserController.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/skolehjem/app/Http/Controllers/UserController.php b/skolehjem/app/Http/Controllers/UserController.php index e03049e..c027dbe 100644 --- a/skolehjem/app/Http/Controllers/UserController.php +++ b/skolehjem/app/Http/Controllers/UserController.php @@ -152,7 +152,7 @@ class UserController extends Controller // else if(Auth::user()->hasPermissionTo("user.edit")) { $user = User::find($id); - if ($request->roles != null) { + if ($request->roles != null) { //You can only edit roles on the admin site, so if there is an input roles, then update user info and edit roles /** @var User $user */ $user->update($data); $user->roles()->detach(); @@ -163,20 +163,20 @@ class UserController extends Controller } //$user->save(); - } else { - if ($request->input('password') != null) { - if ($request->input('password') != $request->input('confirmpassword')) { + } else { // Else if you're not on the admin site (user site) + if ($request->input('password') != null) { // If you're editing the password + if ($request->input('password') != $request->input('confirmpassword')) { // If new password and new password confirm is not the same, go back. return Response::detect("users.editpass"); - } elseif (!Hash::check($request->input('oldpassword'), $user->password)) { + } elseif (!Hash::check($request->input('oldpassword'), $user->password)) { // If the written current password and current password in DB is not the same, go back. return Response::detect("users.editpass"); - } else { + } else { // If new password and current password is the same AND current written and current DB password is the same. Then update and logout. /** @var User $user */ $user->update($data); Auth::logout(); return redirect()->route("users.login"); } - } else { + } else { // Else if you're not editing the password but anything else (Email, Phone Number). Then update user. $user->update($data); }