-
-
Notifications
You must be signed in to change notification settings - Fork 41
/
index.html
171 lines (143 loc) · 5.24 KB
/
index.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>{{ login.Title }}</title>
<!-- Bootstrap -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootswatch@4.3.1/dist/sandstone/bootstrap.min.css"
integrity="sha256-qgpZ1V8XkWmm9APL5rLtRW+Tyhp+0TPKJm4JMprrSOw=" crossorigin="anonymous">
<style>
html, body {
background-color: #f2f2f2;
height: 100%;
margin: 0;
padding: 0;
}
</style>
</head>
<body>
{% verbatim %}
<div class="container h-100">
<div class="row h-100 justify-content-center align-items-center">
<div>
<div class="col-12 text-center mb-3">
<h1>{{ login.title }}</h1>
</div>
<div class="card" style="width: 30rem;">
<div class="card-header" v-if="loginMethods.length > 1">
<div class="input-group">
<div class="input-group-prepend">
<div class="input-group-text">Login with</div>
</div>
<select class="form-control" v-model="active_method">
<option
:key="method.name"
:value="method.name"
v-for="method in loginMethods"
>
{{ method.label }}
</option>
</select>
</div>
</div> <!-- ./card-header -->
<div class="card-body">
<div class="card-text">
<form action="/login" method="post">
<input type="hidden" name="go" :value="go">
<div
class="form-group"
:key="field.name"
v-for="field in activeFields"
>
<label :for="`${active_method}-${field.name}`" v-if="field.label">
{{ field.label }}
</label>
<input
:class="fieldClasses(field)"
:onclick="field.action"
:id="`${active_method}-${field.name}`"
:name="`${active_method}-${field.name}`"
:placeholder="field.placeholder"
:type="field.type"
:value="field.type == 'button' ? field.placeholder : ''"
/>
</div>
<div class="form-group text-center" v-if="needsLoginButton">
<button type="submit" class="btn btn-success btn-lg">Login</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div> <!-- /.container -->
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://cdn.jsdelivr.net/npm/jquery@3.4.0/dist/jquery.min.js"
integrity="sha256-BJeo0qm959uMBGb65z40ejJYGSgR7REI4+CW1fNKwOg=" crossorigin="anonymous"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.3.1/dist/js/bootstrap.min.js"
integrity="sha256-CjSoeELFOcH0/uxWu6mC/Vlrc1AARqbm/jiiImDGV3s=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.10/dist/vue.min.js"
integrity="sha256-chlNFSVx3TdcQ2Xlw7SvnbLAavAQLO0Y/LBiWX04viY=" crossorigin="anonymous"></script>
{% endverbatim %}
<script>
function sortOrder(i, j) {
switch (true) {
case i < j:
return -1
case j < i:
return 1
default:
return 0
}
}
var app = new Vue({
computed: {
activeFields() {
return this.available_methods[this.active_method]
},
loginMethods() {
var res = []
for (name in this.available_methods) {
if (this.login.names[name]) {
res.push({ name, label: this.login.names[name] })
}
}
res.sort(function(i, j) { return sortOrder(i.name, j.name) })
return res
},
needsLoginButton() {
for (idx in this.activeFields) {
var field = this.activeFields[idx]
if (field.type == 'button') {
return false
}
}
return true
},
},
data: {
active_method: '{{ login.DefaultMethod }}',
available_methods: {{ active_methods | to_json | safe }},
go: '{{ go }}',
login: {{ login | to_json | safe }},
},
el: ".container",
methods: {
fieldClasses(field) {
var classes = ['form-control']
if (field.type == 'button') {
classes.push('btn')
classes.push('btn-success')
}
return classes.join(' ')
}
},
})
</script>
</body>
</html>