NIHVIVO-155 Corrections to redirections after fake self-editing form submissions

This commit is contained in:
rjy7 2010-03-10 22:13:04 +00:00
parent 6837626931
commit fd2676da55
2 changed files with 51 additions and 42 deletions

View file

@ -32,7 +32,10 @@ public class FakeSelfEditController extends VitroHttpServlet {
// if (!checkLoginStatus(request, response)) {
// return;
// }
String redirectUrl = null;
String netid = null;
String msg = null;
try {
super.doGet(request,response);
@ -43,43 +46,37 @@ public class FakeSelfEditController extends VitroHttpServlet {
LoginFormBean loginHandler = null;
if( obj != null && obj instanceof LoginFormBean )
loginHandler = ((LoginFormBean)obj);
if( loginHandler == null ||
// Not logged in to site admin
if ( loginHandler == null ||
! "authenticated".equalsIgnoreCase(loginHandler.getLoginStatus()) ||
Integer.parseInt(loginHandler.getLoginRole()) <= LoginFormBean.CURATOR ){
Integer.parseInt(loginHandler.getLoginRole()) <= LoginFormBean.CURATOR ) {
session.setAttribute("postLoginRequest",
vreq.getRequestURI()); //+( vreq.getQueryString()!=null?('?' + vreq.getQueryString()):"" ));
// Redirect to site admin login page
redirectUrl=request.getContextPath() + Controllers.LOGIN + "?login=block";
response.sendRedirect(redirectUrl);
return;
}
String netid = null;
String msg = null;
// Logged in to site admin
else {
// Handle form submission
// Form to use netid submitted
if( vreq.getParameter("force") != null ){
VitroRequestPrep.forceToSelfEditing(request);
netid = request.getParameter("netid");
msg = "You are using the netid '" + netid + "' to test self-editing."
; FakeSelfEditingIdentifierFactory.clearFakeIdInSession( session );
FakeSelfEditingIdentifierFactory.clearFakeIdInSession( session );
FakeSelfEditingIdentifierFactory.putFakeIdInSession( netid , session );
//redirectUrl = request.getContextPath() + "/admin/fakeselfedit" + "?netid=" + netid;
// Redirect to user's entity page
redirectUrl = request.getContextPath() + Controllers.ENTITY + "?netid=" + netid;
}
else {
// Form to stop using netid submitted
if ( request.getParameter("stopfaking") != null){
else if ( request.getParameter("stopfaking") != null) {
VitroRequestPrep.forceOutOfSelfEditing(request);
FakeSelfEditingIdentifierFactory.clearFakeIdInSession( session );
}
netid = (String)session.getAttribute(FakeSelfEditingIdentifierFactory.FAKE_SELF_EDIT_NETID);
msg = "You have not configured a netid to test self-editing.";
if( netid != null ) {
msg = "You are testing self-editing as '" + netid + "'.";
//redirectUrl = request.getContextPath() + "/admin/fakeselfedit" + "?netid=" + netid;
}
else {
netid = "";
// Redirect to home page
redirectUrl = request.getContextPath();
}
}
@ -88,8 +85,20 @@ public class FakeSelfEditController extends VitroHttpServlet {
return;
}
// On page, form not yet submitted
// Check if already logged in from previous form submission
netid = (String)session.getAttribute(FakeSelfEditingIdentifierFactory.FAKE_SELF_EDIT_NETID);
// Already logged in from a previous request
if ( netid != null ) {
msg = "You are testing self-editing as '" + netid + "'.";
}
// Not logged in
else {
msg = "You have not configured a netid to test self-editing.";
}
request.setAttribute("msg", msg);
request.setAttribute("netid", netid);
request.setAttribute("title", "Self-Edit Test");
request.setAttribute("bodyJsp", "/admin/fakeselfedit.jsp");

View file

@ -9,11 +9,11 @@
<form action="<c:url value="/admin/fakeselfedit"/>" >
<input type="text" name="netid" value="${netid}"/>
<input type="hidden" name="force" value="1"/>
<input type="submit" value="use this netid for testing"/>
&nbsp;<input type="submit" value="use this netid for testing"/>
</form>
<form action="<c:url value="fakeselfedit"/>" >
<br />
<form action="<c:url value="/admin/fakeselfedit"/>" >
<input type="hidden" name="stopfaking" value="1"/>
<input type="submit" value="stop using netid for testing"/>
</form>