Skip to content
Snippets Groups Projects
Commit ced35bcb authored by Tor-Einar Skog's avatar Tor-Einar Skog
Browse files

fix:Handle non-authorized request

parent a93d5d24
No related branches found
No related tags found
1 merge request!33Feat/add user subscription link vipsutv 342
This commit is part of merge request !33. Comments created here will be created in the context of that merge request.
......@@ -20,6 +20,8 @@ package no.nibio.vips.logic.controller.servlet;
import freemarker.core.ParseException;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.List;
import javax.ejb.EJB;
import javax.persistence.EntityManager;
......@@ -80,7 +82,12 @@ public class NotificationSubscriptionController extends HttpServlet {
String action = request.getParameter("action");
VipsLogicUser user = (VipsLogicUser) request.getSession().getAttribute("user");
if(user == null)
{
this.redirectToLogin(request, response);
return;
}
try
{
// Default: View list of user subscriptions
......@@ -173,6 +180,13 @@ public class NotificationSubscriptionController extends HttpServlet {
}
}
private void redirectToLogin(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException
{
String nextPage = ServletUtil.getFullRequestURI(request);
String nextPageDirective= "?nextPage=" + URLEncoder.encode(nextPage, "UTF-8");
response.sendRedirect(Globals.PROTOCOL + "://" + ServletUtil.getServerName(request) + "/login" + nextPageDirective);
}
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
/**
* Handles the HTTP <code>GET</code> method.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment