diff options
| author | Jules Laplace <jules@okfoc.us> | 2014-08-25 13:12:27 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2014-08-25 13:40:12 -0400 |
| commit | 099dfd16940c62e931bf01e7f62b7a45f2b8c654 (patch) | |
| tree | b10d4dc452d01783619966a43ea10decc75e4344 /server/lib/schemas | |
| parent | 4ef340497ef24bb2ecacb2c9c4106c24515c874f (diff) | |
collaborators api
Diffstat (limited to 'server/lib/schemas')
| -rw-r--r-- | server/lib/schemas/Collaborator.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/server/lib/schemas/Collaborator.js b/server/lib/schemas/Collaborator.js new file mode 100644 index 0000000..79e3287 --- /dev/null +++ b/server/lib/schemas/Collaborator.js @@ -0,0 +1,29 @@ +/* jshint node: true */ + +var mongoose = require('mongoose'), + _ = require('lodash'), + config = require('../../../config.json'), + util = require('../util'); + +var CollaboratorSchema = new mongoose.Schema({ + email: { type: String, required: true}, + project_id: { type: mongoose.Schema.ObjectId, index: true }, + user_id: { type: mongoose.Schema.ObjectId, index: true }, + nonce: { + type: String, + default: "", + }, + created_at: { type: Date }, + updated_at: { type: Date }, +}) + +CollaboratorSchema.statics.makeNonce = function(cb){ + crypto.pseudoRandomBytes(256, function (err, buf){ + var shasum = crypto.createHash('sha1') + shasum.update(buf) + cb( shasum.digest('hex') ) + }) +} + +module.exports = exports = mongoose.model('collaborator', CollaboratorSchema); +exports.schema = CollaboratorSchema; |
