我试图捕获LockedException的异常,但它会抛出BadCredentialsException。
try {
accessToken = accessTokenProviderChain.obtainAccessToken(
resourceDetails,
new DefaultAccessTokenRequest());
} catch (OAuth2AccessDeniedException e) {
throw new BadCredentialsException('invalid login', authentication.details);
} catch (Exception e) {
authenticationErrorReporter.logSessionData(session)
throw e
}
当锁定的帐户尝试获取accessToken时,请先执行此操作
preAuthenticationChecks.check(user);
它抛出AuthenticationException,然后转移到AccountStatusException,之后,我得到了InvocationTargetException,然后被OAuth2AccessDeniedException捕获。 我想要的是AccountStatusException,而不是OAuth2AccessDeniedException。
这是Stacktrace
ERROR org.codehaus.groovy.grails.web.errors.GrailsExceptionResolver - InvalidGrantException occurred when processing request: [POST] /api/oauth/token - parameters:
username: someone
grant_type: password
password: ***
User account is locked. Stacktrace follows:
error="invalid_grant", error_description="User account is locked"
at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:179)
at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
有谁知道如何解决这个问题,请欣赏。