Skip to content

Commit db22c08

Browse files
author
jtowers
committed
added all methods for use with authr. updated DB run during tests to sqlite and updated dev dependencies to require sqlite3
1 parent d9ab73a commit db22c08

File tree

4 files changed

+43
-7
lines changed

4 files changed

+43
-7
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ var config = {
2727
db: {
2828
type: 'mysql',
2929
host: localhost,
30-
port: 1337,
30+
port: 3306,
3131
database_name: 'authr',
3232
collection: 'users'
3333
}

index.js

+26
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,32 @@ Adapter.prototype.savePWResetToken = function (user, token, callback) {
597597
*/
598598

599599

600+
/**
601+
* Verify email address in the datastore
602+
* @param {Object} user = object containing user to verify
603+
* @param {Callback} callback - Execute a callback when done inserting
604+
* @return {verifyEmailAddressCallback} callback
605+
*/
606+
Adapter.prototype.verifyEmailAddress = function (user, callback) {
607+
user[this.config.user.email_verified] = true;
608+
var self = this;
609+
610+
user.save().success(function(){
611+
callback(null, user);
612+
}).error(function(err){
613+
throw err;
614+
});
615+
616+
};
617+
618+
/**
619+
* Handles response for verifyEmailAddress method
620+
* @callback verifyEmailAddressCallback
621+
* @param {String} err - error message, if it exists
622+
* @param {Object} user - user that was deleted
623+
*/
624+
625+
600626
// UTILITY METHODS
601627
// ---------------
602628

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@
2424
"async": "~0.9.0",
2525
"moment": "~2.8.1",
2626
"bcrypt": "~0.8.0",
27-
"sequelize": "~1.7.9",
28-
"mysql": "~2.4.3"
27+
"sequelize": "~1.7.9"
2928
},
3029
"devDependencies": {
3130
"mocha": "*",
3231
"chai": "*",
3332
"jsdoc": "~3.3.0-alpha9",
3433
"ink-docstrap": "~0.4.12",
35-
"blanket": "~1.1.6"
34+
"blanket": "~1.1.6",
35+
"sqlite3": "~2.2.7"
3636
},
3737
"directories": {
3838
"test": "test"

test/index.js

+13-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe('constructor', function () {
2626
email_verification_hash_expires: 'email_verification_expires'
2727
},
2828
db: {
29-
type: 'mysql',
29+
type: 'sqlite',
3030
host: '127.0.0.1',
3131
port: '3306',
3232
username: 'root',
@@ -75,7 +75,7 @@ describe('constructor', function () {
7575

7676
describe('', function(){
7777
it('should have the right db config', function (done) {
78-
adapter.config.db.type.should.equal('mysql');
78+
adapter.config.db.type.should.equal('sqlite');
7979
done();
8080
});
8181

@@ -308,7 +308,17 @@ describe('constructor', function () {
308308
done();
309309
});
310310
});
311-
})
311+
});
312+
313+
it('should be able to verify a user email address', function(done){
314+
adapter.isValueTaken(saved_user, adapter.config.user.username, function(err, user){
315+
adapter.verifyEmailAddress(user, function(err, usr){
316+
should.not.exist(err);
317+
usr[adapter.config.user.email_verified].should.equal(true);
318+
done();
319+
});
320+
});
321+
});
312322
});
313323
});
314324
});

0 commit comments

Comments
 (0)