Commit 47bbfe0f authored by bas's avatar bas
Browse files

MDL-69371 theme_boost: redesign the moodle login page

parent 8885e22a
......@@ -11,7 +11,7 @@ Feature: User must accept policy managed by this plugin when logging in and sign
| sitepolicyhandler | tool_policy |
And I am on site homepage
And I follow "Log in"
When I press "Create new account"
When I click on "Create new account" "link"
Then I should not see "I understand and agree"
And I set the following fields to these values:
| Username | user1 |
......@@ -45,7 +45,7 @@ Feature: User must accept policy managed by this plugin when logging in and sign
| P1 | This privacy policy | | full text2 | short text2 | draft |
And I am on site homepage
And I follow "Log in"
When I press "Create new account"
When I click on "Create new account" "link"
Then I should not see "I understand and agree"
And I set the following fields to these values:
| Username | user1 |
......@@ -80,7 +80,7 @@ Feature: User must accept policy managed by this plugin when logging in and sign
| P1 | This site policy | | full text3 | short text3 | draft |
And I am on site homepage
And I follow "Log in"
When I press "Create new account"
When I click on "Create new account" "link"
Then I should see "This site policy" in the "region-main" "region"
And I should see "short text2"
And I should see "full text2"
......@@ -128,7 +128,7 @@ Feature: User must accept policy managed by this plugin when logging in and sign
| This guests policy | 0 | | full text4 | short text4 | active | guest |
And I am on site homepage
And I follow "Log in"
When I press "Create new account"
When I click on "Create new account" "link"
Then I should see "This site policy" in the "region-main" "region"
And I should see "short text2"
And I should see "full text2"
......@@ -188,7 +188,7 @@ Feature: User must accept policy managed by this plugin when logging in and sign
| This site policy | | full text2 | short text2 | active |
And I am on site homepage
And I follow "Log in"
When I press "Create new account"
When I click on "Create new account" "link"
Then I should see "Age and location verification"
And I set the field "What is your age?" to "16"
And I set the field "In which country do you live?" to "DZ"
......@@ -239,7 +239,7 @@ Feature: User must accept policy managed by this plugin when logging in and sign
| This privacy policy | 1 | | full text3 | short text3 | active | loggedin |
And I am on site homepage
And I follow "Log in"
And I press "Create new account"
And I click on "Create new account" "link"
And I should see "This site policy"
And I press "Next"
And I should see "This privacy policy"
......@@ -494,7 +494,7 @@ Feature: User must accept policy managed by this plugin when logging in and sign
| This guests policy | 0 | | full text4 | short text4 | active | guest |
And I am on site homepage
And I follow "Log in"
When I press "Create new account"
When I click on "Create new account" "link"
Then I should see "This site policy" in the "region-main" "region"
And I should see "short text2"
And I should see "full text2"
......@@ -526,7 +526,7 @@ Feature: User must accept policy managed by this plugin when logging in and sign
Then I should see "Confirm your account"
And I should see "An email should have been sent to your address at user1@address.invalid"
And I follow "Log in"
When I press "Create new account"
When I click on "Create new account" "link"
# Confirm that the user can view and accept policies when attempting to create another account.
Then I should see "This site policy" in the "region-main" "region"
And I should see "short text2"
......@@ -628,7 +628,7 @@ Feature: User must accept policy managed by this plugin when logging in and sign
And I press "Log in as a guest"
# Now sign up
And I follow "Log in"
When I press "Create new account"
When I click on "Create new account" "link"
Then I should see "This site policy"
And I should see "short text2"
And I should see "full text2"
......@@ -677,7 +677,7 @@ Feature: User must accept policy managed by this plugin when logging in and sign
| Terms of Service | We teach, you learn | Here goes content. | 1 |
And I am on site homepage
And I follow "Log in"
When I press "Create new account"
When I click on "Create new account" "link"
# The first policy with the agreement style "on its own page" must be accepted first.
Then I should see "Digital maturity declaration" in the "region-main" "region"
And I should see "You declare be old enough"
......@@ -841,7 +841,7 @@ Feature: User must accept policy managed by this plugin when logging in and sign
| Terms of Service | We teach, you learn | Here goes content. | 1 | guest |
And I am on site homepage
And I follow "Log in"
When I press "Create new account"
When I click on "Create new account" "link"
# All the policies to be displayed one by one with a button to accept each of them prior seeing the next.
Then I should see "Digital maturity declaration" in the "region-main" "region"
And I should see "You declare be old enough"
......
......@@ -65,7 +65,7 @@ Feature: Optional policies
| OwnPageOptional1 | full text5 | short text5 | 1 | 1 |
And I am on site homepage
And I follow "Log in"
And I press "Create new account"
And I click on "Create new account" "link"
# Compulsory policies displayed on own page are shown first and must be agreed.
And I should see "OwnPageCompulsory1" in the "region-main" "region"
And I should see "short text4" in the "region-main" "region"
......
......@@ -70,6 +70,8 @@ class login implements renderable, templatable {
public $signupurl;
/** @var string The user name to pre-fill the form with. */
public $username;
/** @var string The language selector menu. */
public $languagemenu;
/** @var string The csrf token to limit login to requests that come from the login form. */
public $logintoken;
/** @var string Maintenance message, if Maintenance is enabled. */
......@@ -82,10 +84,11 @@ class login implements renderable, templatable {
* @param string $username The username to display.
*/
public function __construct(array $authsequence, $username = '') {
global $CFG;
global $CFG, $OUTPUT;
$this->username = $username;
$this->languagemenu = $OUTPUT->language_menu();
$this->canloginasguest = $CFG->guestloginbutton and !isguestuser();
$this->canloginbyemail = !empty($CFG->authloginviaemail);
$this->cansignup = $CFG->registerauth == 'email' || !empty($CFG->registerauth);
......@@ -111,8 +114,12 @@ class login implements renderable, templatable {
$this->instructions = get_string('loginsteps', 'core', 'signup.php');
}
if ($CFG->maintenance_enabled == true && !empty($CFG->maintenance_message)) {
$this->maintenance = $CFG->maintenance_message;
if ($CFG->maintenance_enabled == true) {
if (!empty($CFG->maintenance_message)) {
$this->maintenance = $CFG->maintenance_message;
} else {
$this->maintenance = get_string('sitemaintenance', 'admin');
}
}
// Identity providers.
......@@ -152,6 +159,7 @@ class login implements renderable, templatable {
$data->username = $this->username;
$data->logintoken = $this->logintoken;
$data->maintenance = format_text($this->maintenance, FORMAT_MOODLE);
$data->languagemenu = $this->languagemenu;
return $data;
}
......
......@@ -10,7 +10,7 @@ Feature: User must accept policy when logging in and signing up
| passwordpolicy | 0 |
And I am on site homepage
And I follow "Log in"
When I press "Create new account"
When I click on "Create new account" "link"
Then I should not see "I understand and agree"
And I set the following fields to these values:
| Username | user1 |
......@@ -40,7 +40,7 @@ Feature: User must accept policy when logging in and signing up
| sitepolicy | https://moodle.org |
And I am on site homepage
And I follow "Log in"
When I press "Create new account"
When I click on "Create new account" "link"
Then the field "I understand and agree" matches value "0"
And I set the following fields to these values:
| Username | user1 |
......@@ -74,7 +74,7 @@ Feature: User must accept policy when logging in and signing up
| s1 | John | Doe | s1@example.com |
And I am on site homepage
And I follow "Log in"
When I press "Create new account"
When I click on "Create new account" "link"
And I set the following fields to these values:
| Username | s2 |
| Password | test |
......
@auth @core_auth @javascript
Feature: Test if the login form provides the correct feedback
In order to check if the login form provides correct feedback
As a user
I need to go on login page and see feedback on incorrect username or password.
Background:
Given the following "users" exist:
| username |
| teacher1 |
Scenario: Check invalid login message
Given I follow "Log in"
And I set the field "Username" to "teacher1"
And I set the field "Password" to "incorrect"
When I press "Log in"
Then I should see "Invalid login, please try again"
Scenario: Test login language selector
Given I log in as "admin"
And I navigate to "Language > Language packs" in site administration
And I set the field "Available language packs" to "nl,es"
And I press "Install selected language pack(s)"
And I trigger cron
And I am on homepage
And I log out
And I follow "Log in"
And I click on "//a[@id='action-menu-toggle-0']" "xpath_element"
And I click on "//a[@data-lang='nl']" "xpath_element"
Then I should see "Gebruikersnaam"
@_file_upload
Scenario: Set logo for loginpage
Given I log in as "admin"
And I navigate to "Appearance > Logos" in site administration
And I upload "course/tests/fixtures/image.jpg" file to "Logo" filemanager
And I press "Save changes"
And I log out
And I follow "Log in"
Then "//img[@id='logoimage']" "xpath_element" should exist
Scenario: Add a custom welcome message
Given the following config values are set as admin:
| auth_instructions | Lorem ipsum dolor sit amet |
And I follow "Log in"
Then I should see "Lorem ipsum dolor sit amet"
Scenario: Show the maintenance mode message
Given the following config values are set as admin:
| maintenance_enabled | Disabled |
| maintenance_message | Back online tomorrow |
And I follow "Log in"
Then I should see "Back online tomorrow"
Scenario: User self registration
Given the following config values are set as admin:
| registerauth | Email-based self-registration |
And I follow "Log in"
Then I should see "Create new account"
Scenario: Set OAuth providers
Given I log in as "admin"
And I navigate to "Plugins > Authentication > Manage authentication" in site administration
And I click on "Enable" "link" in the "OAuth 2" "table_row"
And I navigate to "Server > OAuth 2 services" in site administration
And I press "Google"
And I set the field "Client ID" to "1234"
And I set the field "Client secret" to "1234"
And I press "Save changes"
And I press "Facebook"
And I set the field "Client ID" to "1234"
And I set the field "Client secret" to "1234"
And I press "Save changes"
And I press "Microsoft"
And I set the field "Client ID" to "1234"
And I set the field "Client secret" to "1234"
And I press "Save changes"
And I log out
And I follow "Log in"
Then I should see "Google"
And I should see "Facebook"
And I should see "Microsoft"
Scenario: Test the login page auto focus feature
Given the following config values are set as admin:
| loginpageautofocus | Enabled |
And I follow "Log in"
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"
Then the focused element is "Password" "field"
Scenario: Test the login page focus after error feature
Given I follow "Log in"
And I set the field "Username" to "admin"
And I set the field "Password" to "wrongpassword"
And I press "Log in"
And I press the tab key
Then the focused element is "Username" "field"
......@@ -13,24 +13,24 @@ Feature: Test the 'Digital age of consent verification' feature works.
# Try to access the sign up page.
Given I am on homepage
When I click on "Log in" "link" in the ".logininfo" "css_element"
And I press "Create new account"
And I click on "Create new account" "link"
Then I should see "Age and location verification"
When I set the field "What is your age?" to "16"
And I set the field "In which country do you live?" to "DZ"
And I press "Proceed"
Then I should see "New account"
And I should see "Choose your username and password"
And I should see "Username"
# Try to access the sign up page again.
When I press "Cancel"
And I press "Create new account"
And I click on "Create new account" "link"
Then I should see "New account"
And I should see "Choose your username and password"
And I should see "Username"
Scenario: User that is considered a digital minor attempts to self-register on the site.
# Try to access the sign up page.
Given I am on homepage
When I click on "Log in" "link" in the ".logininfo" "css_element"
And I press "Create new account"
And I click on "Create new account" "link"
Then I should see "Age and location verification"
When I set the field "What is your age?" to "12"
And I set the field "In which country do you live?" to "AT"
......@@ -40,6 +40,6 @@ Feature: Test the 'Digital age of consent verification' feature works.
# Try to access the sign up page again.
When I click on "Back to the site home" "link"
And I click on "Log in" "link" in the ".logininfo" "css_element"
And I press "Create new account"
And I click on "Create new account" "link"
Then I should see "You are too young to create an account on this site."
And I should see "Please ask your parent/guardian to contact:"
......@@ -161,3 +161,5 @@ coursepage,core_admin
invalidpersistenterror,core_competency
mediapluginswf,core_admin
mediapluginswfnote,core_admin
createuserandpass,core
supplyinfo,core
......@@ -419,7 +419,6 @@ $string['createnewcategory'] = 'Create new category';
$string['createnewcourse'] = 'Create new course';
$string['createnewsubcategory'] = 'Create new subcategory';
$string['createsubcategoryof'] = 'Create subcategory of {$a}';
$string['createuserandpass'] = 'Choose your username and password';
$string['createuser'] = 'Create user';
$string['createziparchive'] = 'Create zip archive';
$string['creatingblocks'] = 'Creating blocks';
......@@ -2064,7 +2063,6 @@ $string['successduration'] = 'Success ({$a} seconds)';
$string['summary'] = 'Summary';
$string['summary_help'] = 'The idea of a summary is a short text to prepare students for the activities within the topic or week. The text is shown on the course page under the section name.';
$string['summaryof'] = 'Summary of {$a}';
$string['supplyinfo'] = 'More details';
$string['suspended'] = 'Suspended';
$string['suspendedusers'] = 'Suspended users';
$string['switchdevicedefault'] = 'Switch to the standard theme';
......@@ -2350,4 +2348,6 @@ $string['coursepreferences'] = 'Course preferences';
$string['registrationno'] = 'No, I do not wish to receive any emails';
// Deprecated since Moodle 4.0.
$string['createuserandpass'] = 'Choose your username and password';
$string['descriptiona'] = 'Description: {$a}';
$string['supplyinfo'] = 'More details';
......@@ -3720,6 +3720,44 @@ EOD;
return $this->render_custom_menu($custommenu);
}
/**
* Returns the language menu if multiple languages are installed.
*
* @return object lang menu object for rendering.
*/
public function language_menu() {
global $CFG;
if ($CFG->langmenu) {
$langs = get_string_manager()->get_list_of_translations();
if (count($langs) < 2) {
return '';
}
$langmenu = new action_menu();
$menuname = get_string('language');
$currentlang = current_language();
if (isset($langs[$currentlang])) {
$menuname = $langs[$currentlang];
}
$langmenu->set_menu_trigger($menuname);
foreach ($langs as $langtype => $langname) {
$lang = new action_menu_link_secondary(
new moodle_url($this->page->url, ['lang' => $langtype]),
null,
$langname,
['data-lang' => $langtype]
);
$langmenu->add($lang);
}
return $this->render($langmenu);
}
}
/**
* We want to show the custom menus as a list of links in the footer on small screens.
* Just return the menu object exported so we can render it differently.
......
......@@ -26,33 +26,15 @@
"homelink": "/"
}
}}
<div class="container-fluid mt-1 mt-md-5">
<div class="row justify-content-md-center">
<div class="col-md-8 push-md-2 col-xl-6 push-xl-3">
<div class="card">
<div class="card-body">
<div class="card-title text-xs-center">
{{#logourl}}
<h2><img src="{{logourl}}" title="{{sitename}}" alt="{{sitename}}"/></h2>
{{/logourl}}
{{^logourl}}
<h2>{{sitename}}</h2>
{{/logourl}}
<hr>
</div>
<div class="card-title">
<h3>{{#str}}considereddigitalminor{{/str}}</h3>
</div>
<div class="pt-3 pb-5">
<p>{{#str}}digitalminor_desc{{/str}}</p>
<p class="mb-0">{{{supportname}}}</p>
<p class="mb-0">{{{supportemail}}}</p>
</div>
<div class="backlink">
<a href="{{homelink}}">{{#str}}backtohome{{/str}}</a>
</div>
</div>
</div>
</div>
</div>
<div class="card-title">
<h3>{{#str}}considereddigitalminor{{/str}}</h3>
</div>
<div class="pt-3 pb-5">
<p>{{#str}}digitalminor_desc{{/str}}</p>
<p class="mb-0">{{{supportname}}}</p>
<p class="mb-0">{{{supportemail}}}</p>
</div>
<div class="backlink">
<a href="{{homelink}}">{{#str}}backtohome{{/str}}</a>
</div>
......@@ -25,40 +25,23 @@
"formhtml": "(Form html would go here)"
}
}}
<div class="container-fluid mt-1 mt-md-5">
<div class="row justify-content-md-center">
<div class="col-md-8 push-md-2 col-xl-6 push-xl-3">
<div class="card">
<div class="card-body">
<div class="card-title text-xs-center">
{{#logourl}}
<h2><img src="{{logourl}}" title="{{sitename}}" alt="{{sitename}}"/></h2>
{{/logourl}}
{{^logourl}}
<h2>{{sitename}}</h2>
{{/logourl}}
<hr>
</div>
{{#error}}
<div class="alert alert-danger" role="alert" data-aria-autofocus="true">
{{{error}}}
</div>
{{/error}}
<div class="card-title">
<h3>{{#str}}agelocationverification{{/str}}</h3>
</div>
<div class="mt-2 mb-2">
{{{formhtml}}}
</div>
<hr>
<div class="card-title">
<h3>{{#str}}whyisthisrequired{{/str}}</h3>
</div>
<div class="mt-1">
<p >{{#str}}explanationdigitalminor{{/str}}</p>
</div>
</div>
</div>
<div class="verifyage">
{{#error}}
<div class="alert alert-danger" role="alert" data-aria-autofocus="true">
{{{error}}}
</div>
{{/error}}
<div class="card-title">
<h3>{{#str}}agelocationverification{{/str}}</h3>
</div>
<div class="mt-2 mb-2">
{{{formhtml}}}
</div>
<hr>
<div class="card-title">
<h3>{{#str}}whyisthisrequired{{/str}}</h3>
</div>
<div class="mt-1">
<p >{{#str}}explanationdigitalminor{{/str}}</p>
</div>
</div>
......@@ -91,175 +91,134 @@
"logourl": false,
"sitename": "Beer & Chips",
"logintoken": "randomstring",
"maintenance": "For full access to this site, you need to login in as an admin."
"maintenance": "For full access to this site, you need to login in as an admin.",
"languagemenu": "Choose language"
}
}}
<div class="my-1 my-sm-5"></div>
<div class="row justify-content-center">
<div class="col-xl-6 col-sm-8 ">
<div class="card">
<div class="card-block">
{{#logourl}}
<h1 class="h2 card-header text-center" >
<span class="sr-only">{{sitename}}: {{#str}} login {{/str}}</span>
<img src="{{logourl}}" class="img-fluid" alt=""/>
</h1>
{{/logourl}}
{{^logourl}}
<h1 class="h2 card-header text-center" aria-label="{{sitename}}: {{#str}} login {{/str}}">{{sitename}}</h1>
{{/logourl}}
<div class="card-body">
{{#cansignup}}
<div class="sr-only">
<a href="{{signupurl}}">{{#str}} tocreatenewaccount {{/str}}</a>
</div>
{{/cansignup}}
{{#error}}
<div class="loginerrors mt-3">
<a href="#" id="loginerrormessage" class="accesshide">{{error}}</a>
<div class="alert alert-danger" role="alert" data-aria-autofocus="true">{{error}}</div>
</div>
{{/error}}
<div class="row justify-content-md-center">
<div class="col-md-5">
<form class="mt-3" action="{{loginurl}}" method="post" id="login">
<input id="anchor" type="hidden" name="anchor" value="">
<script>document.getElementById('anchor').value = location.hash;</script>
<input type="hidden" name="logintoken" value="{{logintoken}}">
<div class="form-group">
<label for="username" class="sr-only">
{{^canloginbyemail}}
{{#str}} username {{/str}}
{{/canloginbyemail}}
{{#canloginbyemail}}
{{#str}} usernameemail {{/str}}
{{/canloginbyemail}}
</label>
<input type="text" name="username" id="username"
class="form-control"
value="{{username}}"
placeholder={{#quote}}{{^canloginbyemail}}{{#str}}username{{/str}}{{/canloginbyemail}}{{#canloginbyemail}}{{#str}}usernameemail{{/str}}{{/canloginbyemail}}{{/quote}}
autocomplete="username">
</div>
<div class="form-group">
<label for="password" class="sr-only">{{#str}} password {{/str}}</label>
<input type="password" name="password" id="password" value=""
class="form-control"
placeholder={{#quote}}{{#str}}password{{/str}}{{/quote}}
autocomplete="current-password">
</div>
{{#rememberusername}}
<div class="rememberpass mt-3">
<input type="checkbox" name="rememberusername" id="rememberusername" value="1" {{#username}}checked="checked"{{/username}} />
<label for="rememberusername">{{#str}} rememberusername, admin {{/str}}</label>
</div>
{{/rememberusername}}
<button type="submit" class="btn btn-primary btn-block mt-3" id="loginbtn">{{#str}}login{{/str}}</button>
</form>
</div>
<div class="col-md-5">
<div class="forgetpass mt-3">
<p><a href="{{forgotpasswordurl}}">{{#str}}forgotten{{/str}}</a></p>
</div>
<div class="mt-3">
{{#str}} cookiesenabled {{/str}}
{{{cookieshelpiconformatted}}}
</div>
{{#canloginasguest}}
<div class="mt-2">
<p>{{#str}}someallowguest{{/str}}</p>
<form action="{{loginurl}}" method="post" id="guestlogin">
<input type="hidden" name="logintoken" value="{{logintoken}}">
<input type="hidden" name="username" value="guest" />
<input type="hidden" name="password" value="guest" />
<button class="btn btn-secondary btn-block" type="submit">{{#str}}loginguest{{/str}}</button>
</form>
</div>
{{/canloginasguest}}
{{#hasidentityproviders}}
<h2 class="h6 mt-2">{{#str}} potentialidps, auth {{/str}}</h2>
<div class="potentialidplist mt-3">
{{#identityproviders}}
<div class="potentialidp">
<a href="{{url}}" title={{#quote}}{{name}}{{/quote}} class="btn btn-secondary btn-block">
{{#iconurl}}
<img src="{{iconurl}}" alt="" width="24" height="24"/>
{{/iconurl}}
{{name}}
</a>
</div>
{{/identityproviders}}