Added info about activation to account settings

This commit is contained in:
Marcin Kurczewski 2014-09-10 18:06:49 +02:00
parent 0283b2055d
commit 56cd1b965a
4 changed files with 21 additions and 8 deletions

View file

@ -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 += '<br/>Check your inbox for activation e-mail.<br/>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;

View file

@ -43,6 +43,10 @@
<label class="form-label" for="account-settings-email">E-mail:</label>
<div class="form-input">
<input type="text" name="email" id="account-settings-email" placeholder="New e-mail&hellip;" value="<%= user.email %>"/>
<% if (user.emailUnconfirmed) { %>
<br/>
<span class="account-settings-email-unconfirmed">(unconfirmed) <%= user.emailUnconfirmed %></span>
<% } %>
</div>
</div>
<% } %>

View file

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

View file

@ -33,6 +33,8 @@ class UserViewProxy extends AbstractViewProxy
$result->email = $user->email;
$result->emailUnconfirmed = $user->emailUnconfirmed;
}
$result->confirmed = !$user->emailUnconfirmed;
}
return $result;
}