Closed carrotcomputer closed 9 years ago
Hey Spark,
I know it's not clearly in the readme to send the db credentials, but this is how you do it.
var couchUser = require('express-user-couchdb');
var bodyParser = require('body-parser');
var app = express();
app.use(bodyParser.json());
app.use(couchUser({
users: 'http://localhost:5984/_users',
request_defaults: {
user: 'couchAdminUserName',
pass: 'couchAdminPassword'
}
}));
Thanks for the help Joel.
I tried what you suggested and I can see that the request_defaults are being used when I make a request within my node script to the _users table as it works successfully.
However, if I try a client-side AJAX request to one of the couchUser methods like signin or signup, I still receive HTTP 500 and 403 errors.
For the signin method whilst posting the admin username and password, I get a 500 error stating:
error: "not_found" message: "missing" ok: false
For the signup method, posting the following:
"name": "bobrep", "password": "password", "email": "bobrep@staff.co.uk", "data": { "fullName": "Bob Rep" }
I receive a 403 error stating:
Error: Only admins can access design document actions for system databases.
Any further advise? Cheers
@sparkrevolutions
Joel was correct above about the need for the credentials in the request_defaults, but they need to be nested under an auth
node. Like ...
app.use(couchUser({
users: 'http://localhost:5984/_users',
request_defaults: {
auth: {
user: 'couchAdminUserName',
pass: 'couchAdminPassword'
}
}
}));
Give that a try and let me know if you are still having issues!
That worked perfectly @warrensplayer
Any chance we could have this added to the readme?
Closing this issue because I just updated the readme.
Hi there. Firstly - cool module, crazy that this hadn't already been done well.
Im trying to use some of the basic methods by following the readme, but so far im having no luck.
Every request I make is denied (500, 403), essentially saying I don't have access to the user's table. I have tried a signin method with my DB admin credentials and then a sign up request - didn't work.
The readme and its examples don't seem to make any any reference to where admin credentials go, so couchUser can execute the views from the init file on my _users database. There is two different usage examples at the top and bottom of the readme, and I have no idea what the bottom one refers to:
Top
var couchUser = require('express-couchUser');
var express = require('express');
var app = express();
// Required for session storage
app.use(express.cookieParser());
app.use(express.session({ secret: 'Use something else here.'}));
app.configure(function() {
app.use(couchUser({
users: 'http://localhost:5984/_users',
email: {
...
},
adminRoles: [ 'admin' ],
validateUser: function(data, cb) {...}
}));
});
Bottom
var user = require('express-user-couchdb');
var config = {
users: 'http://localhost:5984/_users',
email ....
};
app.config(function() {
// handle other requests first
app.use(express.router);
// handle core requests
app.use(user(config));
});
node init.js [couchdb users db]
So in simple terms, what is the minimum requirement to get this module up and running. Have I missed anything obvious?
Cheers