Skip to content
Snippets Groups Projects
Commit 9b62d840 authored by Vytor Calixto's avatar Vytor Calixto :space_invader:
Browse files

Add verification token model

parent b7854376
No related branches found
No related tags found
2 merge requests!116Release v1.0.0,!73Workerpool feature
Pipeline #
......@@ -35,6 +35,7 @@
"monetdb-pool": "0.0.8",
"mongoose": "^4.6.0",
"nconf": "^0.8.x",
"node-uuid": "^1.4.8",
"nodemailer": "^4.0.1",
"nodemailer-html-to-text": "^2.1.0",
"passport": "^0.3.2",
......
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const libs = `${process.cwd()}/libs`;
const log = require(`${libs}/log`)(module);
const User = require(`${libs}/models/user`);
const uuid = require('node-uuid');
let VerificationToken = new Schema({
userId: {
type: Schema.Types.ObjectId,
required: true,
ref: 'User'
},
token: {
type: String,
required: true
},
createdAt: {
type: Date,
required: true,
default: Date.now,
expires: '4h'
}
});
VerificationToken.methods.createVerificationToken = function(done) {
let verificationToken = this;
let token = uuid.v4();
verificationToken.set('token', token);
verificationToken.save(function(err) {
if (err) return done(err);
log.debug('Verification Token', verificationToken);
return done(null, token);
})
}
module.exports = mongoose.model('VerificationToken', VerificationToken);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment