diff --git a/Controller.php b/Controller.php index c6217fe2..275b672c 100644 --- a/Controller.php +++ b/Controller.php @@ -77,4 +77,17 @@ public function admin() return $view->render(); } + + public function confirmPassword() + { + $enablePasswordConfirmation = \Piwik\Plugins\LoginLdap\Config::getConfigOption('enable_password_confirmation'); + if ($enablePasswordConfirmation) { + return parent::confirmPassword(); + } + Piwik::checkUserIsNotAnonymous(); + Piwik::checkUserHasSomeViewAccess(); + + $this->passwordVerify->setPasswordVerifiedCorrectly(); + } + } \ No newline at end of file diff --git a/tests/UI/Admin_spec.js b/tests/UI/Admin_spec.js index fab764d8..3d9431fc 100644 --- a/tests/UI/Admin_spec.js +++ b/tests/UI/Admin_spec.js @@ -34,6 +34,7 @@ describe("LoginLdap_Admin", function () { }); var ldapAdminUrl = "?module=LoginLdap&action=admin&idSite=1&period=day&date=yesterday"; + var addNewTokenUrl = "?module=UsersManager&action=addNewToken&idSite=1&period=day&date=yesterday"; it("should load correctly and allow testing the filter and group fields", async function () { await page.goto(ldapAdminUrl); @@ -53,4 +54,22 @@ describe("LoginLdap_Admin", function () { var elem = await page.jQuery('#content'); expect(await elem.screenshot()).to.matchImage('admin_page'); }); + + it("should show the password confirmation screen when add new token screen is called", async function () { + testEnvironment.configOverride.LoginLdap = { enable_password_confirmation: 1 }; + testEnvironment.save(); + await page.goto(addNewTokenUrl); + await page.waitForNetworkIdle(); + var elem = await page.jQuery('#loginPage'); + expect(await elem.screenshot()).to.matchImage('addNewToken_with_password'); + }); + + it("should show the add new token screen", async function () { + testEnvironment.configOverride.LoginLdap = { enable_password_confirmation: 0 }; + testEnvironment.save(); + await page.goto(addNewTokenUrl); + await page.waitForNetworkIdle(); + var elem = await page.jQuery('.page'); + expect(await elem.screenshot()).to.matchImage('addNewToken_without_password'); + }); }); diff --git a/tests/UI/expected-ui-screenshots/LoginLdap_Admin_addNewToken_with_password.png b/tests/UI/expected-ui-screenshots/LoginLdap_Admin_addNewToken_with_password.png new file mode 100644 index 00000000..534f2170 Binary files /dev/null and b/tests/UI/expected-ui-screenshots/LoginLdap_Admin_addNewToken_with_password.png differ diff --git a/tests/UI/expected-ui-screenshots/LoginLdap_Admin_addNewToken_without_password.png b/tests/UI/expected-ui-screenshots/LoginLdap_Admin_addNewToken_without_password.png new file mode 100644 index 00000000..6baf3ade Binary files /dev/null and b/tests/UI/expected-ui-screenshots/LoginLdap_Admin_addNewToken_without_password.png differ