Comments Added

This commit is contained in:
Anders 2020-07-27 14:01:04 +02:00
parent 39af9758ee
commit 42449ae091
1 changed files with 7 additions and 7 deletions

View File

@ -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);
}