blob: 4b40793923980b9f2e16cead66b6ff51fff9a170 (
plain)
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
|
<% page_header("plain", "SWAT Login", "");
libinclude("auth.js");
include("/scripting/forms.js");
if (request['SESSION_EXPIRED'] == "True") {
write("<b>Your session has expired - please authenticate again<br /></b>\n");
}
var f = FormObj("login", 3, 1);
f.element[0].label = "Username";
f.element[0].value = form['Username'];
f.element[1].label = "Password";
f.element[1].value = form['Password'];
f.element[1].type = "password";
f.element[2].label = "Domain";
f.element[2].type = "select";
f.element[2].list = getDomainList();
f.submit[0] = "Login";
f.display();
%>
<%
if (request.REQUEST_METHOD == "POST") {
var authinfo = new Object();
authinfo.username = form.Username;
authinfo.password = form.Password;
authinfo.domain = form.Domain;
authinfo.rhost = request['REMOTE_HOST'];
auth = userAuth(authinfo);
if (auth == undefined) {
write("<b>Invalid login - please try again<br /></b>\n");
} else if (auth.result) {
session.AUTHENTICATED = true;
session.authinfo = new Object();
session.authinfo.username = auth.username;
session.authinfo.domain = auth.domain;
session.authinfo.credentials = credentials_init();
session.authinfo.credentials.set_username(authinfo.username);
session.authinfo.credentials.set_domain(authinfo.domain);
session.authinfo.credentials.set_password(authinfo.password);
/* if the user was asking for the login page, then now
redirect them to the main page. Otherwise just
redirect them to the current page, which will now
show its true content */
if (request.REQUEST_URI == "/login.esp") {
redirect(session_uri("/"));
} else {
redirect(session_uri(request.REQUEST_URI));
}
} else {
write("<b>Login failed - please try again<br /></b>\n");
}
}
%>
<% page_footer(); %>
|