From 806ca43b527809e6b37573b6995535638102039c Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Thu, 27 Apr 2017 12:27:36 +0200 Subject: [PATCH] allow to display the verification code also while verification is already running Signed-off-by: Bjoern Schiessle --- settings/Controller/UsersController.php | 28 +++++++++++++------------ settings/js/federationsettingsview.js | 2 ++ settings/js/personal.js | 14 ++++++++++--- settings/templates/personal.php | 17 +++++++-------- 4 files changed, 35 insertions(+), 26 deletions(-) diff --git a/settings/Controller/UsersController.php b/settings/Controller/UsersController.php index 38c555e6a5..f481629e98 100644 --- a/settings/Controller/UsersController.php +++ b/settings/Controller/UsersController.php @@ -518,9 +518,10 @@ class UsersController extends Controller { * @PasswordConfirmationRequired * * @param string $account + * @param bool $onlyVerificationCode only return verification code without updating the data * @return DataResponse */ - public function getVerificationCode($account) { + public function getVerificationCode($account, $onlyVerificationCode) { $user = $this->userSession->getUser(); @@ -554,19 +555,20 @@ class UsersController extends Controller { return new DataResponse([], Http::STATUS_BAD_REQUEST); } - $this->accountManager->updateUser($user, $accountData); + if ($onlyVerificationCode === false) { + $this->accountManager->updateUser($user, $accountData); - - $this->jobList->add('OC\Settings\BackgroundJobs\VerifyUserData', - [ - 'verificationCode' => $code, - 'data' => $data, - 'type' => $type, - 'uid' => $user->getUID(), - 'try' => 0, - 'lastRun' => $this->getCurrentTime() - ] - ); + $this->jobList->add('OC\Settings\BackgroundJobs\VerifyUserData', + [ + 'verificationCode' => $code, + 'data' => $data, + 'type' => $type, + 'uid' => $user->getUID(), + 'try' => 0, + 'lastRun' => $this->getCurrentTime() + ] + ); + } return new DataResponse(['msg' => $msg, 'code' => $code]); } diff --git a/settings/js/federationsettingsview.js b/settings/js/federationsettingsview.js index e8c6a84e1e..f89aad2afd 100644 --- a/settings/js/federationsettingsview.js +++ b/settings/js/federationsettingsview.js @@ -167,10 +167,12 @@ var verifyStatus = this.$('#' + field + 'form > .verify > #verify-' + field); verifyStatus.attr('title', t('core', 'Verify')); verifyStatus.attr('src', OC.imagePath('core', 'actions/verify.svg')); + verifyStatus.data('status', '0'); verifyStatus.addClass('verify-action'); } else if (field === 'email') { var verifyStatus = this.$('#' + field + 'form > .verify > #verify-' + field); verifyStatus.attr('title', t('core', 'Verifying …')); + verifyStatus.data('status', '1'); verifyStatus.attr('src', OC.imagePath('core', 'actions/verifying.svg')); } } diff --git a/settings/js/personal.js b/settings/js/personal.js index 3249382a88..cd9fd3498b 100644 --- a/settings/js/personal.js +++ b/settings/js/personal.js @@ -215,18 +215,26 @@ $(document).ready(function () { var verify = $(this); var indicator = $(this).children('img'); var accountId = indicator.attr('id'); + var status = indicator.data('status'); + + var onlyVerificationCode = false; + if (parseInt(status) === 1) { + onlyVerificationCode = true; + } if (indicator.hasClass('verify-action')) { $.ajax( OC.generateUrl('/settings/users/{account}/verify', {account: accountId}), - {method: 'GET'} + { + method: 'GET', + data: {onlyVerificationCode: onlyVerificationCode} + } ).done(function (data) { var dialog = verify.children('.verification-dialog'); showVerifyDialog($(dialog), data.msg, data.code); indicator.attr('title', t('core', 'Verifying …')); indicator.attr('src', OC.imagePath('core', 'actions/verifying.svg')); - indicator.removeClass('verify-action'); - + indicator.data('status', '1'); }); } diff --git a/settings/templates/personal.php b/settings/templates/personal.php index 8dc2872e74..6cd9ac8f7b 100644 --- a/settings/templates/personal.php +++ b/settings/templates/personal.php @@ -106,13 +106,12 @@ print_unescaped('src="' . image_path('core', 'actions/verifying.svg') . '"'); break; case \OC\Accounts\AccountManager::VERIFIED: - print_unescaped('src="' . image_path('core', 'actions/verified.svg') . '""'); + print_unescaped('src="' . image_path('core', 'actions/verified.svg') . '"'); break; default: print_unescaped('src="' . image_path('core', 'actions/verify.svg') . '"'); } - print_unescaped(' title="' . $_['websiteMessage'] . '""'); - ?>> + ?> title=""> @@ -167,10 +166,10 @@
- > + ?> title="">