Skip to content

Commit 02b56d5

Browse files
Merge pull request #587 from creative-commoners/pulls/5/form-sudo-mode
ENH Disable temporary sudo mode after login
2 parents 506aef4 + 2820fc9 commit 02b56d5

7 files changed

Lines changed: 13 additions & 13 deletions

File tree

behat.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ default:
1515
- SilverStripe\Framework\Tests\Behaviour\CmsUiContext
1616
- SilverStripe\BehatExtension\Context\BasicContext
1717
- SilverStripe\BehatExtension\Context\EmailContext
18+
- SilverStripe\BehatExtension\Context\FixtureContext:
19+
- '%paths.modules.mfa%/tests/Behat/features/files/'
1820
- SilverStripe\MFA\Tests\Behat\Context\LoginContext
1921
- SilverStripe\CMS\Tests\Behaviour\ThemeContext
2022
extensions:

client/dist/js/bundle-cms.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/src/boot/cms/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
/* global window */
22
import registerComponents from './registerComponents';
33
import registerReducers from './registerReducers';
4-
import registerTransformations from './registerTransformations';
54

65
window.document.addEventListener('DOMContentLoaded', () => {
76
registerComponents();
87
registerReducers();
9-
registerTransformations();
108
});

client/src/boot/cms/registerTransformations.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/Authenticator/LoginHandler.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
use SilverStripe\Security\MemberAuthenticator\LoginHandler as BaseLoginHandler;
2727
use SilverStripe\Security\MemberAuthenticator\MemberLoginForm;
2828
use SilverStripe\Security\Security;
29+
use SilverStripe\Core\ClassInfo;
2930

3031
class LoginHandler extends BaseLoginHandler
3132
{
@@ -576,6 +577,13 @@ public function jsonResponse(array $response, int $code = 200): HTTPResponse
576577
*/
577578
protected function doPerformLogin(HTTPRequest $request, Member $member)
578579
{
580+
// Deactivate sudo mode that was activated in doLogin()
581+
$service = $this->getSudoModeService();
582+
// Check if the service has a deactivate method, because it is not defined on the interface
583+
if (ClassInfo::hasMethod($service, 'deactivate')) {
584+
call_user_func([$service, 'deactivate'], $this->getRequest()->getSession());
585+
}
586+
579587
// Load the previously stored data from session and perform the login using it...
580588
$data = $request->getSession()->get(static::SESSION_KEY . '.additionalData') ?: [];
581589

tests/Behat/features/files/blank.txt

Whitespace-only changes.

tests/Behat/features/mfa-enabled.feature

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ Feature: MFA is enabled for the site
44
So that my site will be more secure
55

66
Background:
7-
Given I am logged in with "ADMIN" permissions
7+
Given I add an extension "SilverStripe\BehatExtension\Extensions\ActivateSudoModeServiceExtension" to the "SilverStripe\Security\SudoMode\SudoModeService" class
8+
And I am logged in with "ADMIN" permissions
89
And I go to "/admin"
910
Then I should see the CMS
1011

0 commit comments

Comments
 (0)