Merge branch 'MDL-62945-master' of https://github.com/HuongNV13/moodle
[moodle.git] / lib / templates / loginform.mustache
blob616e8606499e6dff780c96d3a533ca6652fdae10
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/loginform
20     Moodle template for the login page.
22     Example context (json):
23     {
24         "autofocusform": false,
25         "canloginasguest": true,
26         "canloginbyemail": true,
27         "cansignup": true,
28         "error": "testerror",
29         "errorformatted": "Test error formatted",
30         "forgotpasswordurl": "http://example.com/login/forgot_password.php",
31         "hasidentityproviders": false,
32         "hasinstructions": true,
33         "instructions": "For full access to this site, you first need to create an account.",
34         "loginurl": "http://example.com/stable_master/login/index.php",
35         "rememberusername": true,
36         "signupurl": "http://localhost/stable_master/login/signup.php",
37         "cookieshelpiconformatted": "",
38         "username": ""
39     }
41 {{#hasinstructions}}
42 <div class="loginbox clearfix twocolumns">
43 {{/hasinstructions}}
44 {{^hasinstructions}}
45 <div class="loginbox clearfix onecolumn">
46 {{/hasinstructions}}
48     <div class="loginpanel">
49         {{#cansignup}}
50             <div class="skiplinks">
51                 <a class="skip" href="{{signupurl}}">{{#str}} tocreatenewaccount {{/str}}</a>
52             </div>
53         {{/cansignup}}
55         <h2>{{#str}} login {{/str}}</h2>
57         <div class="subcontent loginsub">
58             {{#error}}
59                 <div class="loginerrors" role="alert">
60                     <a href="#" id="loginerrormessage" class="accesshide">{{error}}</a>
61                     {{{errorformatted}}}
62                 </div>
63             {{/error}}
64             <form action="{{loginurl}}" method="post" id="login">
65                 <div class="loginform">
66                     <div class="form-label">
67                         <label for="username">
68                             {{^canloginbyemail}}
69                                 {{#str}} username {{/str}}
70                             {{/canloginbyemail}}
71                             {{#canloginbyemail}}
72                                 {{#str}} usernameemail {{/str}}
73                             {{/canloginbyemail}}
74                         </label>
75                     </div>
76                     <div class="form-input">
77                         <input type="text" name="username" id="username" size="15" value="{{username}}">
78                     </div>
79                     <div class="clearer"><!-- --></div>
80                     <div class="form-label">
81                         <label for="password">{{#str}} password {{/str}}</label>
82                     </div>
83                     <div class="form-input">
84                         <input type="password" name="password" id="password" size="15" value="">
85                     </div>
86                 </div>
88                 <div class="clearer"><!-- --></div>
89                 {{#rememberusername}}
90                     <div class="rememberpass">
91                         <input type="checkbox" name="rememberusername" id="rememberusername" value="1" {{#username}}checked="checked"{{/username}} />
92                         <label for="rememberusername">{{#str}} rememberusername, admin {{/str}}</label>
93                     </div>
94                 {{/rememberusername}}
95                 <div class="clearer"><!-- --></div>
96                 <input id="anchor" type="hidden" name="anchor" value="" />
97                 <script>document.getElementById('anchor').value = location.hash;</script>
98                 <input type="submit" id="loginbtn" value={{#quote}}{{#str}} login {{/str}}{{/quote}} />
99                 <div class="forgetpass">
100                     <a href="{{forgotpasswordurl}}">{{#str}} forgotten {{/str}}</a>
101                 </div>
102             </form>
104             <div class="desc">
105                 {{#str}} cookiesenabled {{/str}}
106                 {{{cookieshelpiconformatted}}}
107             </div>
109         </div>
111         {{#canloginasguest}}
112             <div class="subcontent guestsub">
113                 <div class="desc">{{#str}} someallowguest {{/str}}</div>
114                 <form action="{{loginurl}}" method="post" id="guestlogin">
115                     <div class="guestform">
116                         <input type="hidden" name="username" value="guest" />
117                         <input type="hidden" name="password" value="guest" />
118                         <input type="submit" value={{#quote}}{{#str}} loginguest {{/str}}{{/quote}} />
119                     </div>
120                 </form>
121             </div>
122         {{/canloginasguest}}
124     </div>
126     <div class="signuppanel">
127     {{#hasinstructions}}
128         <h2>{{#str}} firsttime {{/str}}</h2>
129         <div class="subcontent">
130             {{{instructions}}}
131             {{#cansignup}}
132                 <div class="signupform">
133                     <form action="{{signupurl}}" method="get" id="signup">
134                         <div>
135                             <input type="submit" value={{#quote}}{{#str}} startsignup {{/str}}{{/quote}} />
136                         </div>
137                     </form>
138                 </div>
139             {{/cansignup}}
140         </div>
141     {{/hasinstructions}}
143     {{#hasidentityproviders}}
144         <div class="subcontent potentialidps">
145             <h6>{{#str}} potentialidps, auth {{/str}}</h6>
146             <div class="potentialidplist">
147                 {{#identityproviders}}
148                     <div class="potentialidp">
149                         <a href="{{url}}" title={{#quote}}{{name}}{{/quote}} class="btn">
150                         {{#iconurl}}
151                             <img src="{{iconurl}}" alt="" width="24" height="24"/>
152                         {{/iconurl}}
153                         {{name}}
154                         </a>
155                     </div>
156                 {{/identityproviders}}
157             </div>
158         </div>
159     {{/hasidentityproviders}}
160     </div>
161 </div>
163 {{#js}}
164     {{#error}}
165         require(['jquery'], function($) {
166             $('#loginerrormessage').focus();
167         });
168     {{/error}}
169     {{^error}}
170         {{#autofocusform}}
171             require(['jquery'], function($) {
172                 if ($('#username').val()) {
173                     $('#password').focus();
174                 } else {
175                     $('#username').focus();
176                 }
177             });
178         {{/autofocusform}}
179     {{/error}}
180 {{/js}}