Comments Added
This commit is contained in:
parent
39af9758ee
commit
42449ae091
|
@ -152,7 +152,7 @@ class UserController extends Controller
|
||||||
// else if(Auth::user()->hasPermissionTo("user.edit")) {
|
// else if(Auth::user()->hasPermissionTo("user.edit")) {
|
||||||
$user = User::find($id);
|
$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 */
|
/** @var User $user */
|
||||||
$user->update($data);
|
$user->update($data);
|
||||||
$user->roles()->detach();
|
$user->roles()->detach();
|
||||||
|
@ -163,20 +163,20 @@ class UserController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
//$user->save();
|
//$user->save();
|
||||||
} else {
|
} else { // Else if you're not on the admin site (user site)
|
||||||
if ($request->input('password') != null) {
|
if ($request->input('password') != null) { // If you're editing the password
|
||||||
if ($request->input('password') != $request->input('confirmpassword')) {
|
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");
|
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");
|
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 */
|
/** @var User $user */
|
||||||
$user->update($data);
|
$user->update($data);
|
||||||
Auth::logout();
|
Auth::logout();
|
||||||
|
|
||||||
return redirect()->route("users.login");
|
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);
|
$user->update($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue