spring-bootspring-securityjhipsteranonymous-users

Jhipster cannot use anonymous user before login


When I visit to jhipster websit pre-login, it always displays error message (User could not be found). In jhipster project, where to setup anonymous user for pre-login?


Solution

  • I also have this issue, the backend logs and the browser console fills up with errors of type

    AccountResourceException: User could not be found
    

    Whenever user browses the application before logging in. Probably because of this code in app.tsx:

    export const App = (props: IAppProps) => {
      useEffect(() => {
      props.getSession();
      props.getProfile();
    }, []);
    

    This means it tries to run the effect on load and each time AppProps change, no matter what route the user is trying to visit, even the ones that should be open without login.

    I would look into moving this effect into some part of the code that only runs for login-only routes.