Closed javix closed 8 years ago
That's surprising for me, because I would not close the login form until the password is OK (success) or the user has decided to give up (reject). Each case would clear the buffer...
Some rest calls will be executed parallel during the login form is shown. They result of course is 401 because the user is not logged in and the httpBuffer length increaeses. After the user has entered wrong login data the httpBuffer ist not empty and the event will not be thrown.
Let's clarify:
event:auth-loginRequired
is triggered,authService.loginConfirmed()
and all the 401s gets retried, or user surrenders and you invoke authService.loginCancelled()
and all the 401s are abandoned or rejected.How is your case different?
We have the following scenario:
bufferLength
= 3.event:auth-loginRequired
is triggered by the first rest call.event:auth-loginRequired
to show the message "Wrong logn data", but the event will not be triggered, because bufferLength
> 1.Our backend returns status 401 if the user is not logged in or if the user try to login with wrong login data.
I can see now. The thing is the login request itself should not go through the interceptor, because it's not something you would like store in buffer for retry later once user gets logged in. Especially that this is the request with invalid credentials, so why would you want it to be retried after successful login?
So, when user enters data you should set the request with ignoreAuthModule: true
, so it's response will be ignored by the module and you will get the 401 response delivered directly to your controller. Based on what you get there you can display the right message.
P.S. See the description in doc: https://github.com/witoldsz/angular-http-auth#ignoring-the-401-interceptor
Thanks, we changed our LoginService and it works now like expected.
We have a problem with lines
The 'bufferLength' is always > 1, if used some resolves in route config and the user is not logged in. In our case we use 4 resolve functions (rest calls to retrieving some data), they resulting in 401, because the user is not logged in before. The login dialog will be shown (OK). If the user enter wrong login data, the request results in 401, but the httpBuffer is not empty anymore and the event will not be thrown.
(sorry for grammatical errors)