Require confirmation when generating backup codes

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2016-09-19 16:58:38 +02:00 committed by Lukas Reschke
parent a0d6c6593a
commit 86aa6197b8
No known key found for this signature in database
GPG Key ID: B9F6980CF6E759B1
2 changed files with 11 additions and 4 deletions

View File

@ -89,6 +89,11 @@
}.bind(this));
},
_onGenerateBackupCodes: function () {
if (OC.PasswordConfirmation.requiresPasswordConfirmation()) {
OC.PasswordConfirmation.requirePasswordConfirmation(_.bind(this._onGenerateBackupCodes, this));
return;
}
// Hide old codes
this._enabled = false;
this.render();

View File

@ -59,15 +59,17 @@ class SettingsController extends Controller {
/**
* @NoAdminRequired
* @PasswordConfirmationRequired
*
* @return JSONResponse
*/
public function createCodes() {
$user = $this->userSession->getUser();
$codes = $this->storage->createCodes($user);
return [
'codes' => $codes,
'state' => $this->storage->getBackupCodesState($user),
];
return new JSONResponse([
'codes' => $codes,
'state' => $this->storage->getBackupCodesState($user),
]);
}
}