Allow user.default to be an api function

This commit is contained in:
Nick O'Leary 2015-02-05 10:45:03 +00:00
parent 53a515176b
commit 26c42e500f
1 changed files with 17 additions and 11 deletions

View File

@ -23,17 +23,19 @@ var util = require("util");
users: [{ users: [{
username: "nol", username: "nol",
password: "5f4dcc3b5aa765d61d8327deb882cf99" // password password: "5f4dcc3b5aa765d61d8327deb882cf99" // password
permissions: "* read write"
}], }],
default: {} default: {
permissions: "* read write"
}
}, },
adminAuth: { adminAuth: {
type: "credentials", type: "credentials",
api: { users: function(username) {return when.resolve(user)},
get: function(username) {} authenticate: function(username,password) { return when.resolve(user);}
authenticate: function(username,password) {} default: function() { return when.resolve(defaultUser) }
default: function() {} }
}
*/ */
//{username:"nick",password:crypto.createHash('md5').update("foo",'utf8').digest('hex')} //{username:"nick",password:crypto.createHash('md5').update("foo",'utf8').digest('hex')}
@ -95,11 +97,15 @@ function init(config) {
} }
} }
if (config.default) { if (config.default) {
api.default = function() { if (typeof config.default === "function") {
return when.resolve({ api.default = config.default;
"anonymous": true, } else {
"permissions":config.default.permissions api.default = function() {
}); return when.resolve({
"anonymous": true,
"permissions":config.default.permissions
});
}
} }
} else { } else {
api.default = getDefaultUser; api.default = getDefaultUser;