122 lines
2.9 KiB
Text
122 lines
2.9 KiB
Text
|
|
<%@ page language="java" contentType="text/html; charset=UTF-8"
|
||
|
|
pageEncoding="UTF-8"%>
|
||
|
|
<%@ page import="com.stephenschafer.email.Util"%>
|
||
|
|
<%@ page import="com.stephenschafer.email.Configuration"%>
|
||
|
|
<%@ page import="com.stephenschafer.email.Session"%>
|
||
|
|
<%@ page import="com.stephenschafer.email.User"%>
|
||
|
|
<%@ page import="com.stephenschafer.email.Logger"%>
|
||
|
|
<%
|
||
|
|
final boolean failed;
|
||
|
|
final String username = request.getParameter("username");
|
||
|
|
User user = null;
|
||
|
|
if ("post".equalsIgnoreCase(request.getMethod())) {
|
||
|
|
final String password = request.getParameter("password");
|
||
|
|
user = Util.login(username, password);
|
||
|
|
failed = true;
|
||
|
|
}
|
||
|
|
else {
|
||
|
|
final String privilegedHost = Configuration.INSTANCE.getPrivilegedHost();
|
||
|
|
if (username != null && privilegedHost != null ) {
|
||
|
|
String remoteHost = request.getRemoteHost();
|
||
|
|
if (privilegedHost.equals(remoteHost)) {
|
||
|
|
user = Util.login(username);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
failed = false;
|
||
|
|
session.removeAttribute("email-session");
|
||
|
|
}
|
||
|
|
if (user != null) {
|
||
|
|
Session timesheetSession = new Session();
|
||
|
|
timesheetSession.setUser(user);
|
||
|
|
session.setAttribute("email-session", timesheetSession);
|
||
|
|
String returnServletPath = (String) session.getAttribute("return-servlet-path");
|
||
|
|
if (returnServletPath == null) {
|
||
|
|
returnServletPath = "/index.jsp";
|
||
|
|
}
|
||
|
|
String returnQueryString = (String) session.getAttribute("return-query-string");
|
||
|
|
if (returnQueryString == null) {
|
||
|
|
returnQueryString = "";
|
||
|
|
}
|
||
|
|
final String returnUrl = request.getContextPath() + returnServletPath + "?"
|
||
|
|
+ returnQueryString;
|
||
|
|
response.sendRedirect(returnUrl);
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||
|
|
<html>
|
||
|
|
<head>
|
||
|
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||
|
|
<title>Login</title>
|
||
|
|
<style>
|
||
|
|
body {
|
||
|
|
font-family: sans-serif;
|
||
|
|
font-size: 10pt;
|
||
|
|
color: #333;
|
||
|
|
}
|
||
|
|
table {
|
||
|
|
font-family: inherit;
|
||
|
|
font-size: inherit;
|
||
|
|
}
|
||
|
|
table {
|
||
|
|
border-spacing: 0px;
|
||
|
|
}
|
||
|
|
table.td {
|
||
|
|
padding: 0px;
|
||
|
|
}
|
||
|
|
div.buttons {
|
||
|
|
margin-top: 10px;
|
||
|
|
}
|
||
|
|
@media only screen and (min-resolution:2x) {
|
||
|
|
body {
|
||
|
|
font-size: 300%;
|
||
|
|
}
|
||
|
|
h1 {
|
||
|
|
display: none;
|
||
|
|
}
|
||
|
|
button {
|
||
|
|
display: block;
|
||
|
|
margin-bottom: .5em;
|
||
|
|
font-size: inherit;
|
||
|
|
}
|
||
|
|
input {
|
||
|
|
display: block;
|
||
|
|
margin-bottom: .5em;
|
||
|
|
font-size: inherit;
|
||
|
|
}
|
||
|
|
select {
|
||
|
|
display: block;
|
||
|
|
margin-bottom: .5em;
|
||
|
|
font-size: inherit;
|
||
|
|
}
|
||
|
|
label {
|
||
|
|
display: block;
|
||
|
|
margin-bottom: .5em;
|
||
|
|
font-size: inherit;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
</style>
|
||
|
|
</head>
|
||
|
|
<body>
|
||
|
|
<%
|
||
|
|
if (failed) {
|
||
|
|
%><div class="fail">That didn't work.</div>
|
||
|
|
<%
|
||
|
|
}
|
||
|
|
%><form name="login" action="login.jsp" method="post">
|
||
|
|
<table>
|
||
|
|
<tr>
|
||
|
|
<td>Username</td>
|
||
|
|
<td><input type="text" name="username" value="<%=username == null ? "" : username%>" /></td>
|
||
|
|
</tr>
|
||
|
|
<tr>
|
||
|
|
<td>Password</td>
|
||
|
|
<td><input type="password" name="password" /></td>
|
||
|
|
</tr>
|
||
|
|
</table>
|
||
|
|
<div class="buttons">
|
||
|
|
<button type="submit">Login</button>
|
||
|
|
</div>
|
||
|
|
</form>
|
||
|
|
</body>
|
||
|
|
</html>
|