-
Notifications
You must be signed in to change notification settings - Fork 614
/
login.html
115 lines (106 loc) · 4.13 KB
/
login.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
{% extends "_layouts/basecp" %}
{% import "_includes/forms" as forms %}
{% set title = "Login"|t('app') %}
{% set bodyClass = 'login' %}
{% do view.registerAssetBundle("craft\\web\\assets\\login\\LoginAsset") %}
{% do view.registerTranslations('app', [
"Reset Password",
"Check your email for instructions to reset your password.",
]) %}
{% set username = craft.app.config.general.rememberUsernameDuration ? craft.app.user.getRememberedUsername(): '' %}
{% if craft.app.config.general.useEmailAsUsername %}
{% set usernameLabel = 'Email'|t('app') %}
{% set usernameType = 'email' %}
{% else %}
{% set usernameLabel = 'Username or Email'|t('app') %}
{% set usernameType = 'text' %}
{% endif %}
{% set hasLogo = CraftEdition == CraftPro and craft.rebrand.isLogoUploaded %}
{% set formAttributes = {
id: 'login-form',
method: 'post',
'accept-charset': 'UTF-8',
} %}
{% if hasLogo %}
{% set logo = craft.rebrand.logo %}
{% set formAttributes = formAttributes|merge({
class: 'has-logo',
style: {
'background-image': "url(#{logo.url|e('css')})",
'background-size': "#{logo.width}px #{logo.height}px",
'padding-top': "#{logo.height + 30}px",
},
}) %}
{% endif %}
{% set formHtml %}
<main>
<form {{ attr(formAttributes) }}>
{% if not hasLogo %}
<h1>{{ systemName }}</h1>
{% endif %}
<div id="login-fields">
{{ forms.textField({
id: 'loginName',
name: 'username',
placeholder: usernameLabel,
value: username,
autocomplete: 'username',
type: usernameType,
inputAttributes: {
aria: {
label: usernameLabel,
},
},
}) }}
{{ forms.passwordField({
id: 'password',
name: 'password',
placeholder: 'Password'|t('app'),
autocomplete: 'current-password',
inputAttributes: {
aria: {
label: 'Password'|t('app'),
},
},
}) }}
</div>
<div id="password-fields">
{% if craft.app.config.general.rememberedUserSessionDuration %}
{{ forms.checkboxField({ id: 'rememberMe', label: 'Keep me logged in'|t('app') }) }}
{% endif %}
<a id="forgot-password">{{ 'Forgot your password?'|t('app') }}</a>
</div>
<div class="buttons">
<button id="submit" class="btn submit disabled" type="submit">{{ 'Login'|t('app') }}</button>
<div id="spinner" class="spinner hidden"></div>
</div>
<a id="poweredby" href="http://craftcms.com/" title="{{ 'Powered by Craft CMS'|t('app') }}" aria-label="{{ 'Powered by Craft CMS'|t('app') }}">
{{ svg('@app/web/assets/cp/dist/images/craftcms.svg') }}
</a>
</form>
</main>
{% endset %}
{% set noCookiesHtml %}
<main>
<div class="message-container no-access">
<div class="pane notice">
<p>{{ 'Cookies must be enabled to access the Craft CMS control panel.'|t('app') }}</p>
</div>
</div>
</main>
{% endset %}
{% block body %}
<script type="text/javascript">
var cookieTest = 'CraftCookieTest='+Math.floor(Math.random() * 1000000);
document.cookie = cookieTest;
if (document.cookie.search(cookieTest) != -1) {
document.cookie = cookieTest + '=; expires=Thu, 01 Jan 1970 00:00:01 GMT;';
document.write({{ formHtml|json_encode|raw }});
{% if not craft.app.request.isMobileBrowser(true) %}
document.getElementById("{{ (username ? 'password' : 'loginName') }}").focus();
{% endif %}
} else {
document.write({{ noCookiesHtml|json_encode|raw }});
}
</script>
{% endblock %}