auth
Server-side plugin for modella. Supports auto-salting, password hashing (using pbkdf2) and authentication.
Example
var modella = ;var auth = ; // Create modelvar User = ; // Use middlewareUser; // creatingUser // after submitting a formUser // or authenticate an existing user User;
API
auth(opts)
Initialize auth with the following options:
- opts.password: the password attribute to lookup (default:
password
) - opts.salt: the salt attribute to use as a hash (default:
salt
)
auth introduces the following methods to your modella models:
Model#authenticate(id, password, fn)
Find your model with id
and confirm it with your password
. fn
will return the model if the given credentials are correct, false
if your credentials are wrong, or an err
if something bad happened.
License
MIT