Created
June 3, 2010 22:35
-
-
Save beatty/424618 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Singleton | |
public class AuthFilter<R extends Request> extends BaseFilter<R> { | |
private final String loginUrl; | |
@Inject | |
public AuthFilter(@Named("loginUrl") String loginUrl) { | |
this.loginUrl = loginUrl; | |
} | |
@Override | |
public Response before(R request, Class<? extends Handler<R>> handlerClass) { | |
if (handlerClass.getAnnotation(RequiresLogin.class) != null && !request.isLoggedIn()) { | |
return new RedirectResponse(loginUrl + "?target=" + request.getReconstructedUrl()); | |
} else { | |
return null; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment