NIHVIVO-155 Corrections to redirections after fake self-editing form submissions
This commit is contained in:
parent
6837626931
commit
fd2676da55
2 changed files with 51 additions and 42 deletions
|
@ -32,7 +32,10 @@ public class FakeSelfEditController extends VitroHttpServlet {
|
||||||
// if (!checkLoginStatus(request, response)) {
|
// if (!checkLoginStatus(request, response)) {
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
String redirectUrl = null;
|
String redirectUrl = null;
|
||||||
|
String netid = null;
|
||||||
|
String msg = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
super.doGet(request,response);
|
super.doGet(request,response);
|
||||||
|
@ -43,43 +46,37 @@ public class FakeSelfEditController extends VitroHttpServlet {
|
||||||
LoginFormBean loginHandler = null;
|
LoginFormBean loginHandler = null;
|
||||||
if( obj != null && obj instanceof LoginFormBean )
|
if( obj != null && obj instanceof LoginFormBean )
|
||||||
loginHandler = ((LoginFormBean)obj);
|
loginHandler = ((LoginFormBean)obj);
|
||||||
if( loginHandler == null ||
|
|
||||||
! "authenticated".equalsIgnoreCase(loginHandler.getLoginStatus()) ||
|
// Not logged in to site admin
|
||||||
Integer.parseInt(loginHandler.getLoginRole()) <= LoginFormBean.CURATOR ){
|
if ( loginHandler == null ||
|
||||||
|
! "authenticated".equalsIgnoreCase(loginHandler.getLoginStatus()) ||
|
||||||
|
Integer.parseInt(loginHandler.getLoginRole()) <= LoginFormBean.CURATOR ) {
|
||||||
|
|
||||||
session.setAttribute("postLoginRequest",
|
session.setAttribute("postLoginRequest",
|
||||||
vreq.getRequestURI()); //+( vreq.getQueryString()!=null?('?' + vreq.getQueryString()):"" ));
|
vreq.getRequestURI()); //+( vreq.getQueryString()!=null?('?' + vreq.getQueryString()):"" ));
|
||||||
|
// Redirect to site admin login page
|
||||||
redirectUrl=request.getContextPath() + Controllers.LOGIN + "?login=block";
|
redirectUrl=request.getContextPath() + Controllers.LOGIN + "?login=block";
|
||||||
response.sendRedirect(redirectUrl);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String netid = null;
|
// Logged in to site admin
|
||||||
String msg = null;
|
|
||||||
|
|
||||||
// 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.putFakeIdInSession( netid , session );
|
|
||||||
//redirectUrl = request.getContextPath() + "/admin/fakeselfedit" + "?netid=" + netid;
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
|
// Handle form submission
|
||||||
|
// Form to use netid submitted
|
||||||
|
if( vreq.getParameter("force") != null ){
|
||||||
|
VitroRequestPrep.forceToSelfEditing(request);
|
||||||
|
netid = request.getParameter("netid");
|
||||||
|
FakeSelfEditingIdentifierFactory.clearFakeIdInSession( session );
|
||||||
|
FakeSelfEditingIdentifierFactory.putFakeIdInSession( netid , session );
|
||||||
|
// Redirect to user's entity page
|
||||||
|
redirectUrl = request.getContextPath() + Controllers.ENTITY + "?netid=" + netid;
|
||||||
|
}
|
||||||
|
|
||||||
// Form to stop using netid submitted
|
// Form to stop using netid submitted
|
||||||
if ( request.getParameter("stopfaking") != null){
|
else if ( request.getParameter("stopfaking") != null) {
|
||||||
VitroRequestPrep.forceOutOfSelfEditing(request);
|
VitroRequestPrep.forceOutOfSelfEditing(request);
|
||||||
FakeSelfEditingIdentifierFactory.clearFakeIdInSession( session );
|
FakeSelfEditingIdentifierFactory.clearFakeIdInSession( session );
|
||||||
}
|
// Redirect to home page
|
||||||
netid = (String)session.getAttribute(FakeSelfEditingIdentifierFactory.FAKE_SELF_EDIT_NETID);
|
redirectUrl = request.getContextPath();
|
||||||
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 = "";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,8 +85,20 @@ public class FakeSelfEditController extends VitroHttpServlet {
|
||||||
return;
|
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("msg", msg);
|
||||||
request.setAttribute("netid", netid);
|
|
||||||
|
|
||||||
request.setAttribute("title", "Self-Edit Test");
|
request.setAttribute("title", "Self-Edit Test");
|
||||||
request.setAttribute("bodyJsp", "/admin/fakeselfedit.jsp");
|
request.setAttribute("bodyJsp", "/admin/fakeselfedit.jsp");
|
||||||
|
|
|
@ -9,11 +9,11 @@
|
||||||
<form action="<c:url value="/admin/fakeselfedit"/>" >
|
<form action="<c:url value="/admin/fakeselfedit"/>" >
|
||||||
<input type="text" name="netid" value="${netid}"/>
|
<input type="text" name="netid" value="${netid}"/>
|
||||||
<input type="hidden" name="force" value="1"/>
|
<input type="hidden" name="force" value="1"/>
|
||||||
<input type="submit" value="use this netid for testing"/>
|
<input type="submit" value="use this netid for testing"/>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<br />
|
||||||
<form action="<c:url value="fakeselfedit"/>" >
|
<form action="<c:url value="/admin/fakeselfedit"/>" >
|
||||||
<input type="hidden" name="stopfaking" value="1"/>
|
<input type="hidden" name="stopfaking" value="1"/>
|
||||||
<input type="submit" value="stop using netid for testing"/>
|
<input type="submit" value="stop using netid for testing"/>
|
||||||
</form>
|
</form>
|
||||||
|
|
Loading…
Add table
Reference in a new issue