Comments (6)
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...
from angular-http-auth.
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.
from angular-http-auth.
Let's clarify:
- browser is sending requests, they all return as 401s,
- first time the 401 comes, the
event:auth-loginRequired
is triggered, - the login section should now appear,
- user is typing login, in the mean time more and more 401s are free to come,
- user submits the form, but the login credentials are wrong, so the login section does not disappear, just the message about invalid credentials gets displayed,
- user tries again and again and again,
- finally the data are OK, so you hide the form, invoke
authService.loginConfirmed()
and all the 401s gets retried, or user surrenders and you invokeauthService.loginCancelled()
and all the 401s are abandoned or rejected.
How is your case different?
from angular-http-auth.
We have the following scenario:
- User open "host:8080/myapp/#/myroute" and was not logged in before.
- The route 'myroute' is configured in RouteProviderConfig and has 3 resolve functions (see https://docs.angularjs.org/api/ngRoute/provider/$routeProvider).
- angular try to resolve the route promises, they result status are 401, because the user was not logged in before.
- here is the
bufferLength
= 3. - login dialog will be shown, because the promises return 401 and the
event:auth-loginRequired
is triggered by the first rest call. - user is typing wrong login data and confirm the dialog.
- the LoginService on the backend will be called and returns 401.
- the login dialog is still open.
- if the login credentials are wrong, we expect the
event:auth-loginRequired
to show the message "Wrong logn data", but the event will not be triggered, becausebufferLength
> 1.
Our backend returns status 401 if the user is not logged in or if the user try to login with wrong login data.
from angular-http-auth.
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
from angular-http-auth.
Thanks, we changed our LoginService and it works now like expected.
from angular-http-auth.
Related Issues (20)
- Breaks angular-loading-bar HOT 7
- doesn't seem to use the config for the next requests HOT 4
- bower install warning HOT 7
- There is no minified version on bower/npm HOT 5
- Issue using ng-file-upload and http-auth-interceptor HOT 14
- resume loading screen HOT 3
- login address returns 404 after 401 intercept HOT 2
- Error when config doesn't exist HOT 1
- Even Unauthenticated user can see static contents of the page HOT 5
- Add Trip distance
- How angular-http-auth-buffer works ? HOT 2
- npm version stuck on 1.2.1 HOT 2
- Prevent double event HOT 1
- Basic authentication results in 404 HOT 4
- Scenario with refresh token (e.g. authService.ignoreCurrentRequest()) HOT 3
- Add Better loginCancelled documentation to avoid confusion HOT 1
- Please add license = "MIT" to bower.son HOT 2
- Even't function won't fire HOT 6
- Interceptor automatically captures all 401s and prevents other interceptors from having an opportunity to examine them
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from angular-http-auth.