-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
45 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,7 @@ | ||
var express = require('express') | ||
, passport = require('passport') | ||
, util = require('util') | ||
, LocalStrategy = require('../../../passport-webid').Strategy; | ||
|
||
|
||
var users = [ | ||
{ id: 1, username: 'bob', password: 'secret', email: '[email protected]' } | ||
, { id: 2, username: 'joe', password: 'birthday', email: '[email protected]' } | ||
]; | ||
|
||
function findById(id, fn) { | ||
var idx = id - 1; | ||
if (users[idx]) { | ||
fn(null, users[idx]); | ||
} else { | ||
fn(new Error('User ' + id + ' does not exist')); | ||
} | ||
} | ||
|
||
function findByUsername(username, fn) { | ||
for (var i = 0, len = users.length; i < len; i++) { | ||
var user = users[i]; | ||
if (user.username === username) { | ||
return fn(null, user); | ||
} | ||
} | ||
return fn(null, null); | ||
} | ||
, WebIDStrategy = require('../../../passport-webid').Strategy; | ||
|
||
|
||
// Passport session setup. | ||
|
@@ -50,7 +25,7 @@ passport.deserializeUser(function(id, done) { | |
// credentials (in this case, a username and password), and invoke a callback | ||
// with a user object. In the real world, this would query a database; | ||
// however, in this example we are using a baked-in set of users. | ||
passport.use(new LocalStrategy( | ||
passport.use(new WebIDStrategy( | ||
function(username, password, done) { | ||
// asynchronous verification, for effect... | ||
process.nextTick(function () { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters