diff --git a/auth/classes/output/login.php b/auth/classes/output/login.php index 1ee9f8fa66c..1f0bbd77ab9 100644 --- a/auth/classes/output/login.php +++ b/auth/classes/output/login.php @@ -64,8 +64,6 @@ class login implements renderable, templatable { public $instructions; /** @var moodle_url The form action login URL. */ public $loginurl; - /** @var bool Whether the username should be remembered. */ - public $rememberusername; /** @var moodle_url The sign-up URL. */ public $signupurl; /** @var string The user name to pre-fill the form with. */ @@ -96,10 +94,8 @@ class login implements renderable, templatable { $this->cansignup = $CFG->registerauth == 'email' || !empty($CFG->registerauth); if ($CFG->rememberusername == 0) { $this->cookieshelpicon = new help_icon('cookiesenabledonlysession', 'core'); - $this->rememberusername = false; } else { $this->cookieshelpicon = new help_icon('cookiesenabled', 'core'); - $this->rememberusername = true; } $this->autofocusform = !empty($CFG->loginpageautofocus); @@ -156,7 +152,6 @@ class login implements renderable, templatable { list($data->instructions, $data->instructionsformat) = external_format_text($this->instructions, FORMAT_MOODLE, context_system::instance()->id); $data->loginurl = $this->loginurl->out(false); - $data->rememberusername = $this->rememberusername; $data->signupurl = $this->signupurl->out(false); $data->username = $this->username; $data->logintoken = $this->logintoken; diff --git a/auth/tests/behat/login.feature b/auth/tests/behat/login.feature index d23d1558625..e2e66063ba0 100644 --- a/auth/tests/behat/login.feature +++ b/auth/tests/behat/login.feature @@ -40,19 +40,6 @@ Feature: Authentication When I click on "Log out" "link" in the "#page-footer" "css_element" Then I should see "You are not logged in" in the "page-footer" "region" - Scenario Outline: Checking the display of the Remember username checkbox - Given the following config values are set as admin: - | rememberusername | | - And I am on homepage - When I click on "Log in" "link" in the ".logininfo" "css_element" - Then I should "Remember username" - - Examples: - | settingvalue | expect | - | 0 | not see | - | 1 | see | - | 2 | see | - @javascript @accessibility Scenario: Login page must be accessible When I am on site homepage diff --git a/auth/tests/behat/loginform.feature b/auth/tests/behat/loginform.feature index 394892ccddd..3a006863845 100644 --- a/auth/tests/behat/loginform.feature +++ b/auth/tests/behat/loginform.feature @@ -89,7 +89,6 @@ Feature: Test if the login form provides the correct feedback Then the focused element is "Username" "field" And I set the field "Username" to "admin" And I set the field "Password" to "admin" - And I set the field "Remember username" to "1" And I press "Log in" And I log out And I follow "Log in" diff --git a/auth/tests/behat/rememberusername.feature b/auth/tests/behat/rememberusername.feature index b7d0388d921..cfa8c5f5238 100644 --- a/auth/tests/behat/rememberusername.feature +++ b/auth/tests/behat/rememberusername.feature @@ -1,8 +1,8 @@ @core @core_auth Feature: Test the 'remember username' feature works. - In order to see my saved username on the login form + In order for users to easily log in to the site As a user - I need to have logged in once before and clicked 'Remember username' + I need the site to remember my username when the feature is enabled Background: Given the following "users" exist: @@ -11,16 +11,42 @@ Feature: Test the 'remember username' feature works. # Given the user has logged in and selected 'Remember username', when they log in again, then their username should be remembered. Scenario: Check that 'remember username' works without javascript for teachers. - # Log in the first time and check the 'remember username' box. - Given I am on homepage + # Log in the first time with $CFG->rememberusername set to Yes. + Given the following config values are set as admin: + | rememberusername | 1 | + And I am on homepage And I click on "Log in" "link" in the ".logininfo" "css_element" And I set the field "Username" to "teacher1" And I set the field "Password" to "teacher1" - And I set the field "Remember username" to "1" And I press "Log in" And I log out # Log out and check that the username was remembered. When I am on homepage And I click on "Log in" "link" in the ".logininfo" "css_element" Then the field "username" matches value "teacher1" - And the field "Remember username" matches value "1" + + # Given the user has logged in before and selected 'Remember username', when they log in again and unset 'Remember username', then + # their username should be forgotten for future log in attempts. + Scenario: Check that 'remember username' unsetting works without javascript for teachers. + # Log in the first time with $CFG->rememberusername set to Optional. + Given the following config values are set as admin: + | rememberusername | 2 | + And I am on homepage + And I click on "Log in" "link" in the ".logininfo" "css_element" + And I set the field "Username" to "teacher1" + And I set the field "Password" to "teacher1" + And I press "Log in" + And I log out + # Log in again, the username should have been remembered. + When I am on homepage + And I click on "Log in" "link" in the ".logininfo" "css_element" + Then the field "username" matches value "teacher1" + And I set the field "Password" to "teacher1" + And I press "Log in" + And I log out + And the following config values are set as admin: + | rememberusername | 0 | + # Check username has been forgotten. + And I am on homepage + And I click on "Log in" "link" in the ".logininfo" "css_element" + Then the field "username" matches value "" diff --git a/blocks/login/block_login.php b/blocks/login/block_login.php index e56ca7c30c7..83d6319f70f 100644 --- a/blocks/login/block_login.php +++ b/blocks/login/block_login.php @@ -77,16 +77,6 @@ class block_login extends block_base { $this->content->text .= ' class="form-control" value="" autocomplete="current-password"/>'; $this->content->text .= ''; - if (isset($CFG->rememberusername) and $CFG->rememberusername == 2) { - $checked = $username ? 'checked="checked"' : ''; - $this->content->text .= '
'; - $this->content->text .= ''; - $this->content->text .= '
'; - } - $this->content->text .= '
'; $this->content->text .= ''; $this->content->text .= '
'; diff --git a/lib/templates/loginform.mustache b/lib/templates/loginform.mustache index f72af240dbd..d563f5a43ad 100644 --- a/lib/templates/loginform.mustache +++ b/lib/templates/loginform.mustache @@ -33,7 +33,6 @@ * instructions - Instructions, * instructionsformat - Format of instructions, * loginurl - Login url, - * rememberusername - Remeber username?, * signupurl - Signup url, * errorformatted - Formatted error, * logourl - Flag, logo url, @@ -83,7 +82,6 @@ "instructions": "For full access to this site, you first need to create an account.", "instructionsformat": "1", "loginurl": "http://localhost/stable_master/login/index.php", - "rememberusername": true, "signupurl": "http://localhost/stable_master/login/signup.php", "cookieshelpiconformatted": "", "errorformatted": "", diff --git a/login/index.php b/login/index.php index 7b3668aa459..25312086d8a 100644 --- a/login/index.php +++ b/login/index.php @@ -218,7 +218,7 @@ if ($frm and isset($frm->username)) { // Login WITH // auth plugins can temporarily override this from loginpage_hook() // do not save $CFG->nolastloggedin in database! - } else if (empty($CFG->rememberusername) or ($CFG->rememberusername == 2 and empty($frm->rememberusername))) { + } else if (empty($CFG->rememberusername)) { // no permanent cookies, delete old one if exists set_moodle_cookie('');