2 This file is part of Moodle - http://moodle.org/
4 Moodle is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 Moodle is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with Moodle. If not, see <http://www.gnu.org/licenses/>.
18 @template core/loginform
20 Moodle template for the login page.
22 Context variables required for this template:
23 * autofocusform: Auto focus on form ?,
24 * canloginasguest - Is guest login allowed?,
25 * canloginbyemail - Is login by email allowed?,
26 * cansignup - Signup allowed?,
27 * cookieshelpicon - cookies help icon details
28 * error - Any errors in the form?,
29 * forgotpasswordurl - Forgot password url,
30 * hasidentityproviders - Flag, set to true to hide identity providers,
31 * hasinstructions - Flag, set to true to show instructions,
32 * identityproviders - List of identiy providers,
33 * instructions - Instructions,
34 * instructionsformat - Format of instructions,
35 * loginurl - Login url,
36 * signupurl - Signup url,
37 * errorformatted - Formatted error,
38 * logourl - Flag, logo url,
39 * sitename - Name of site.,
40 * logintoken - Random token to protect login request.,
41 * maintenance - Maintenance message
43 Example context (json):
45 "autofocusform": false,
46 "canloginasguest": "1",
47 "canloginbyemail": false,
50 "heading": "Cookies must be enabled in your browser",
51 "text": "<div class=\"no-overflow\">Two cookies are used on this site. Both died..</div>",
60 "value": "Help with Cookies must be enabled in your browser"
64 "value": "Help with Cookies must be enabled in your browser"
68 "value": "http://localhost/stable_master/theme/image.php?theme=boost&component=core&image=help"
73 "title": "Help with Cookies must be enabled in your browser",
74 "url": "http://localhost/stable_master/help.php?component=core&identifier=cookiesenabled&lang=en",
78 "forgotpasswordurl": "http://localhost/stable_master/login/forgot_password.php",
79 "hasidentityproviders": false,
80 "hasinstructions": true,
81 "identityproviders": [],
82 "instructions": "For full access to this site, you first need to create an account.",
83 "instructionsformat": "1",
84 "loginurl": "http://localhost/stable_master/login/index.php",
85 "signupurl": "http://localhost/stable_master/login/signup.php",
86 "cookieshelpiconformatted": "",
89 "sitename": "Beer & Chips",
90 "logintoken": "randomstring",
91 "maintenance": "For full access to this site, you need to login in as an admin.",
92 "languagemenu": "Choose language"
96 <div class="loginform">
98 <div id="loginlogo" class="login-logo">
99 <img id="logoimage" src="{{logourl}}" class="img-fluid" alt="{{sitename}}"/>
100 <h1 class="login-heading sr-only">{{#str}} loginto, core, {{sitename}} {{/str}}</h1>
104 <h1 class="login-heading mb-4">{{#str}} loginto, core, {{sitename}} {{/str}}</h1>
107 <div class="alert alert-danger login-maintenance">
112 <a href="#" id="loginerrormessage" class="sr-only">{{error}}</a>
113 <div class="alert alert-danger" role="alert">{{error}}</div>
116 <a href="{{signupurl}}" class="sr-only">{{#str}} tocreatenewaccount {{/str}}</a>
118 <form class="login-form" action="{{loginurl}}" method="post" id="login">
119 <input type="hidden" name="logintoken" value="{{logintoken}}">
120 <div class="login-form-username form-group">
121 <label for="username" class="sr-only">
123 {{#str}} username {{/str}}
126 {{#str}} usernameemail {{/str}}
129 <input type="text" name="username" id="username" {{!
130 !}}class="form-control form-control-lg" {{!
131 !}}value="{{username}}" {{!
132 !}}placeholder="{{^canloginbyemail}}{{#cleanstr}}username{{/cleanstr}}{{/canloginbyemail}}{{!
133 !}}{{#canloginbyemail}}{{#cleanstr}}usernameemail{{/cleanstr}}{{/canloginbyemail}}" {{!
134 !}}autocomplete="username">
136 <div class="login-form-password form-group">
137 <label for="password" class="sr-only">{{#str}} password {{/str}}</label>
138 <input type="password" name="password" id="password" value="" {{!
139 !}}class="form-control form-control-lg" {{!
140 !}}placeholder="{{#cleanstr}}password{{/cleanstr}}" {{!
141 !}}autocomplete="current-password">
143 <div class="login-form-submit form-group">
144 <button class="btn btn-primary btn-lg" type="submit" id="loginbtn">{{#str}}login{{/str}}</button>
146 <div class="login-form-forgotpassword form-group">
147 <a href="{{forgotpasswordurl}}">{{#str}}forgotaccount{{/str}}</a>
150 {{#hasidentityproviders}}
151 <div class="login-divider"></div>
152 <div class="login-identityproviders">
153 <h2 class="login-heading">{{#str}} potentialidps, auth {{/str}}</h2>
154 {{#identityproviders}}
155 <a class="btn login-identityprovider-btn btn-block" href="{{url}}">
157 <img src="{{iconurl}}" alt="" width="24" height="24"/>
161 {{/identityproviders}}
163 {{/hasidentityproviders}}
165 <div class="login-divider"></div>
166 <div class="login-instructions {{#cansignup}}mb-3{{/cansignup}}">
167 <h2 class="login-heading">{{#str}}firsttime{{/str}}</h2>
172 <div class="login-signup">
173 <a class="btn btn-secondary" href="{{signupurl}}">{{#str}}startsignup{{/str}}</a>
177 <div class="login-divider"></div>
178 <h2 class="login-heading">{{#str}}someallowguest{{/str}}</h2>
179 <form action="{{loginurl}}" method="post" id="guestlogin">
180 <input type="hidden" name="logintoken" value="{{logintoken}}">
181 <input type="hidden" name="username" value="guest" />
182 <input type="hidden" name="password" value="guest" />
183 <button class="btn btn-secondary" type="submit">{{#str}}loginguest{{/str}}</button>
186 <div class="login-divider"></div>
189 <div class="login-languagemenu">
190 {{>core/action_menu}}
192 <div class="divider border-left align-self-center mx-3"></div>
194 <button type="button" class="btn btn-secondary" {{!
195 }} data-modal="alert"{{!
196 }} data-modal-title-str='["cookiesenabled", "core"]' {{!
197 }} data-modal-content-str='["cookiesenabled_help_html", "core"]'{{!
198 }}>{{#str}}cookiesnotice{{/str}}</button>
205 var userNameField = document.getElementById('username');
206 if (userNameField.value.length == 0) {
207 userNameField.focus();
209 document.getElementById('password').focus();
214 document.getElementById('loginerrormessage').focus();