diff --git a/samples/gae/src/main/java/samples/gae/security/GaeAuthenticationFilter.java b/samples/gae/src/main/java/samples/gae/security/GaeAuthenticationFilter.java index c1960c5026..f08bdcfe89 100644 --- a/samples/gae/src/main/java/samples/gae/security/GaeAuthenticationFilter.java +++ b/samples/gae/src/main/java/samples/gae/security/GaeAuthenticationFilter.java @@ -52,6 +52,14 @@ public class GaeAuthenticationFilter extends GenericFilterBean { try { authentication = authenticationManager.authenticate(token); SecurityContextHolder.getContext().setAuthentication(authentication); + + if (authentication.getAuthorities().contains(AppRole.NEW_USER)) { + logger.debug("New user authenticated. Redirecting to registration page"); + ((HttpServletResponse) response).sendRedirect(REGISTRATION_URL); + + return; + } + } catch (AuthenticationException e) { failureHandler.onAuthenticationFailure((HttpServletRequest)request, (HttpServletResponse)response, e); @@ -60,16 +68,6 @@ public class GaeAuthenticationFilter extends GenericFilterBean { } } - // A new user has to register with the app before doing anything else - if (authentication != null && authentication.getAuthorities().contains(AppRole.NEW_USER) - && !((HttpServletRequest)request).getRequestURI().endsWith(REGISTRATION_URL)) { - logger.debug("New user authenticated. Redirecting to registration page"); - - ((HttpServletResponse) response).sendRedirect(REGISTRATION_URL); - - return; - } - chain.doFilter(request, response); } diff --git a/samples/gae/src/main/java/samples/gae/users/GaeDataStoreUserRegistry.java b/samples/gae/src/main/java/samples/gae/users/GaeDataStoreUserRegistry.java index 6fd1ff2f5c..0c15bace36 100644 --- a/samples/gae/src/main/java/samples/gae/users/GaeDataStoreUserRegistry.java +++ b/samples/gae/src/main/java/samples/gae/users/GaeDataStoreUserRegistry.java @@ -15,7 +15,7 @@ import samples.gae.security.AppRole; * * @author Luke Taylor */ -public class GaeDataStoreUserRegistry implements UserRegistry { +public class GaeDatastoreUserRegistry implements UserRegistry { private final Logger logger = LoggerFactory.getLogger(getClass()); private static final String USER_TYPE = "GaeUser"; diff --git a/samples/gae/src/main/webapp/WEB-INF/applicationContext-security.xml b/samples/gae/src/main/webapp/WEB-INF/applicationContext-security.xml index f4b8f799e1..ba6053b5f2 100644 --- a/samples/gae/src/main/webapp/WEB-INF/applicationContext-security.xml +++ b/samples/gae/src/main/webapp/WEB-INF/applicationContext-security.xml @@ -8,12 +8,11 @@ - + + - - @@ -43,6 +42,6 @@ - + diff --git a/samples/gae/src/test/java/samples/gae/users/GaeDataStoreUserRegistryTests.java b/samples/gae/src/test/java/samples/gae/users/GaeDataStoreUserRegistryTests.java index 36998072e8..708206153b 100644 --- a/samples/gae/src/test/java/samples/gae/users/GaeDataStoreUserRegistryTests.java +++ b/samples/gae/src/test/java/samples/gae/users/GaeDataStoreUserRegistryTests.java @@ -31,7 +31,7 @@ public class GaeDataStoreUserRegistryTests { @Test public void correctDataIsRetrievedAfterInsert() { - GaeDataStoreUserRegistry registry = new GaeDataStoreUserRegistry(); + GaeDatastoreUserRegistry registry = new GaeDatastoreUserRegistry(); Set roles = EnumSet.of(AppRole.ADMIN, AppRole.USER); String userId = "someUserId";