Skip to content

Commit

Permalink
Merge pull request #349 from matomo-org/PG-2796-token_auth_skip_pwd
Browse files Browse the repository at this point in the history
Added code to skip password confirmation for create token auth
  • Loading branch information
AltamashShaikh authored Nov 6, 2023
2 parents 10452b6 + a481ebe commit e2b2ebc
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

}
19 changes: 19 additions & 0 deletions tests/UI/Admin_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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');
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e2b2ebc

Please sign in to comment.