allow to display the verification code also while verification is already running

Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
This commit is contained in:
Bjoern Schiessle 2017-04-27 12:27:36 +02:00 committed by Morris Jobke
parent 9480b29413
commit 806ca43b52
No known key found for this signature in database
GPG key ID: 9CE5ED29E7FCD38A
4 changed files with 35 additions and 26 deletions

View file

@ -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]);
}

View file

@ -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'));
}
}

View file

@ -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');
});
}

View file

@ -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="<?php p($_['emailMessage']); ?>">
</div>
<input type="email" name="email" id="email" value="<?php p($_['email']); ?>"
<?php if(!$_['displayNameChangeSupported']) { print_unescaped('class="hidden"'); } ?>
@ -167,10 +166,10 @@
<span class="icon-password"/>
</h2>
<div class="verify <?php if ($_['website'] === '' || $_['websiteScope'] !== 'public') p('hidden'); ?>">
<img id="verify-website" <?php
<img id="verify-website" data-status="<?php p($_['websiteVerification']) ?>" <?php
switch($_['websiteVerification']) {
case \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS:
print_unescaped('src="' . image_path('core', 'actions/verifying.svg') . '"');
print_unescaped('src="' . image_path('core', 'actions/verifying.svg') . '" class="verify-action"');
break;
case \OC\Accounts\AccountManager::VERIFIED:
print_unescaped('src="' . image_path('core', 'actions/verified.svg') . '"');
@ -178,8 +177,7 @@
default:
print_unescaped('src="' . image_path('core', 'actions/verify.svg') . '" class="verify-action"');
}
print_unescaped(' title="' . $_['websiteMessage'] . '""');
?>>
?> title="<?php p($_['websiteMessage']); ?>">
<div class="verification-dialog popovermenu bubble menu">
<div class="verification-dialog-content">
<p class="explainVerification"></p>
@ -205,7 +203,7 @@
<img id="verify-twitter" <?php
switch($_['twitterVerification']) {
case \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS:
print_unescaped('src="' . image_path('core', 'actions/verifying.svg') . '"');
print_unescaped('src="' . image_path('core', 'actions/verifying.svg') . '" class="verify-action"');
break;
case \OC\Accounts\AccountManager::VERIFIED:
print_unescaped('src="' . image_path('core', 'actions/verified.svg') . '"');
@ -213,8 +211,7 @@
default:
print_unescaped('src="' . image_path('core', 'actions/verify.svg') . '" class="verify-action"');
}
print_unescaped(' title="' . $_['twitterMessage'] . '""');
?>>
?> title="<?php p($_['twitterMessage']); ?>">
<div class="verification-dialog popovermenu bubble menu">
<div class="verification-dialog-content">
<p class="explainVerification"></p>