-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot authenticate after page-reload -> Session not working #245
Comments
Hey everyone! By adding x-csrf-token to the headers of cors in the config file (local.ini) of CouchDB and by applying changes to the login-function as follows, I could make the cookie be set. But: It was set empty (no value, "AuthSession=") (although I could see, that the POST request did include the AuthSession value (!)). `
` In order to set the Cookie successfully with value, I had to call the following function after login: `getAuthSession: function(options) {
Now the Cookie is being set with the correct value and is being sent with every request and authenticates the user successfully. Tested successfully on Android device, Android emulator and OSX/Chrome with Phonegap Note for browser-platform/Phonegap-serve: I hope this helps! I found quite many threads where the Cookie/Auth-thing did not work out of the box although following the docs. |
Expected Behavior
When I log in and reload the page, I should remain logged in.
Current Behavior
I use pouchdb-authentication in my Cordova-App. Login/Register works just fine, but a user cannot stay logged in after a page-reload. So something with this plugin's cookie-auth seems to fail.
I use Couch-Per-User functionality with CouchDB 2.2.
When I log in on Chrome, I receive a session-object as expected:
{"ok":true,"userCtx":{"name":"julius","roles":[]},"info":{"authentication_db":"_users","authentication_handlers":["cookie","default"],"authenticated":"default"}}
Also, I can sync, put docs, etc.
When I reload the page, read out the user's name and database-name from the local document, I receive a 401 "unauthorized" error:
and the following DB/Session-objects:
{"error":"unauthorized","reason":"You are not authorized to access this db.","host":"https://domain.com:6984/userdb-6a756c697573/","db_name":"https://domain.com:6984/userdb-6a756c697573","auto_compaction":false,"adapter":"https"}
{"ok":true,"userCtx":{"name":null,"roles":[]},"info":{"authentication_db":"_users","authentication_handlers":["cookie","default"]}}
Steps to Reproduce (for bugs)
Context
Here I provide all the code needed for reproduction of the error:
`onDeviceReady: function() {
},`
`login: function(){
},`
`sync: function(){
},`
Here is my CouchDB Configuration:
And here are is another screenshot:
Your Environment
I am quite desperately trying to get this to work. Any hint is very welcome!
The text was updated successfully, but these errors were encountered: