]> source.dussan.org Git - nextcloud-server.git/commitdiff
Require confirmation when generating backup codes
authorJoas Schilling <coding@schilljs.com>
Mon, 19 Sep 2016 14:58:38 +0000 (16:58 +0200)
committerLukas Reschke <lukas@statuscode.ch>
Fri, 18 Nov 2016 10:57:16 +0000 (11:57 +0100)
Signed-off-by: Joas Schilling <coding@schilljs.com>
apps/twofactor_backupcodes/js/settingsview.js
apps/twofactor_backupcodes/lib/Controller/SettingsController.php

index 224f5f4797f70e3c3aeb9e2c4faa58f2bad72138..763960231201ea92b89b43cecb1e05fd7cdf82a4 100644 (file)
                        }.bind(this));
                },
                _onGenerateBackupCodes: function () {
+                       if (OC.PasswordConfirmation.requiresPasswordConfirmation()) {
+                               OC.PasswordConfirmation.requirePasswordConfirmation(_.bind(this._onGenerateBackupCodes, this));
+                               return;
+                       }
+
                        // Hide old codes
                        this._enabled = false;
                        this.render();
index fed7634643d105b7fd6195945e4356acfa4747c5..9b0b0fc57ba974b7dba5cd0b9148c792484ade38 100644 (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),
+               ]);
        }
 
 }