Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

throw DisabledException for non authenticated user

  • Loading branch information...
commit 5acacc13197ffe7aaaec940c4df56130f5171e07 1 parent 2d6fb9f
@splix authored
View
13 src/groovy/com/the6hours/grails/springsecurity/twitter/TwitterAuthFilter.groovy
@@ -11,6 +11,8 @@ import twitter4j.auth.AccessToken
import twitter4j.TwitterException
import twitter4j.TwitterFactory
import org.apache.log4j.Logger
+import org.springframework.security.authentication.BadCredentialsException
+import org.springframework.security.authentication.DisabledException
/**
* TODO
@@ -65,16 +67,15 @@ class TwitterAuthFilter extends AbstractAuthenticationProcessingFilter {
Authentication auth = getAuthenticationManager().authenticate(securityToken)
if (auth.authenticated) {
rememberMeServices.loginSuccess(request, response, auth)
+ log.info "Successful authentication"
+ return auth
+ } else {
+ throw new DisabledException("User is disabled")
}
- log.info "Successful authentication"
- return auth
} catch (TwitterException e) {
log.error "Failed processing twitter callback", e
}
- log.info "Authentication failed"
- TwitterAuthToken auth = new TwitterAuthToken()
- auth.authenticated = false
- return auth
+ throw new BadCredentialsException("Invalid twitter token")
}
protected boolean _requiresAuthentication(HttpServletRequest request, HttpServletResponse response) {
Please sign in to comment.
Something went wrong with that request. Please try again.