Skip to content

Commit

Permalink
Commit of big refactor to using generic StepSequence instances and us…
Browse files Browse the repository at this point in the history
…ing breakTo semantics (replaces the if semantics attached to what are now RouteTriggeredSequence instances)
  • Loading branch information
bnoguchi committed May 2, 2011
1 parent 33c6492 commit 1fded46
Show file tree
Hide file tree
Showing 11 changed files with 444 additions and 458 deletions.
25 changes: 22 additions & 3 deletions example/server.js
Expand Up @@ -53,9 +53,28 @@ everyauth
.getRegisterPath('/register')
.postRegisterPath('/register')
.registerView('register.jade')
.registerUser( function (login, password) {
return usersByLogin[login] = {
login: login, password: password };
.validateRegistration( function (login, password, extraParams, req, res) {
if (!login)
return this.breakTo('registrationError', req, res, 'Missing login');
if (!password)
return this.breakTo('registrationError', req, res, 'Missing password');

// simulate an async user db
var promise = this.Promise();
setTimeout( function () {
if (login in usersByLogin) {
return promise.breakTo('registrationError', req, res, 'Someone already has the login ' + login);
}
promise.fulfill({
login: login
, password: password
});
}, 200);
return promise;
})
.registerUser( function (newUserAttrs) {
var login = newUserAttrs.login;
return usersByLogin[login] = newUserAttrs;
})

.redirectPath('/');
Expand Down
2 changes: 2 additions & 0 deletions example/views/register.jade
@@ -1,4 +1,6 @@
h2 Register
- if ('undefined' !== typeof errorMessage)
#error= errorMessage
form(action: '/register', method: 'POST')
#login
label(for: 'login') Login
Expand Down
190 changes: 0 additions & 190 deletions lib/deprecated.js

This file was deleted.

0 comments on commit 1fded46

Please sign in to comment.