Skip to content

Commit

Permalink
moved throwing the UserNotFoundException into its own method to make …
Browse files Browse the repository at this point in the history
…it easier to override in a subclass; I'm implementing a custom integration where I need access to the FacebookAuthToken, so I store it in the HTTP session before throwing the exception
  • Loading branch information
burtbeckwith committed Nov 3, 2014
1 parent 53a49b3 commit cb4848e
Showing 1 changed file with 7 additions and 3 deletions.
Expand Up @@ -72,9 +72,7 @@ class FacebookAuthProvider implements AuthenticationProvider, InitializingBean,
user = facebookAuthDao.create(token)
justCreated = true
} else {
log.error "User $token.uid doesn't exist, and creation of a new user is disabled."
log.debug "To enable auto creation of users set `grails.plugin.springsecurity.facebook.autoCreate.enabled` to true"
throw new UsernameNotFoundException("Facebook user with uid $token.uid doesn't exist")
handleUserNotFoundNoAutocreate(token)
}
}

Expand Down Expand Up @@ -143,6 +141,12 @@ class FacebookAuthProvider implements AuthenticationProvider, InitializingBean,
token
}

protected void handleUserNotFoundNoAutocreate(FacebookAuthToken token) throws UsernameNotFoundException {
log.error "User $token.uid doesn't exist, and creation of a new user is disabled."
log.debug "To enable auto creation of users set `grails.plugin.springsecurity.facebook.autoCreate.enabled` to true"
throw new UsernameNotFoundException("Facebook user with uid $token.uid doesn't exist")
}

boolean supports(Class<? extends Object> authentication) {
FacebookAuthToken.isAssignableFrom authentication
}
Expand Down

0 comments on commit cb4848e

Please sign in to comment.