I use Spring Security with OAuth 2. My OAuth users have account_locked
and enabled
fields and I use them for different reasons. E.g. account_locked
for blocking users and enabled
for deactivating users. When user tries to log in and has block, then he receives 401
HTTP code and message "User account is locked". If he is deactivated, then he also receives 401
HTTP code and message "User is disabled".
I want to enhance these errors with additional information(like it is possible to enhance token using TokenEnhancer
) to distinguish block code from deactivated code on the client. E.g. with the field reason_of_fail
. Please note that I don't want to use text messages from these errors.
I already tried to use this(from this answer):
@Override
protected void configure(HttpSecurity http) throws Exception {
http.exceptionHandling()
.authencationEntryPoint(unauthorizedHandler)
.accessDeniedHandler(accessDeniedHandler);
}
But these handlers doesn't catch LockedException
and DisabledException
.
So, how I can enhance these errors with additional field(key-value pair)?