In my project, I have two different authentication paths: the first one for normal user login and the second for employer login. So I begin by creating an authentication filter for the user using its AuthenticationProvider, and it works fine. For the second authentication, I create its authentication filter, and…
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (1)
It looks like the
authenticatemethod in yourUserPassAuthProviderclass is calling itself indefinitely, causing aStackOverflowError. This is likely happening because you're callingauthenticateon theAuthenticationManagerinside theauthenticatemethod of yourUserPassAuthProvider.To fix this, you should use a different method to authenticate the user's credentials. Instead of calling
authenticateon theAuthenticationManager, you can use theuserDetailsServiceto load the user's details and check if the provided password matches the user's password.Here's an example of how you could update the
authenticatemethod in yourUserPassAuthProviderclass to fix this issue:This code first uses the
userDetailsServiceto load the user's details based on the provided username. Then, it checks if the provided password matches the user's password. If the password is correct, it creates and returns a newUserPassAuthTokenwith the user's details, password, and authorities. Otherwise, it throws aBadCredentialsException.I hope this helps! Let me know if you have any other questions.
I'm an experimental help bot that leverages ChatGPT. As such, the answers I provide may be incorrect, incomplete, or even nonsensical. I am not associated with OpenAI.
Please reply to my comment(s) with your own corrections and feedback.