NIHVIVO-638 Check in first phase of changes to the Login form and backend.
This commit is contained in:
parent
2253f889ed
commit
74c7660321
12 changed files with 999 additions and 342 deletions
BIN
webapp/web/images/iconAlert.png
Normal file
BIN
webapp/web/images/iconAlert.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
|
@ -2,120 +2,14 @@
|
|||
|
||||
<%-- Included in siteAdmin/main.jsp to handle login/logout form and processing --%>
|
||||
|
||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.login.LoginTemplateHelper" %>
|
||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.VitroRequest" %>
|
||||
|
||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.Portal" %>
|
||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.Controllers" %>
|
||||
|
||||
<c:url var="loginJSP" value="<%= Controllers.LOGIN_JSP %>" />
|
||||
<c:set var="loginFormTitle" value="<h3>Please log in</h3>" />
|
||||
|
||||
|
||||
|
||||
<%
|
||||
int securityLevel = loginHandler.ANYBODY;
|
||||
String loginStatus = loginHandler.getLoginStatus();
|
||||
if ( loginStatus.equals("authenticated")) {
|
||||
%>
|
||||
<div id="logoutPanel">
|
||||
<%
|
||||
} else {
|
||||
String themeDir = new VitroRequest(request).getPortal().getThemeDir().replaceAll("/$", "");
|
||||
%>
|
||||
<div id="loginPanel" class="pageBodyGroup">
|
||||
<%
|
||||
}
|
||||
if ( loginStatus.equals("authenticated")) {
|
||||
|
||||
// test whether session is still valid
|
||||
String currentSessionId = session.getId();
|
||||
String storedSessionId = loginHandler.getSessionId();
|
||||
|
||||
if ( currentSessionId.equals( storedSessionId ) ) {
|
||||
String currentRemoteAddrStr = request.getRemoteAddr();
|
||||
String storedRemoteAddr = loginHandler.getLoginRemoteAddr();
|
||||
securityLevel = Integer.parseInt( loginHandler.getLoginRole() );
|
||||
|
||||
if ( currentRemoteAddrStr.equals( storedRemoteAddr ) ) {
|
||||
%>
|
||||
<form class="logout" name="logout" action="${loginJSP}" method="post">
|
||||
<input type="hidden" name="home" value="<%=portal.getPortalId()%>"/>
|
||||
<em>Logged in as</em> <strong><jsp:getProperty name="loginHandler" property="loginName" /></strong>
|
||||
<input type="submit" name="loginSubmitMode" value="Log out" class="logout-button button" />
|
||||
</form>
|
||||
|
||||
<%
|
||||
} else {
|
||||
%>
|
||||
${loginFormTitle}
|
||||
<em>(IP address has changed)</em><br />
|
||||
<%
|
||||
loginHandler.setLoginStatus("logged out");
|
||||
}
|
||||
|
||||
} else {
|
||||
loginHandler.setLoginStatus("logged out");
|
||||
%>
|
||||
${loginFormTitle}
|
||||
<em>(session has expired)</em><br/>
|
||||
<form class="login" name="login" action="${loginJSP}" method="post" onsubmit="return isValidLogin(this) ">
|
||||
<input type="hidden" name="home" value="<%=portal.getPortalId()%>" />
|
||||
Username: <input type="text" name="loginName" size="10" class="form-item" /><br />
|
||||
Password: <input type="password" name="loginPassword" size="10" class="form-item" /><br />
|
||||
<input type="submit" name="loginSubmitMode" value="Log in" class="form-item button" />
|
||||
</form>
|
||||
<%
|
||||
}
|
||||
|
||||
} else { /* not thrown out by coming from different IP address or expired session; check login status returned by authenticate.java */
|
||||
%>
|
||||
<h3>Please log in</strong></h3>
|
||||
<%
|
||||
if ( loginStatus.equals("logged out")) { %>
|
||||
<em class="noticeText">(currently logged out)</em>
|
||||
<% } else if ( loginStatus.equals("bad_password")) { %>
|
||||
<em class="errorText">(password incorrect)</em><br/>
|
||||
<% } else if ( loginStatus.equals("unknown_username")) { %>
|
||||
<em class="errorText">(unknown username)</em><br/>
|
||||
<% } else if ( loginStatus.equals("first_login_no_password")) { %>
|
||||
<em class="noticeText">(1st login; need to request initial password below)</em>
|
||||
<% } else if ( loginStatus.equals("first_login_mistyped")) { %>
|
||||
<em class="noticeText">(1st login; initial password entered incorrectly)</em>
|
||||
<% } else if ( loginStatus.equals("first_login_changing_password")) { %>
|
||||
<em class="noticeText">(1st login; changing to new private password)</em>
|
||||
<% } else if ( loginStatus.equals("changing_password_repeated_old")) { %>
|
||||
<em class="noticeText">(changing to a different password)</em>
|
||||
<% } else if ( loginStatus.equals("changing_password")) { %>
|
||||
<em class="noticeText">(changing to new password)</em>
|
||||
<% } else if ( loginStatus.equals("none")) { %>
|
||||
<em class="noticeText">(new session)</em><br/>
|
||||
<% } else { %>
|
||||
<em class="errorText">Status unrecognized: <%=loginStatus.replace("_", " ")%></em><br/>
|
||||
<% } %>
|
||||
|
||||
<form class="old-global-form" name="login" action="${loginJSP}" method="post" onsubmit="return isValidLogin(this) ">
|
||||
<input type="hidden" name="home" value="<%=portal.getPortalId()%>" />
|
||||
<label for="loginName">Username:</label>
|
||||
<%
|
||||
if ( loginStatus.equals("bad_password") || loginStatus.equals("first_login_no_password")
|
||||
|| loginStatus.equals("first_login_mistyped") || loginStatus.equals("first_login_changing_password")
|
||||
|| loginStatus.equals("changing_password_repeated_old") || loginStatus.equals("changing_password") ) { %>
|
||||
<input id="username" type="text" name="loginName" value='<%=loginHandler.getLoginName()%>' size="10" class="form-item" /><br />
|
||||
<% } else { %>
|
||||
<input id="username" type="text" name="loginName" size="10" class="form-item" /><br />
|
||||
<% if ( loginStatus.equals("unknown_username") ) { %>
|
||||
<em class="errorText usernameError">Unknown username</em>
|
||||
<% }
|
||||
}
|
||||
%>
|
||||
<label for="loginPassword">Password:</label>
|
||||
<input id="password" type="password" name="loginPassword" size="10" class="form-item" /><br />
|
||||
<link rel="stylesheet" type="text/css" href="<%=themeDir%>/css/login.css"/>
|
||||
|
||||
<% String passwordError=loginHandler.getErrorMsg("loginPassword");
|
||||
if (passwordError!=null && !passwordError.equals("")) {%>
|
||||
<em class="errorText passwordError"><%=passwordError%></em>
|
||||
<% } %>
|
||||
<%= new LoginTemplateHelper(request).showLoginPage(request) %>
|
||||
|
||||
<input type="submit" name="loginSubmitMode" value="Log in" class="form-item button" />
|
||||
</form>
|
||||
<% } %>
|
||||
|
||||
</div> <!-- end loginPanel -->
|
||||
|
|
|
@ -17,8 +17,14 @@
|
|||
Portal portal = (Portal) request.getAttribute("portalBean");
|
||||
final String DEFAULT_SEARCH_METHOD = "fulltext"; /* options are fulltext/termlike */
|
||||
|
||||
int securityLevel = loginHandler.ANYBODY;
|
||||
String loginStatus = loginHandler.getLoginStatus();
|
||||
if ( loginStatus.equals("authenticated")) {
|
||||
securityLevel = Integer.parseInt( loginHandler.getLoginRole() );
|
||||
}
|
||||
%>
|
||||
|
||||
|
||||
<div id="content">
|
||||
|
||||
<div class="tab">
|
||||
|
|
|
@ -13,14 +13,10 @@ function isValidLogin( theForm ) {
|
|||
theForm.loginName.focus();
|
||||
return false;
|
||||
}
|
||||
if ( isEmptyOrWrongLength( theForm.loginPassword.value)) {
|
||||
if ( isEmptyPassword( theForm.loginPassword.value)) {
|
||||
theForm.loginPassword.focus();
|
||||
return false;
|
||||
}
|
||||
|
||||
//alert("theForm.loginPassword.value=" + theForm.loginPassword.value );
|
||||
theForm.loginPassword.value = calcMD5( theForm.loginPassword.value );
|
||||
//alert("theForm.loginPassword.value=" + theForm.loginPassword.value );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -32,15 +28,39 @@ function isEmpty( aStr ) {
|
|||
return false;
|
||||
}
|
||||
|
||||
function isEmptyOrWrongLength( aStr ) {
|
||||
function isEmptyPassword( aStr ) {
|
||||
if ( aStr.length == 0 ) {
|
||||
alert("Please enter a password to log in");
|
||||
return true;
|
||||
} else if ( aStr.length < <%=User.MIN_PASSWORD_LENGTH%> || aStr.length > <%=User.MAX_PASSWORD_LENGTH%>) {
|
||||
alert("Please enter a password between 6 and 12 characters long");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function isReasonableNewPassword( theForm ) {
|
||||
if ( isWrongLengthPassword( theForm.newPassword.value)) {
|
||||
theForm.newPassword.focus();
|
||||
return false;
|
||||
}
|
||||
if ( isMismatchedPasswords( theForm.newPassword.value, theForm.confirmPassword.value)) {
|
||||
theForm.newPassword.focus();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function isWrongLengthPassword( aStr ) {
|
||||
if ( aStr.length < <%=User.MIN_PASSWORD_LENGTH%> || aStr.length > <%=User.MAX_PASSWORD_LENGTH%>) {
|
||||
alert("Please enter a password between <%=User.MIN_PASSWORD_LENGTH%> and <%=User.MAX_PASSWORD_LENGTH%> characters long");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function isMismatchedPasswords( one, two ) {
|
||||
if ( one != two ) {
|
||||
alert("Passwords do not match");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//Give initial focus to the password or username field
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
<tr class="editformcell">
|
||||
<td valign="bottom" colspan="2">
|
||||
<b>User Name*</b><br/>
|
||||
<b>Email address*</b><br/>
|
||||
<input type="text" name="Username" value="${formValue['Username']}" size="60" maxlength="120" />
|
||||
<span class="warning"><form:error name="Username"/></span>
|
||||
</td>
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||
|
||||
<#-- Crop the replacement main image for an Individual, to produce a thumbnail. -->
|
||||
|
||||
<h2>Forced password change</h2>
|
||||
|
||||
${stylesheets.addFromTheme("/login.css")}
|
||||
|
||||
<div id="formLogin" class="pageBodyGroup">
|
||||
<h2>Create Your New Password</h2>
|
||||
|
||||
<#if errorMessage??>
|
||||
<div id="errorAlert"><img src="${alertImageUrl}" width="32" height="31" alert="Error alert icon"/>
|
||||
<p>${errorMessage}</p>
|
||||
</div>
|
||||
</#if>
|
||||
|
||||
<form action="${formAction}" method="post" onsubmit="return isReasonableNewPassword(this)">
|
||||
<label for="newPassword">Password</label>
|
||||
<input type="password" name="newPassword" />
|
||||
<label for="confirmPassword">Confirm Password</label>
|
||||
<input type="password" name="confirmPassword" />
|
||||
<br />
|
||||
<input name="passwordChangeForm" type="submit" class="submit" value="Save Changes"/>
|
||||
</form>
|
||||
</div>
|
||||
|
29
webapp/web/templates/freemarker/body/login/login.ftl
Normal file
29
webapp/web/templates/freemarker/body/login/login.ftl
Normal file
|
@ -0,0 +1,29 @@
|
|||
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||
|
||||
<#-- Crop the replacement main image for an Individual, to produce a thumbnail. -->
|
||||
|
||||
${stylesheets.addFromTheme("/login.css")}
|
||||
|
||||
<div id="formLogin" class="pageBodyGroup">
|
||||
<h2>Log in</h2>
|
||||
|
||||
<#if infoMessage??>
|
||||
<h3>${infoMessage}</h3>
|
||||
</#if>
|
||||
|
||||
<#if errorMessage??>
|
||||
<div id="errorAlert"><img src="${alertImageUrl}" width="32" height="31" alert="Error alert icon"/>
|
||||
<p>${errorMessage}</p>
|
||||
</div>
|
||||
</#if>
|
||||
|
||||
<form action="${formAction}" method="post" onsubmit="return isValidLogin(this)">
|
||||
<label for="loginName">Email</label>
|
||||
<input name="loginName" type="text" value="${loginName}" />
|
||||
<label for="loginPassword">Password</label>
|
||||
<input type="password" name="loginPassword" />
|
||||
<br />
|
||||
<input name="loginForm" type="submit" class="submit" value="Log in"/>
|
||||
</form>
|
||||
</div>
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue