From 8c9a7246722b9439150a864538dabf42d929a463 Mon Sep 17 00:00:00 2001 From: Jun Pataleta Date: Thu, 4 Oct 2018 11:43:22 +0800 Subject: [PATCH 1/2] MDL-63528 auth: Show "Remember username" on login form only when needed --- auth/classes/output/login.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/auth/classes/output/login.php b/auth/classes/output/login.php index 9ec9c329cbb..9876ea9b109 100644 --- a/auth/classes/output/login.php +++ b/auth/classes/output/login.php @@ -78,7 +78,7 @@ class login implements renderable, templatable { * @param string $username The username to display. */ public function __construct(array $authsequence, $username = '') { - global $CFG, $SESSION; + global $CFG; $this->username = $username; @@ -88,7 +88,7 @@ class login implements renderable, templatable { $this->cookieshelpicon = new help_icon('cookiesenabled', 'core'); $this->autofocusform = !empty($CFG->loginpageautofocus); - $this->rememberusername = isset($CFG->rememberusername) and $CFG->rememberusername == 2; + $this->rememberusername = isset($CFG->rememberusername) && $CFG->rememberusername != 0; $this->forgotpasswordurl = new moodle_url('/login/forgot_password.php'); $this->loginurl = new moodle_url('/login/index.php'); From 0f6973ac13935c9bdf037e152f627c4c68ccb269 Mon Sep 17 00:00:00 2001 From: Jun Pataleta Date: Thu, 4 Oct 2018 12:22:35 +0800 Subject: [PATCH 2/2] MDL-63528 auth: Behat scenario for "Remember username" display --- auth/tests/behat/login.feature | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/auth/tests/behat/login.feature b/auth/tests/behat/login.feature index 697080011fa..f80390b204e 100644 --- a/auth/tests/behat/login.feature +++ b/auth/tests/behat/login.feature @@ -39,3 +39,18 @@ Feature: Authentication Given I log in as "admin" When I log out 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 I log in as "admin" + And I set the following administration settings values: + | rememberusername | | + And I log out + 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 |