Search code examples
spartacus-storefront

what is alternative for AuthActions.LOAD_USER_TOKEN_FAIL in sparatcus v3.x


I am using AuthActions.LOAD_USER_TOKEN_FAIL action for 2.0 but when I migrate to 3.3.0 I am getting error on this as this has been removed. can you please let me know what is the alternative for this one if I have to track the HTTP error code like v2.0

thanks in advance.


Solution

  • If you are using the standard "credentials" authentication.

    You could extend the OOTB AuthService and overirde the loginWithCredentials, keep the same logic but add some additional logic in the catch which is called if the login failed.

    I you don't want to add the logic there directly you could create your own LOAD_USER_TOKEN_FAIL and dispatch it from there. Alternatively, you can use the built in Event mechanism to create a new event an observe it elsewhere in the code.