Permalink
Browse files

Merge branch 'master' of https://github.com/bnoguchi/mongoose-auth

Conflicts:
	package.json
  • Loading branch information...
2 parents 01981a4 + 13945ec commit 0a61107ac7b3c2eca6fc28bea32220313e7f338c @bnoguchi committed Feb 9, 2012
Showing with 28 additions and 24 deletions.
  1. +2 −5 Makefile
  2. +1 −3 README.md
  3. +2 −2 lib/modules/password/plugin.js
  4. +7 −2 package.json
  5. +16 −12 test/authplugin.test.js
View
@@ -1,7 +1,4 @@
test:
- @expresso test/authplugin.test.js
+ @node_modules/.bin/mocha
-test-cov:
- @TESTFLAGS=--cov $(MAKE) test
-
-.PHONY: test test-cov
+.PHONY: test
View
@@ -14,6 +14,7 @@ mongoose-auth supports the following authorization strategies:
- `twitter`
- `github`
- `instagram`
+- `google`
mongoose-auth does 3 things:
@@ -167,9 +168,6 @@ You can also use multiple authorization strategies in the same application.
Here is an example, using 5 authorization strategies:
```javascript
- // A configuration file for holding all of your
- // 3rd party OAuth credentials
- var conf = require('./conf');
// A configuration file for holding all of your
// 3rd party OAuth credentials
var conf = require('./conf');
@@ -36,8 +36,8 @@ exports = module.exports = function (schema, opts) {
return this._password;
}).set( function (password) {
this._password = password;
- var salt = this.salt = bcrypt.gen_salt_sync(10);
- this.hash = bcrypt.encrypt_sync(password, salt);
+ var salt = this.salt = bcrypt.genSaltSync(10);
+ this.hash = bcrypt.hashSync(password, salt);
});
schema.method('authenticate', function (password, callback) {
View
@@ -13,14 +13,19 @@
"lib": "."
},
"dependencies": {
- "bcrypt":">=0.2.0",
+ "bcrypt":">=0.5.0",
"mongoose": ">=2.4.8",
"everyauth": ">=0.2.28",
"mongoose-types": ">=1.0.3"
},
"devDependencies": {
"express": ">=2.3.2",
- "jade": ">=0.12.1"
+ "jade": ">=0.12.1",
+ "mocha": ">=0.10.1",
+ "should": ">=0.5.1"
+ },
+ "scripts": {
+ "test": "make"
},
"engines": {
"node": ">=0.4.0"
View
@@ -11,26 +11,30 @@ UserSchema.plugin(authPlugin, {
mongoose.model('User', UserSchema);
User = mongoose.model('User');
-module.exports = {
- "setting a user's password should generate a salt and set a hash": function () {
+describe('User', function () {
+ it('should generate a salt and set a hash when password is set', function () {
var user = new User();
should.strictEqual(undefined, user.salt);
should.strictEqual(undefined, user.hash);
user.password = 'hello';
user.password.should.equal('hello');
user.salt.should.not.be.undefined;
user.hash.should.not.be.undefined;
- },
-
- 'a user should authenticate with a correct password': function () {
+ });
+ it('should authenticate with a correct password', function (done) {
var user = new User();
user.password = 'hello';
- user.authenticate('hello').should.be.true;
- },
-
- 'a user should fail authentication with an incorrect password': function () {
+ user.authenticate('hello', function (err, matched) {
+ matched.should.be.true;
+ done();
+ });
+ });
+ it('should fail authentication with an incorrect password', function (done) {
var user = new User();
user.password = 'correct';
- user.authenticate('incorrect').should.be.false;
- }
-};
+ user.authenticate('incorrect', function (err, matched) {
+ matched.should.be.false;
+ done();
+ });
+ });
+});

0 comments on commit 0a61107

Please sign in to comment.