Comments (7)
Can you isolate a specific way to reproduce this error?
from superlogin.
By trying to describe it I realized this is probably mostly a client issue
Using the client library (tested with my vanilla but not with your Angularjs).
The easiest way is to set the refreshThreshold nothing (Number.EPSILON).
When calling logout, the hook will trigger the refresh call which will change the data of couchdb between the read and the write done by logout.
It might be a problem with Axios that I use for the interceptor (api based on http of Angularjs), but you should take a look, just in case.
from superlogin.
This issue probably don't belong here
from superlogin.
I get what you are saying. If the same user makes two calls to the SuperLogin API at the exact same time then there could be a document update conflict. The refresh handler on ng-superlogin
does cause two requests to fire at the same time.
I think the simplest solution is for the interceptor to require the refresh call to finish before sending the original request.
from superlogin.
So here what worked for me on my client (publishing soon)
I turned checkRefresh into a promise already, so in the request interceptor I return checkRefresh to make sure the refresh is finished before logout (or any other call) is done.
Here the snippet:
const request = req => {
const config = this.getConfig();
const session = this.getSession();
if (!session || !session.token) {
return Promise.resolve(req);
}
return this.checkRefresh().then(() => {
if (checkEndpoint(req.url, config.endpoints)) {
req.headers.Authorization = 'Bearer ' + session.token + ':' + session.password;
}
return req;
});
};
So I didn't test with ng-superlogin (since I don't use Angular.js), but you might need to do something similar.
from superlogin.
I was thinking to do the exact same thing. The disadvantage is that it could slightly delay the user's request if refresh is required. It is a waste to refresh before actions like logout
.
What I'm thinking is to add a _superloginNoRefresh
property to the $http
config object for logout
and logout-all
. When the request interceptor sees this property it will not attempt checkRefresh()
. For actions like change-email
I will pass _superloginDelayRequest
which will refresh then fire the request as you have done above.
Outside the SuperLogin API the requests can fire at the same time without side effects.
from superlogin.
That could do the trick indeed
from superlogin.
Related Issues (20)
- How can I remove confirmPassword requirement?
- Validation failed HOT 8
- Validation failed HOT 1
- Calling /auth/session with authorization header is returning unauthorized HOT 1
- Use template-literal instead of EJS
- user-db-added event doesn't get emitted HOT 1
- New release? HOT 13
- Validation Failed HOT 1
- Register vaildation failed HOT 18
- Mandatory Migration from Cloudant to BlueMix not compatible with Superlogin HOT 1
- Superlogin with CouchDB crypto.pbkdf2 "digest" argument required HOT 1
- how to add profile data with registration?
- removeUser not working
- Live demo isn't working HOT 1
- Forgot Password function
- TypeError: Cannot read property 'valid' of undefined at Function.PouchDB.parseAdapter
- Howto: use superlogin with current nodejs HOT 6
- Set a Doc create limit per user
- super login spaming console with errors
- Graphql
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 superlogin.