MDL-87119 login: Improve the logout confirmation dialogue
This commit is contained in:
@@ -1247,6 +1247,7 @@ $string['loginrequired'] = 'Login required';
|
||||
$string['logoof'] = 'Logo of {$a}';
|
||||
$string['logout'] = 'Log out';
|
||||
$string['logoutconfirm'] = 'Do you really want to log out?';
|
||||
$string['logoutconfirmtitle'] = 'Log out?';
|
||||
$string['logs'] = 'Logs';
|
||||
$string['logtoomanycourses'] = '[ <a href="{$a->url}">more</a> ]';
|
||||
$string['logtoomanyusers'] = '[ <a href="{$a->url}">more</a> ]';
|
||||
|
||||
@@ -394,8 +394,13 @@ if (isloggedin() and !isguestuser()) {
|
||||
// prevent logging when already logged in, we do not want them to relogin by accident because sesskey would be changed
|
||||
echo $OUTPUT->box_start();
|
||||
$logout = new single_button(new moodle_url('/login/logout.php', array('sesskey'=>sesskey(),'loginpage'=>1)), get_string('logout'), 'post');
|
||||
$continue = new single_button(new moodle_url('/'), get_string('cancel'), 'get');
|
||||
echo $OUTPUT->confirm(get_string('alreadyloggedin', 'error', fullname($USER)), $logout, $continue);
|
||||
$continue = new single_button(new moodle_url('/'), get_string('gobacktosite'), 'get');
|
||||
echo $OUTPUT->confirm(
|
||||
message: get_string('alreadyloggedin', 'error', fullname($USER)),
|
||||
continue: $logout,
|
||||
cancel: $continue,
|
||||
displayoptions: ['confirmtitle' => get_string('logoutconfirmtitle')],
|
||||
);
|
||||
echo $OUTPUT->box_end();
|
||||
} else {
|
||||
$loginform = new \core_auth\output\login($authsequence, $frm->username);
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
@core
|
||||
Feature: Relogin prevention
|
||||
User will be informed when trying to login again while already logged in
|
||||
As a user
|
||||
I should be informed that I am already logged in
|
||||
|
||||
Background:
|
||||
Given the following "users" exist:
|
||||
| username | password | firstname | lastname | email |
|
||||
| testuser | test | Test | User | user@example.com |
|
||||
|
||||
Scenario: A logged in user tries to access the login page again
|
||||
Given I follow "Log in"
|
||||
And I set the field "Username" to "testuser"
|
||||
And I set the field "Password" to "test"
|
||||
And I press "Log in"
|
||||
And I should see "You are logged in as"
|
||||
When I visit "/login"
|
||||
Then I should see "You are already logged in as Test User, you need to log out before logging in as different user." in the "Log out?" "dialogue"
|
||||
And "Go back to site" "button" should exist in the "Log out?" "dialogue"
|
||||
And "Log out" "button" should exist in the "Log out?" "dialogue"
|
||||
Reference in New Issue
Block a user