From fce394f6bd7b70f33491ce34db271eca40f14784 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sat, 16 Jun 2018 14:30:20 -0700 Subject: [PATCH] Change email handling and logout function --- .../Api/Client/AccountController.php | 6 ++--- .../Api/Client/Account/UpdateEmailRequest.php | 5 +--- .../scripts/components/core/Navigation.vue | 10 ++++++-- .../dashboard/account/UpdateEmail.vue | 12 +++------ .../assets/scripts/store/modules/auth.js | 25 +++---------------- routes/auth.php | 2 +- 6 files changed, 18 insertions(+), 42 deletions(-) diff --git a/app/Http/Controllers/Api/Client/AccountController.php b/app/Http/Controllers/Api/Client/AccountController.php index fc0f22ecd..84ec07e3a 100644 --- a/app/Http/Controllers/Api/Client/AccountController.php +++ b/app/Http/Controllers/Api/Client/AccountController.php @@ -40,7 +40,7 @@ class AccountController extends ClientApiController /** * Update the authenticated user's email address if their password matches. * - * @param UpdateEmailRequest $request + * @param \Pterodactyl\Http\Requests\Api\Client\Account\UpdateEmailRequest $request * @return array * * @throws \Pterodactyl\Exceptions\Model\DataValidationException @@ -48,9 +48,7 @@ class AccountController extends ClientApiController */ public function updateEmail(UpdateEmailRequest $request): array { - $updated = $this->updateService->handle($request->user(), [ - 'email' => $request->input('email'), - ]); + $updated = $this->updateService->handle($request->user(), $request->validated()); return $this->fractal->item($updated->get('model')) ->transformWith($this->getTransformer(AccountTransformer::class)) diff --git a/app/Http/Requests/Api/Client/Account/UpdateEmailRequest.php b/app/Http/Requests/Api/Client/Account/UpdateEmailRequest.php index f354d120a..0d8f9ea74 100644 --- a/app/Http/Requests/Api/Client/Account/UpdateEmailRequest.php +++ b/app/Http/Requests/Api/Client/Account/UpdateEmailRequest.php @@ -34,9 +34,6 @@ class UpdateEmailRequest extends ClientApiRequest { $rules = User::getUpdateRulesForId($this->user()->id); - return [ - 'email' => $rules['email'], - 'password' => array_merge($rules['password'], ['confirmed']), - ]; + return ['email' => $rules['email']]; } } diff --git a/resources/assets/scripts/components/core/Navigation.vue b/resources/assets/scripts/components/core/Navigation.vue index 701fada65..5939355a4 100644 --- a/resources/assets/scripts/components/core/Navigation.vue +++ b/resources/assets/scripts/components/core/Navigation.vue @@ -23,7 +23,7 @@
  • - +
  • @@ -37,6 +37,12 @@ export default { name: 'navigation', - components: { LogOutIcon, ServerIcon, SettingsIcon, UserIcon } + components: { LogOutIcon, ServerIcon, SettingsIcon, UserIcon }, + methods: { + doLogout: function () { + this.$store.commit('auth/logout'); + return window.location = this.route('auth.logout'); + }, + } }; diff --git a/resources/assets/scripts/components/dashboard/account/UpdateEmail.vue b/resources/assets/scripts/components/dashboard/account/UpdateEmail.vue index 0e4d82b69..d8932c973 100644 --- a/resources/assets/scripts/components/dashboard/account/UpdateEmail.vue +++ b/resources/assets/scripts/components/dashboard/account/UpdateEmail.vue @@ -16,12 +16,6 @@ v-model="password" > -
    - - -
    @@ -31,6 +25,7 @@