Proyectos de Subversion Moodle

Rev

Rev 1 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
{{!
2
    This file is part of Moodle - http://moodle.org/
3
 
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.
8
 
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.
13
 
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/>.
16
}}
17
{{!
18
    @template core/loginform
19
 
20
    Moodle template for the login page.
21
 
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?,
1441 ariadna 27
    * showloginform - Hide the standard login form if it not necessary (only OAuth2 for example)
1 efrain 28
    * cookieshelpicon - cookies help icon details
29
    * error - Any errors in the form?,
30
    * info - Info notification to display,
31
    * forgotpasswordurl - Forgot password url,
32
    * hasidentityproviders - Flag, set to true to hide identity providers,
33
    * hasinstructions - Flag, set to true to show instructions,
34
    * identityproviders - List of identiy providers,
35
    * instructions - Instructions,
36
    * instructionsformat - Format of instructions,
37
    * loginurl - Login url,
38
    * signupurl - Signup url,
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
44
 
45
    Example context (json):
46
    {
47
        "autofocusform": false,
48
        "canloginasguest": "1",
49
        "canloginbyemail": false,
50
        "cansignup": true,
1441 ariadna 51
        "showloginform": true,
1 efrain 52
        "cookieshelpicon": {
53
            "heading": "Cookies must be enabled in your browser",
54
            "text": "<div class=\"no-overflow\">Two cookies are used on this site. Both died..</div>",
55
            "icon": {
56
                "attributes": [
57
                    {
58
                        "name": "class",
1441 ariadna 59
                        "value": ""
1 efrain 60
                    },
61
                    {
62
                        "name": "alt",
63
                        "value": "Help with Cookies must be enabled in your browser"
64
                    },
65
                    {
66
                        "name": "title",
67
                        "value": "Help with Cookies must be enabled in your browser"
68
                    },
69
                    {
70
                        "name": "src",
71
                        "value": "http://localhost/stable_master/theme/image.php?theme=boost&component=core&image=help"
72
                    }
73
                ]
74
            },
75
            "linktext": null,
76
            "title": "Help with Cookies must be enabled in your browser",
77
            "url": "http://localhost/stable_master/help.php?component=core&identifier=cookiesenabled&lang=en",
78
            "ltr": true
79
        },
80
        "error": "",
81
        "info": "",
82
        "forgotpasswordurl": "http://localhost/stable_master/login/forgot_password.php",
83
        "hasidentityproviders": false,
84
        "hasinstructions": true,
85
        "identityproviders": [],
86
        "instructions": "For full access to this site, you first need to create an account.",
87
        "instructionsformat": "1",
88
        "loginurl": "http://localhost/stable_master/login/index.php",
89
        "signupurl": "http://localhost/stable_master/login/signup.php",
90
        "cookieshelpiconformatted": "",
91
        "errorformatted": "",
92
        "logourl": false,
93
        "sitename": "Beer & Chips",
94
        "logintoken": "randomstring",
95
        "maintenance": "For full access to this site, you need to login in as an admin.",
96
        "languagemenu": "Choose language",
97
        "togglepassword": true,
98
        "smallscreensonly": true
99
    }
100
}}
101
 
102
<div class="loginform">
103
    {{#logourl}}
104
        <div id="loginlogo" class="login-logo">
105
            <img id="logoimage" src="{{logourl}}" class="img-fluid" alt="{{sitename}}"/>
1441 ariadna 106
            <h1 class="login-heading visually-hidden">{{#str}} loginto, core, {{sitename}} {{/str}}</h1>
1 efrain 107
        </div>
108
    {{/logourl}}
109
    {{^logourl}}
110
        <h1 class="login-heading mb-4">{{#str}} loginto, core, {{sitename}} {{/str}}</h1>
111
    {{/logourl}}
112
    {{#maintenance}}
113
        <div class="alert alert-danger login-maintenance">
114
            {{{maintenance}}}
115
        </div>
116
    {{/maintenance}}
117
    {{#error}}
1441 ariadna 118
        <a href="#" id="loginerrormessage" class="visually-hidden">{{error}}</a>
1 efrain 119
        <div class="alert alert-danger" role="alert">{{error}}</div>
120
    {{/error}}
121
    {{#info}}
1441 ariadna 122
        <a href="#" id="logininfomessage" class="visually-hidden">{{info}}</a>
1 efrain 123
        <div class="alert alert-info" role="alert">{{info}}</div>
124
    {{/info}}
125
    {{#cansignup}}
1441 ariadna 126
        <a href="{{signupurl}}" class="visually-hidden">{{#str}} tocreatenewaccount {{/str}}</a>
1 efrain 127
    {{/cansignup}}
1441 ariadna 128
    {{#showloginform}}
129
        <form class="login-form" action="{{loginurl}}" method="post" id="login">
130
            <input id="anchor" type="hidden" name="anchor" value="">
131
            <script>document.getElementById('anchor').value = location.hash;</script>
132
            <input type="hidden" name="logintoken" value="{{logintoken}}">
133
            <div class="login-form-username mb-3">
134
                <label for="username" class="visually-hidden">
135
                    {{^canloginbyemail}}
136
                        {{#str}} username {{/str}}
137
                    {{/canloginbyemail}}
138
                    {{#canloginbyemail}}
139
                        {{#str}} usernameemail {{/str}}
140
                    {{/canloginbyemail}}
141
                </label>
142
                <input type="text" name="username" id="username" {{!
143
                    !}}class="form-control form-control-lg" {{!
144
                    !}}value="{{username}}" {{!
145
                    !}}placeholder="{{^canloginbyemail}}{{#cleanstr}}username{{/cleanstr}}{{/canloginbyemail}}{{!
146
                    !}}{{#canloginbyemail}}{{#cleanstr}}usernameemail{{/cleanstr}}{{/canloginbyemail}}" {{!
147
                    !}}autocomplete="username">
1 efrain 148
            </div>
1441 ariadna 149
            <div class="login-form-password mb-3">
150
                <label for="password" class="visually-hidden">{{#str}} password {{/str}}</label>
151
                <input type="password" name="password" id="password" value="" {{!
152
                    !}}class="form-control form-control-lg" {{!
153
                    !}}placeholder="{{#cleanstr}}password{{/cleanstr}}" {{!
154
                    !}}autocomplete="current-password">
155
            </div>
156
            {{#recaptcha}}
157
                <div class="login-form-recaptcha mb-3">
158
                    {{{recaptcha}}}
159
                </div>
160
            {{/recaptcha}}
161
            <div class="login-form-submit mb-3">
162
                <button class="btn btn-primary btn-lg" type="submit" id="loginbtn">{{#str}}login{{/str}}</button>
163
            </div>
164
            <div class="login-form-forgotpassword mb-3">
165
                <a href="{{forgotpasswordurl}}">{{#str}}forgotaccount{{/str}}</a>
166
            </div>
167
        </form>
168
    {{/showloginform}}
1 efrain 169
    {{#hasidentityproviders}}
170
        <div class="login-divider"></div>
171
        <div class="login-identityproviders">
172
            <h2 class="login-heading">{{#str}} potentialidps, auth {{/str}}</h2>
173
            {{#identityproviders}}
1441 ariadna 174
                <a class="btn login-identityprovider-btn w-100" href="{{url}}">
1 efrain 175
                    {{#iconurl}}
176
                        <img src="{{iconurl}}" alt="" width="24" height="24"/>
177
                    {{/iconurl}}
178
                    {{name}}
179
                </a>
180
            {{/identityproviders}}
181
        </div>
182
    {{/hasidentityproviders}}
183
    {{#hasinstructions}}
184
        <div class="login-divider"></div>
185
        <div class="login-instructions {{#cansignup}}mb-3{{/cansignup}}">
186
            <h2 class="login-heading">{{#str}}firsttime{{/str}}</h2>
187
            {{{instructions}}}
188
        </div>
189
    {{/hasinstructions}}
190
    {{#cansignup}}
191
        <div class="login-signup">
192
            <a class="btn btn-secondary" href="{{signupurl}}">{{#str}}startsignup{{/str}}</a>
193
        </div>
194
    {{/cansignup}}
195
    {{#canloginasguest}}
196
        <div class="login-divider"></div>
197
        <h2 class="login-heading">{{#str}}someallowguest{{/str}}</h2>
198
        <form action="{{loginurl}}" method="post" id="guestlogin">
199
            <input type="hidden" name="logintoken" value="{{logintoken}}">
200
            <input type="hidden" name="username" value="guest" />
201
            <input type="hidden" name="password" value="guest" />
202
            <button class="btn btn-secondary" type="submit" id="loginguestbtn">{{#str}}loginguest{{/str}}</button>
203
        </form>
204
    {{/canloginasguest}}
205
    <div class="login-divider"></div>
206
    <div class="d-flex">
207
        {{#languagemenu}}
208
            <div class="login-languagemenu">
209
                {{>core/action_menu}}
210
            </div>
1441 ariadna 211
            <div class="divider border-start align-self-center mx-3"></div>
1 efrain 212
        {{/languagemenu}}
213
        <button type="button" class="btn btn-secondary" {{!
214
        }} data-modal="alert"{{!
215
        }} data-modal-title-str='["cookiesenabled", "core"]' {{!
216
        }} data-modal-content-str='["cookiesenabled_help_html", "core"]'{{!
217
        }}>{{#str}}cookiesnotice{{/str}}</button>
218
    </div>
219
</div>
220
 
221
{{#js}}
222
    {{^error}}
223
        {{#autofocusform}}
224
            require(['core_form/events'], function(FormEvent) {
225
                function autoFocus() {
226
                    const userNameField = document.getElementById('username');
227
                    if (userNameField.value.length == 0) {
228
                        userNameField.focus();
229
                    } else {
230
                        document.getElementById('password').focus();
231
                    }
232
                }
233
                autoFocus();
234
                window.addEventListener(FormEvent.eventTypes.fieldStructureChanged, autoFocus);
235
            });
236
        {{/autofocusform}}
237
    {{/error}}
238
    {{#error}}
239
        document.getElementById('loginerrormessage').focus();
240
    {{/error}}
241
    {{#togglepassword}}
242
        require(['core/togglesensitive'], function(ToggleSensitive) {
243
            ToggleSensitive.init("password", {{smallscreensonly}});
244
        });
245
    {{/togglepassword}}
246
    require(['core_form/submit'], function(Submit) {
247
        Submit.init("loginbtn");
248
        {{#canloginasguest}}
249
            Submit.init("loginguestbtn");
250
        {{/canloginasguest}}
251
    });
252
{{/js}}