Skip to content

Commit

Permalink
[#3929] Add a feature flag to disable index redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
EmmanuelAkvo committed Nov 2, 2022
1 parent b40e2f2 commit 3c181b2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 5 additions & 1 deletion GAE/src/org/akvo/flow/rest/security/RedirectIndexFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import java.io.IOException;
import java.util.logging.Logger;

import static org.waterforpeople.mapping.app.web.EnvServlet.INDEX_REDIRECT_DISABLED;

public class RedirectIndexFilter extends GenericFilterBean {

private static final Logger logger = Logger.getLogger(RedirectIndexFilter.class.getName());
Expand All @@ -39,7 +41,9 @@ public void doFilter(ServletRequest servletRequest, ServletResponse servletRespo
String requestPath = httpRequest.getServletPath();
logger.fine("Request path is: " + requestPath);

if ("/".equals(requestPath) || requestPath.startsWith("/index")) {
boolean indexRedirectIsActive = System.getProperty(INDEX_REDIRECT_DISABLED) == null;

if (("/".equals(requestPath) || requestPath.startsWith("/index")) && indexRedirectIsActive) {
HttpServletResponse response = (HttpServletResponse) servletResponse;
response.sendRedirect("/admin");
} else {
Expand Down
2 changes: 2 additions & 0 deletions GAE/src/org/waterforpeople/mapping/app/web/EnvServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ public class EnvServlet extends HttpServlet {
public static final String SHOW_FORM_INSTANCE_API_URL = "showFormInstanceApiUrl";
public static final String WEBFORM_V2_ENABLED = "enableWebFormV2";
public static final String SELF_ONBOARD_ENABLED = "enableSelfOnboard";
public static final String INDEX_REDIRECT_DISABLED = "disableIndexRedirect";


private static final ArrayList<String> properties = new ArrayList<String>();

Expand Down

0 comments on commit 3c181b2

Please sign in to comment.