1.0.0 • Published 9 years ago
basic-user v1.0.0
basic-user
A really super simple file-based user library with usernames/hased passwords/key-value pairs.
Usage
var User = require("basic-user");
var user = new User("Janeway");
user.setPassword("voyager", function(err, user) {
user.save(function(err) {
// ... Yeah!
});
});
Functions
User Constructor
Creates a new user
new User([username or props])
username
- The new user's usernameprops
- An object with the keysusername
,password
, andprops
on it.
getUser
Gets a user from the file system
User.getUser(username, callback)
username
- The username to lookupcallback
- A callback with the signaturefunction(err, user)
exists
Checks if a user exists on the file system
User.exists(username)
username
- The username to lookup
setDirectory
Set the directory to look for user files in (The directory defaults to ./users)
User.setDirectory(dir)
dir
- The directory to look for users in
Methods
setPassword
Sets the user's password
myUser.setPassword(password, callback)
password
- The password to setcallback
- A callback with the signaturefunction(err, user)
verifyPassword
Check the supplied password against the user's hash
myUser.verifyPassword(password, callback)
password
- The password to check againstcallback
- A callback with the signaturefunction(err, isCorrect)
whereisCorrect
is a boolean.
save
Save the user to the file system
myUser.save(callback)
callback
- A callback with the signaturefunction(err)
get
Gets the value of a user's property
myUser.get(prop)
prop
- The property to get
set
Sets the value of a user's property
myUser.set(prop, value)
prop
- The property to setvalue
- The value to set the property to
1.0.0
9 years ago