From 56cd1b965a1eb5b30a67e7bd523ca6c46c1cf150 Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Wed, 10 Sep 2014 18:06:49 +0200 Subject: [PATCH] Added info about activation to account settings --- .../UserAccountSettingsPresenter.js | 21 ++++++++++++------- public_html/templates/account-settings.tpl | 4 ++++ src/Controllers/UserController.php | 2 +- src/Controllers/ViewProxies/UserViewProxy.php | 2 ++ 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/public_html/js/Presenters/UserAccountSettingsPresenter.js b/public_html/js/Presenters/UserAccountSettingsPresenter.js index 4b436071..f32de0c8 100644 --- a/public_html/js/Presenters/UserAccountSettingsPresenter.js +++ b/public_html/js/Presenters/UserAccountSettingsPresenter.js @@ -109,7 +109,7 @@ App.Presenters.UserAccountSettingsPresenter = function( formData.accessRank = $el.find('[name=access-rank]').val(); } - if (!validateAccountSettingsFormData($messages, formData)) { + if (!validateAccountSettingsFormData(formData)) { return; } @@ -120,23 +120,30 @@ App.Presenters.UserAccountSettingsPresenter = function( api.put('/users/' + user.name, formData) .then(function(response) { - editSuccess($messages, response); + editSuccess(response); }).fail(function(response) { - editFailure($messages, response); + editFailure(response); }); } - function editSuccess($messages, apiResponse) { - //todo: tell user if it turned out that he needs to confirm his e-mail + function editSuccess(apiResponse) { + user = apiResponse.json; + render(); + var $messages = jQuery(target).find('.messages'); var message = 'Account settings updated!'; + if (!apiResponse.json.confirmed) { + message += '
Check your inbox for activation e-mail.
If e-mail doesn\'t show up, check your spam folder.'; + } messagePresenter.showInfo($messages, message); } - function editFailure($messages, apiResponse) { + function editFailure(apiResponse) { + var $messages = jQuery(target).find('.messages'); messagePresenter.showError($messages, apiResponse.json && apiResponse.json.error || apiResponse); } - function validateAccountSettingsFormData($messages, formData) { + function validateAccountSettingsFormData(formData) { + var $messages = jQuery(target).find('.messages'); if (formData.password !== formData.passwordConfirmation) { messagePresenter.showError($messages, 'Passwords must be the same.'); return false; diff --git a/public_html/templates/account-settings.tpl b/public_html/templates/account-settings.tpl index da371e91..4115d77d 100644 --- a/public_html/templates/account-settings.tpl +++ b/public_html/templates/account-settings.tpl @@ -43,6 +43,10 @@
+ <% if (user.emailUnconfirmed) { %> +
+ + <% } %>
<% } %> diff --git a/src/Controllers/UserController.php b/src/Controllers/UserController.php index 32d435aa..caa65b7a 100644 --- a/src/Controllers/UserController.php +++ b/src/Controllers/UserController.php @@ -60,7 +60,7 @@ final class UserController extends AbstractController $this->privilegeService->assertPrivilege(\Szurubooru\Privilege::REGISTER); $formData = new \Szurubooru\FormData\RegistrationFormData($this->inputReader); $user = $this->userService->createUser($formData); - return array_merge((array) $this->userViewProxy->fromEntity($user), ['confirmed' => !$user->emailUnconfirmed]); + return $this->userViewProxy->fromEntity($user); } public function updateUser($userNameOrEmail) diff --git a/src/Controllers/ViewProxies/UserViewProxy.php b/src/Controllers/ViewProxies/UserViewProxy.php index e7f90a17..7860a40b 100644 --- a/src/Controllers/ViewProxies/UserViewProxy.php +++ b/src/Controllers/ViewProxies/UserViewProxy.php @@ -33,6 +33,8 @@ class UserViewProxy extends AbstractViewProxy $result->email = $user->email; $result->emailUnconfirmed = $user->emailUnconfirmed; } + + $result->confirmed = !$user->emailUnconfirmed; } return $result; }