-
Notifications
You must be signed in to change notification settings - Fork 85
/
login.html
142 lines (124 loc) · 4.31 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
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
<div class="login container">
<div class="span7">
<div class="header"></div>
<div class="form">
<form class="loginForm form-horizontal">
<legend>Login</legend>
<div class="form-group serverDiv">
<label class="col-lg-2 control-label">Server</label>
<div class="col-lg-4" style="padding-top: 5px">
<span class="serverAddress"></span>
<a class="otherServerLink">Other server</a>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label" for="inputEmail">Username</label>
<div class="col-lg-4">
<div class="input-group">
<span class="input-group-addon">@</span>
<input type="email" class="form-control username" id="inputEmail" placeholder="Username (e-mail address)">
</div>
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label" for="inputPassword">Password</label>
<div class="col-lg-4">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-lock"></i></span>
<input type="password" class="form-control password" id="inputPassword" placeholder="Password">
</div>
</div>
</div>
<div class="form-group">
<div class="col-lg-offset-2 col-lg-10">
<label class="checkbox"> <input type="checkbox" class="rememberme" id="rememberMe"> Remember me
</label>
<button type="button" class="btn loginButton btn-primary">Sign in</button>
<button type="button" class="btn btn-default resetPasswordButton">Reset password</button>
<button type="button" class="btn btn-default registerButton initialhide">Register</button>
</div>
</div>
</form>
</div>
</div>
</div>
<script>
function Login(address, username, originalUrl) {
var othis = this;
if (address != null && address.startsWith("http://")) {
address = address.substring(7);
}
this.show = function(){};
this.login = function(address) {
Global.bimServerApi.login($(".username").val(), $("#inputPassword").val(), function(data){
if ($("#rememberMe").is(":checked")) {
// Stored cookie
$.cookie("autologin" + window.document.location.port, Global.bimServerApi.token, { expires: 31});
$.cookie("address" + window.document.location.port, Global.bimServerApi.baseUrl, { expires: 31});
} else {
// Session cookie
$.cookie("autologin" + window.document.location.port, Global.bimServerApi.token, { });
$.cookie("address" + window.document.location.port, Global.bimServerApi.baseUrl, { });
}
Global.bimServerApi.resolveUser(function(user){
if (originalUrl != null) {
window.location = originalUrl;
} else {
$(".indexcontainer").load(Global.baseDir + "main.html", function(){
new Main(address, user).show(false);
});
}
});
});
}
if (address != null) {
$(".serverAddress").html(address);
}
if (!Settings.allowBimServerAddress()) {
$(".serverDiv").hide();
}
if (username != null) {
$("#inputEmail").val(username);
}
$(".header").load(Global.baseDir + "header.html");
$(".loginButton").click(function(){
othis.login($("#inputServer").val());
});
$(".login .username, .login .address, .login .password, .login .rememberme").enterpress(function(){
othis.login($("#inputServer").val());
});
this.resetPassword = function(){
Global.bimServerApi.callWithFullIndication("AuthInterface", "requestPasswordChange", {username: $(".username").val(), resetUrl: Global.baseDir + "?page=ResetPassword", includeSiteAddress: false}, function(){
});
};
this.openIdClick = function(){
$(".openidDiv").show();
$(".loginForm").hide();
};
this.registerClick = function(){
$(".indexcontainer").load(Global.baseDir + "register.html", function(){
new Register($(this));
});
};
$(".registerButton").click(othis.registerClick);;
$(".resetPasswordButton").click(function(){
othis.resetPassword();
});
Global.bimServerApi.call("SettingsInterface", "isAllowSelfRegistration", {}, function(enabled){
if (enabled) {
$(".registerButton").show();
}
});
if (username == null) {
$("#inputEmail").focus();
} else {
$("#inputPassword").focus();
}
pushHistory({page: "Login"}, "Login");
$(".otherServerLink").click(function(){
$(".indexcontainer").load(Global.baseDir + "selectserver.html", function(){
new SelectServer();
});
});
}
</script>