From b816eb1c0686d8e329b4316b01555d3fb6be9e6a Mon Sep 17 00:00:00 2001 From: Pig Fang Date: Sun, 12 Jan 2020 11:47:36 +0800 Subject: [PATCH] simplify --- app/Http/Controllers/UserController.php | 27 +++++++++---------------- 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index 14164317..3dcff87f 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -279,16 +279,13 @@ class UserController extends Controller return json(trans('user.profile.password.wrong-password'), 1); } - if ($user->changePassword($request->input('new_password'))) { - $dispatcher->dispatch('user.profile.updated', [$user, $action, $addition]); - event(new UserProfileUpdated($action, $user)); + $user->changePassword($request->input('new_password')); + $dispatcher->dispatch('user.profile.updated', [$user, $action, $addition]); + event(new UserProfileUpdated($action, $user)); - Auth::logout(); + Auth::logout(); - return json(trans('user.profile.password.success'), 0); - } - - break; // @codeCoverageIgnore + return json(trans('user.profile.password.success'), 0); case 'email': $this->validate($request, [ @@ -332,23 +329,17 @@ class UserController extends Controller $dispatcher->dispatch('user.deleting', [$user]); - if ($user->delete()) { - $dispatcher->dispatch('user.deleted', [$user]); - session()->flush(); + $user->delete(); + $dispatcher->dispatch('user.deleted', [$user]); + session()->flush(); - return json(trans('user.profile.delete.success'), 0); - } - - break; // @codeCoverageIgnore + return json(trans('user.profile.delete.success'), 0); default: return json(trans('general.illegal-parameters'), 1); - break; } } - // @codeCoverageIgnore - public function setAvatar(Request $request, Filter $filter, Dispatcher $dispatcher) { $this->validate($request, ['tid' => 'required|integer']);