1.2.0 • Published 8 years ago

derby-user v1.2.0

Weekly downloads
6
License
MIT
Repository
github
Last release
8 years ago

Derby User

A user library for Derby JS. It uses Passport for authentication and Credential for storing hashes.

Build Status

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:

<form on-submit="signin(username, password)">
  <label>username</label>
  <input type="text" value="{username}">
  <label>password</label>
  <input type="password" value="{password}">
</form>
1.2.0

8 years ago

1.1.0

8 years ago

1.0.7

9 years ago

1.0.6

9 years ago

1.0.5

9 years ago

1.0.4

9 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago

0.13.0

9 years ago

0.12.0

9 years ago

0.11.0

10 years ago

0.10.3

10 years ago

0.10.2

10 years ago

0.10.1

10 years ago

0.10.0

10 years ago

0.9.0

10 years ago

0.8.1

10 years ago

0.8.0

10 years ago

0.7.1

10 years ago

0.7.0

10 years ago

0.6.1

11 years ago

0.6.0

11 years ago

0.5.2

11 years ago

0.5.1

11 years ago

0.5.0

11 years ago

0.4.0

11 years ago

0.3.0

11 years ago

0.2.2

11 years ago

0.2.1

11 years ago

0.2.0

11 years ago

0.1.0

11 years ago