Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Login flow consistency: Do not use redirect in admin area login box #4865

Merged
merged 1 commit into from
Sep 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 9 additions & 22 deletions e107_admin/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,7 @@
{
e107::coreLan('log_messages', true);
e107::getLog()->addEvent(4, __FILE__."|".__FUNCTION__."@".__LINE__, "LOGIN", LAN_ROLL_LOG_11, "U: ".e107::getParser()->toDB($_POST['authname']), FALSE, LOG_TO_ROLLING);

e107::getRedirect()->redirect('admin.php?failed');
}

exit;

}


Expand Down Expand Up @@ -274,28 +269,20 @@ public function authform() // NOTE: this should NOT be a template of the admin-
// Start Clean
// NOTE: this should NOT be a template of the admin-template, however themes may style it using css.

$class = (e_QUERY === 'failed') ? "class='e-shake'" : "";

$text = "<form id='admin-login' method='post' action='".e_SELF."' {$incChap} >
<div id='logo' ><img src='".e_IMAGE."logo_template_large.png' alt='".LAN_LOGIN."' /></div>
<div id='login-admin' class='center'>
<div>";

if(e_QUERY === 'failed')
{
e107::lan('core', 'login');
$text .= e107::getMessage()->render(); // see e107_handlers/login.php L622
$text .= "<script>
window.setTimeout(function() {
$('.alert').fadeTo(500, 0).slideUp(500, function(){
$(this).remove();
});
}, 7000);
</script>";

}


e107::lan('core', 'login');
$text .= e107::getMessage()->render(); // see e107_handlers/login.php L622
$text .= "<script>
window.setTimeout(function() {
$('.alert').fadeTo(500, 0).slideUp(500, function(){
$(this).remove();
});
}, 7000);
</script>";

$text .= "
<div class='panel well panel-primary'>
Expand Down
2 changes: 1 addition & 1 deletion e107_handlers/login.php
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ protected function invalidLogin($username, $reason, $extra_text = '')
$this->logNote('LAN_ROLL_LOG_10', $username);
}

e107::getMessage()->reset()->addError($message, 'default', true); // prevent duplicates, session=true needed for admin-area login.
e107::getMessage()->reset()->addError($message); // prevent duplicates

if($this->testMode === true)
{
Expand Down
15 changes: 13 additions & 2 deletions e107_tests/tests/acceptance/0001_AdminLoginCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,19 @@ public function _after(AcceptanceTester $I)
{
}

// tests
/**
* @see https://github.com/e107inc/e107/issues/4779
*/
public function testAdminFailedLogin(AcceptanceTester $I)
{
$I->wantTo("See a login failure message in the admin area if I put in the wrong credentials");
$I->amOnPage("/e107_admin/admin.php");
$I->fillField('authname', 'e107');
$I->fillField('authpass', 'wrong password');
$I->click('authsubmit');
$I->see("Your login details don't match any registered user");
}

public function testAdminLogin(AcceptanceTester $I)
{

Expand All @@ -27,7 +39,6 @@ public function testAdminLogin(AcceptanceTester $I)

}


private function e107Login(AcceptanceTester $I)
{
$I->amOnPage('/e107_admin/admin.php');
Expand Down