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 * rememberusername - Remeber username?,
37 * signupurl - Signup url,
38 * cookieshelpiconformatted - Formatted html of cookies help icon,
39 * errorformatted - Formatted error,
40 * logourl - Flag, logo url,
41 * sitename - Name of site.,
42 * logintoken - Random token to protect login request.,
43 * maintenance - Maintenance message
45 Example context (json):
47 "autofocusform": false,
48 "canloginasguest": "1",
49 "canloginbyemail": false,
52 "heading": "Cookies must be enabled in your browser",
53 "text": "<div class=\"no-overflow\">Two cookies are used on this site. Both died..</div>",
62 "value": "Help with Cookies must be enabled in your browser"
66 "value": "Help with Cookies must be enabled in your browser"
70 "value": "http://localhost/stable_master/theme/image.php?theme=boost&component=core&image=help"
75 "title": "Help with Cookies must be enabled in your browser",
76 "url": "http://localhost/stable_master/help.php?component=core&identifier=cookiesenabled&lang=en",
80 "forgotpasswordurl": "http://localhost/stable_master/login/forgot_password.php",
81 "hasidentityproviders": false,
82 "hasinstructions": true,
83 "identityproviders": [],
84 "instructions": "For full access to this site, you first need to create an account.",
85 "instructionsformat": "1",
86 "loginurl": "http://localhost/stable_master/login/index.php",
87 "rememberusername": true,
88 "signupurl": "http://localhost/stable_master/login/signup.php",
89 "cookieshelpiconformatted": "",
92 "sitename": "Beer & Chips",
93 "logintoken": "randomstring",
94 "maintenance": "For full access to this site, you need to login in as an admin."
98 <div class="my-1 my-sm-5"></div>
99 <div class="row justify-content-center">
100 <div class="col-xl-6 col-sm-8 ">
102 <div class="card-block">
104 <h1 class="h2 card-header text-center" >
105 <span class="sr-only">{{sitename}}: {{#str}} login {{/str}}</span>
106 <img src="{{logourl}}" class="img-fluid" alt=""/>
110 <h1 class="h2 card-header text-center" aria-label="{{sitename}}: {{#str}} login {{/str}}">{{sitename}}</h1>
112 <div class="card-body">
114 <div class="sr-only">
115 <a href="{{signupurl}}">{{#str}} tocreatenewaccount {{/str}}</a>
120 <div class="loginerrors mt-3">
121 <a href="#" id="loginerrormessage" class="accesshide">{{error}}</a>
122 <div class="alert alert-danger" role="alert" data-aria-autofocus="true">{{error}}</div>
126 <div class="row justify-content-md-center">
127 <div class="col-md-5">
128 <form class="mt-3" action="{{loginurl}}" method="post" id="login">
129 <input id="anchor" type="hidden" name="anchor" value="">
130 <script>document.getElementById('anchor').value = location.hash;</script>
131 <input type="hidden" name="logintoken" value="{{logintoken}}">
132 <div class="form-group">
133 <label for="username" class="sr-only">
135 {{#str}} username {{/str}}
138 {{#str}} usernameemail {{/str}}
141 <input type="text" name="username" id="username"
144 placeholder="{{^canloginbyemail}}{{#cleanstr}}username{{/cleanstr}}{{/canloginbyemail}}{{#canloginbyemail}}{{#cleanstr}}usernameemail{{/cleanstr}}{{/canloginbyemail}}"
145 autocomplete="username">
147 <div class="form-group">
148 <label for="password" class="sr-only">{{#str}} password {{/str}}</label>
149 <input type="password" name="password" id="password" value=""
151 placeholder="{{#cleanstr}}password{{/cleanstr}}"
152 autocomplete="current-password">
154 {{#rememberusername}}
155 <div class="rememberpass mt-3">
156 <input type="checkbox" name="rememberusername" id="rememberusername" value="1" {{#username}}checked="checked"{{/username}} />
157 <label for="rememberusername">{{#str}} rememberusername, admin {{/str}}</label>
159 {{/rememberusername}}
161 <button type="submit" class="btn btn-primary btn-block mt-3" id="loginbtn">{{#str}}login{{/str}}</button>
165 <div class="col-md-5">
166 <div class="forgetpass mt-3">
167 <p><a href="{{forgotpasswordurl}}">{{#str}}forgotten{{/str}}</a></p>
171 {{#str}} cookiesenabled {{/str}}
172 {{{cookieshelpiconformatted}}}
176 <p>{{#str}}someallowguest{{/str}}</p>
177 <form action="{{loginurl}}" method="post" id="guestlogin">
178 <input type="hidden" name="logintoken" value="{{logintoken}}">
179 <input type="hidden" name="username" value="guest" />
180 <input type="hidden" name="password" value="guest" />
181 <button class="btn btn-secondary btn-block" type="submit" id="loginguestbtn">{{#str}}loginguest{{/str}}</button>
186 {{#hasidentityproviders}}
187 <h2 class="h6 mt-2">{{#str}} potentialidps, auth {{/str}}</h2>
188 <div class="potentialidplist mt-3">
189 {{#identityproviders}}
190 <div class="potentialidp">
191 <a href="{{url}}" title="{{name}}" class="btn btn-secondary btn-block">
193 <img src="{{iconurl}}" alt="" width="24" height="24"/>
198 {{/identityproviders}}
200 {{/hasidentityproviders}}
211 <div class="row justify-content-center mt-3">
212 <div class="col-xl-6 col-sm-8">
214 <div class="card-body">
215 <div class="card-title">
216 <h2>{{#str}}firsttime{{/str}}</h2>
221 <form class="mt-3" action="{{signupurl}}" method="get" id="signup">
222 <button type="submit" class="btn btn-secondary">{{#str}}startsignup{{/str}}</button>
233 <div class="row justify-content-center mt-3">
234 <div class="col-xl-6 col-sm-8">
236 <div class="card-body">
237 <div class="card-title">
238 <h2>{{#str}}sitemaintenance, core_admin{{/str}}</h2>
250 require(['jquery'], function($) {
251 $('#loginerrormessage').focus();
256 require(['jquery'], function($) {
257 if ($('#username').val()) {
258 $('#password').focus();
260 $('#username').focus();
265 require(['core_form/submit'], function(Submit) {
266 Submit.init("loginbtn");
267 Submit.init("loginguestbtn");