Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/psirenny/derby-user
A user management library for Derby
https://github.com/psirenny/derby-user
Last synced: 26 days ago
JSON representation
A user management library for Derby
- Host: GitHub
- URL: https://github.com/psirenny/derby-user
- Owner: psirenny
- License: mit
- Archived: true
- Created: 2013-06-09T19:58:16.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2024-04-17T22:27:01.000Z (8 months ago)
- Last Synced: 2024-11-12T20:03:52.635Z (about 1 month ago)
- Language: JavaScript
- Homepage: http://derby-user-demo.herokuapp.com
- Size: 604 KB
- Stars: 4
- Watchers: 3
- Forks: 2
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-derby - derby-user - A user management system for the Derby JS framework (Information)
README
Derby User
==========A user library for [Derby JS](http://derbyjs.com).
It uses [Passport](http://passportjs.org) for authentication
and [Credential](https://github.com/dilvie/credential) for storing hashes.[![Build Status](https://travis-ci.org/psirenny/derby-user.png?branch=master)](https://travis-ci.org/psirenny/derby-user)
Installation
------------$ npm install derby-user --save
Server Usage
-----------In your server file, add the middleware:
var user = require('derby-user');
expressApp
// ...
// ...
// cookieParser, session, transport, model, bodyParser...
.use(user.init())
// ...
// ...
// app.router, expressApp.router
.use('/user', user.routes())App Usage
---------Example route:
// subscribe to current user in each route
app.get('*', function (page, model) {
var userId = model.get('_session.user.id');
var user = model.at('users.' + userId);
model.subscribe(user, function (err) {
if (err) return next(err);
model.ref('_page.user', user);
next();
});
});Example signin controller function:
app.proto.signin = function (username, password) {
var model = this.model;
$.post('/user/signin', {
username: username,
password: password
}).done(function (data) {
model.set('_session.user.id', data.user.id);
app.history.push('/');
});
};Example signin view:
username
password