-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.html
111 lines (106 loc) · 4.4 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="robots" content="noindex">
<title>{{ title }}</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="web/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<link rel="stylesheet" href="web/css/font-awesome.min.css">
<style type="text/css">
body {
height: 100vh;
background: url("web/images/background.jpg") 50% fixed;
background-size: cover;
}
.wrapper {
display: flex;
align-items: center;
flex-direction: column;
width: 100%;
min-height: 100%;
padding: 20px;
background: rgba(4, 40, 68, 0.85);
}
</style>
<script src="web/js/jquery.min.js"></script>
<script src="web/js/bootstrap.min.js"></script>
</head>
<body>
<div class="wrapper">
<div class="container">
<div id="loginbox" style="margin-top:50px;" class="mainbox col-md-6 col-md-offset-3 col-sm-8 col-sm-offset-2">
<div class="panel panel-info" >
<div class="panel-heading">
<div class="panel-title" align="center"><b>{{ title }}</b></div>
</div>
<div style="padding-top:30px" class="panel-body" >
<div id="message" class="alert alert-info col-sm-12" align="center">{{ welcome_message }}</div>
<form id="loginform" class="form-horizontal" role="form">
<div style="margin-bottom: 25px" class="input-group">
<span class="input-group-addon"><i class="fa fa-key"></i></span>
<input id="otp" type="text" class="form-control" name="otp" placeholder="{{ otp_placeholder }}">
</div>
<div style="margin-top:10px" class="form-group">
<div class="col-sm-12 controls">
<button id="register" class="btn btn-primary" style="display: block; width: 100%;">{{ register_button }}</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript">
function getParameter(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
}
var working = false;
$("#register").unbind().on('click', function(e) {
// enter loading status
e.preventDefault();
$("#register").html('<span class="fa fa-refresh fa-spin"></span> {{ registering_message }}')
$("#register").addClass("disabled")
// retrieve parameters from query string
var mac = getParameter("mac");
var ip = getParameter("ip");
var authaction = getParameter("authaction");
var tok = getParameter("tok");
var redir = getParameter("redir");
var gatewayname = getParameter("gatewayname");
// retrieve otp
var otp = $("#otp").val()
//validate otp
setTimeout(function() {
var url = "/register?otp="+otp+"&mac="+mac+"&ip="+ip+"&tok="+tok+"&gatewayname="+gatewayname
$.get(url, function( data ) {
if (data == "0") {
$("#message").html('<i class="fa fa-check"></i> {{ registered_successfully }}')
$("#message").removeClass('hidden alert-danger alert-success alert-info')
$("#message").addClass('alert-success')
$("#loginform").addClass('hidden')
// redirect to $authaction
window.location.href = authaction+"?"+tok+"&redir="+redir+"&mac="+mac+"&ip="+ip+"&tok="+tok+"&gatewayname="+gatewayname;
} else {
var error;
if (data == "1") error = "{{ error_invalid_parameter }}";
if (data == "2") error = "{{error_invalid_otp }}";
$("#message").html('<i class="fa fa-exclamation-triangle"></i> {{ error_banner }}: '+error)
$("#message").removeClass('hidden alert-danger alert-success alert-info')
$("#message").addClass('alert-danger')
$("#register").html('Register')
$("#register").removeClass("disabled")
}
});
}, 1000);
});
</script>
</body>
</html>