Moodle release 3.3rc1
[moodle.git] / theme / boost / templates / core / login.mustache
blob90fb24c96c59606f9496a52fea3a2757e7c5f619
1 {{!
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/>.
17 {{!
18     @template core/login
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.
43     Example context (json):
44     {
45         "autofocusform": false,
46         "canloginasguest": "1",
47         "canloginbyemail": false,
48         "cansignup": true,
49         "cookieshelpicon": {
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>",
52             "icon": {
53                 "attributes": [
54                     {
55                         "name": "class",
56                         "value": "iconhelp"
57                     },
58                     {
59                         "name": "alt",
60                         "value": "Help with Cookies must be enabled in your browser"
61                     },
62                     {
63                         "name": "title",
64                         "value": "Help with Cookies must be enabled in your browser"
65                     },
66                     {
67                         "name": "src",
68                         "value": "http://localhost/stable_master/theme/image.php?theme=boost&component=core&image=help"
69                     }
70                 ]
71             },
72             "linktext": null,
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",
75             "ltr": true
76         },
77         "error": "",
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         "rememberusername": true,
86         "signupurl": "http://localhost/stable_master/login/signup.php",
87         "cookieshelpiconformatted": "",
88         "errorformatted": "",
89         "logourl": false,
90         "sitename": "Beer & Chips"
91     }
94 <div class="m-y-3 hidden-sm-down"></div>
95 <div class="row">
96 <div class="col-xl-6 push-xl-3 m-2-md col-sm-8 push-sm-2">
97 <div class="card">
98     <div class="card-block">
99         <div class="card-title text-xs-center">
100             {{#logourl}}
101                 <h2><img src="{{logourl}}" title="{{sitename}}" alt="{{sitename}}"/></h2>
102             {{/logourl}}
103             {{^logourl}}
104                 <h2>{{sitename}}</h2>
105             {{/logourl}}
106             <hr>
107         </div>
109         {{#cansignup}}
110             <div class="sr-only">
111                 <a href="{{signupurl}}">{{#str}} tocreatenewaccount {{/str}}</a>
112             </div>
113         {{/cansignup}}
115         {{#error}}
116             <div class="loginerrors m-t-1">
117                 <a href="#" id="loginerrormessage" class="accesshide">{{error}}</a>
118                 <div class="alert alert-danger" role="alert">{{error}}</div>
119             </div>
120         {{/error}}
122         <div class="row">
123             <div class="col-md-4 push-md-1">
124                 <form class="m-t-1" action="{{loginurl}}" method="post" id="login">
125                     <input id="anchor" type="hidden" name="anchor" value="">
126                     <script>document.getElementById('anchor').value = location.hash;</script>
128                     <label for="username" class="sr-only">
129                         {{^canloginbyemail}}
130                             {{#str}} username {{/str}}
131                         {{/canloginbyemail}}
132                         {{#canloginbyemail}}
133                             {{#str}} usernameemail {{/str}}
134                         {{/canloginbyemail}}
135                     </label>
136                     <input type="text" name="username" id="username"
137                         class="form-control"
138                         value="{{username}}"
139                         placeholder={{#quote}}{{^canloginbyemail}}{{#str}}username{{/str}}{{/canloginbyemail}}{{#canloginbyemail}}{{#str}}usernameemail{{/str}}{{/canloginbyemail}}{{/quote}}>
140                     <label for="password" class="sr-only">{{#str}} password {{/str}}</label>
141                     <input type="password" name="password" id="password" value=""
142                         class="form-control"
143                         placeholder={{#quote}}{{#str}}password{{/str}}{{/quote}}>
145                     {{#rememberusername}}
146                         <div class="rememberpass m-t-1">
147                             <input type="checkbox" name="rememberusername" id="rememberusername" value="1" {{#username}}checked="checked"{{/username}} />
148                             <label for="rememberusername">{{#str}} rememberusername, admin {{/str}}</label>
149                         </div>
150                     {{/rememberusername}}
152                     <button type="submit" class="btn btn-primary btn-block m-t-1" id="loginbtn">{{#str}}login{{/str}}</button>
153                 </form>
154             </div>
156             <div class="col-md-4 push-md-3">
157                 <div class="forgetpass m-t-1">
158                     <p><a href="{{forgotpasswordurl}}">{{#str}}forgotten{{/str}}</a></p>
159                 </div>
161                 <div class="m-t-1">
162                     {{#str}} cookiesenabled {{/str}}
163                     {{{cookieshelpiconformatted}}}
164                 </div>
165             {{#canloginasguest}}
166                 <div class="m-t-2">
167                     <p>{{#str}}someallowguest{{/str}}</p>
168                     <form action="{{loginurl}}" method="post" id="guestlogin">
169                         <input type="hidden" name="username" value="guest" />
170                         <input type="hidden" name="password" value="guest" />
171                         <button class="btn btn-secondary btn-block" type="submit">{{#str}}loginguest{{/str}}</button>
172                     </form>
173                 </div>
174             {{/canloginasguest}}
176         {{#hasidentityproviders}}
177                 <h6 class="m-t-2">{{#str}} potentialidps, auth {{/str}}</h6>
178                 <div class="potentialidplist" class="m-t-1">
179                     {{#identityproviders}}
180                         <div class="potentialidp">
181                             <a href="{{url}}" title={{#quote}}{{name}}{{/quote}} class="btn btn-secondary btn-block">
182                                 {{#iconurl}}
183                                     <img src="{{iconurl}}" alt="" width="24" height="24"/>
184                                 {{/iconurl}}
185                                 {{name}}
186                             </a>
187                         </div>
188                     {{/identityproviders}}
189                 </div>
190         {{/hasidentityproviders}}
191             </div>
192         </div>
193     </div>
194 </div>
195 </div>
196 </div>
199 {{#hasinstructions}}
200 <div class="row">
201 <div class="col-xl-6 push-xl-3 m-2-md col-sm-8 push-sm-2">
202 <div class="card">
203     <div class="card-block">
204         <div class="card-title">
205             <h2>{{#str}}firsttime{{/str}}</h2>
206         </div>
207         <div>
208         {{{instructions}}}
209         {{#cansignup}}
210             <form class="m-t-1" action="{{signupurl}}" method="get" id="signup">
211                 <button type="submit" class="btn btn-secondary">{{#str}}startsignup{{/str}}</button>
212             </form>
213         {{/cansignup}}
214         </div>
215     </div>
216 </div>
217 </div>
218 </div>
219 {{/hasinstructions}}
221 {{#js}}
222     {{#error}}
223         require(['jquery'], function($) {
224             $('#loginerrormessage').focus();
225         });
226     {{/error}}
227     {{^error}}
228         {{#autofocusform}}
229             require(['jquery'], function($) {
230                 if ($('#username').val()) {
231                     $('#password').focus();
232                 } else {
233                     $('#username').focus();
234                 }
235             });
236         {{/autofocusform}}
237     {{/error}}
238 {{/js}}