This repository has been archived by the owner on Feb 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
e6aebab
commit 8362945
Showing
35 changed files
with
328 additions
and
922 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
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
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
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,188 +0,0 @@ | ||
/** | ||
* Module dependencies. | ||
*/ | ||
var mongoose = require('mongoose'), | ||
config = require('../../config/config'), | ||
Schema = mongoose.Schema; | ||
|
||
|
||
/** | ||
* Experiment Schema | ||
*/ | ||
var ExperimentSchema = new Schema({ | ||
created: { | ||
type: Date, | ||
default: Date.now | ||
}, | ||
EXPERIMENT_ID: { | ||
type: String, | ||
default: '', | ||
trim: true | ||
}, | ||
STUDY_ID: { | ||
type: String, | ||
default: '', | ||
trim: true | ||
}, | ||
STUDY_NAME: { | ||
type: String, | ||
default: '', | ||
trim: true | ||
}, | ||
CENTER_NAME: { | ||
type: String, | ||
default: '', | ||
trim: true | ||
}, | ||
FIRST_SUBMISSION_DATE: { | ||
type: String, | ||
default: '', | ||
trim: true | ||
}, | ||
SEQ_RUNS_COUNT: { | ||
type: String, | ||
default: '', | ||
trim: true | ||
}, | ||
SAMPLE_ID: { | ||
type: String, | ||
default: '', | ||
trim: true | ||
}, | ||
SAMPLE_NAME: { | ||
type: String, | ||
default: '', | ||
trim: true | ||
}, | ||
INSTRUMENT_PLATFORM: { | ||
type: String, | ||
default: '', | ||
trim: true | ||
}, | ||
INSTRUMENT_MODEL: { | ||
type: String, | ||
default: '', | ||
trim: true | ||
}, | ||
LIBRARY_NAME: { | ||
type: String, | ||
default: '', | ||
trim: true | ||
}, | ||
LIBRARY_LAYOUT: { | ||
type: String, | ||
default: '', | ||
trim: true | ||
}, | ||
LIBRARY_STRATEGY: { | ||
type: String, | ||
default: '', | ||
trim: true | ||
}, | ||
EXPERIMENT_TYPE: { | ||
type: String, | ||
default: '', | ||
trim: true | ||
}, | ||
DISEASE: { | ||
type: String, | ||
default: '', | ||
trim: true | ||
}, | ||
BIOMATERIAL_PROVIDER: { | ||
type: String, | ||
default: '', | ||
trim: true | ||
}, | ||
BIOMATERIAL_TYPE: { | ||
type: String, | ||
default: '', | ||
trim: true | ||
}, | ||
CELL_TYPE: { | ||
type: String, | ||
default: '', | ||
trim: true | ||
}, | ||
SPECIMEN_PROCESSING: { | ||
type: String, | ||
default: '', | ||
trim: true | ||
}, | ||
SPECIMEN_STORAGE: { | ||
type: String, | ||
default: '', | ||
trim: true | ||
}, | ||
READ_QUALITIES: { | ||
type: String, | ||
default: '', | ||
trim: true | ||
}, | ||
MOLECULE: { | ||
type: String, | ||
default: '', | ||
trim: true | ||
}, | ||
RUN_ID: { | ||
type: String, | ||
default: '', | ||
trim: true | ||
}, | ||
READ_COUNT: { | ||
type: String, | ||
default: '', | ||
trim: true | ||
}, | ||
BASE_COUNT: { | ||
type: String, | ||
default: '', | ||
trim: true | ||
}, | ||
READ_LENGTH: { | ||
type: String, | ||
default: '', | ||
trim: true | ||
}, | ||
FILE: { | ||
type: String, | ||
default: '', | ||
trim: true | ||
}, | ||
WITHDRAWN: { | ||
type: String, | ||
default: '', | ||
trim: true | ||
}, | ||
TYPE: { | ||
type: String, | ||
default: '', | ||
trim: true | ||
}, | ||
FILE_MD5: { | ||
type: String, | ||
default: '', | ||
trim: true | ||
}, | ||
FILE_SIZE: { | ||
type: String, | ||
default: '', | ||
trim: true | ||
}, | ||
SUBMISSION_ID: { | ||
type: String, | ||
default: '', | ||
trim: true | ||
}, | ||
RUN_NAME: { | ||
type: String, | ||
default: '', | ||
trim: true | ||
}, | ||
user: { | ||
type: Schema.ObjectId, | ||
ref: 'User' | ||
} | ||
}); | ||
|
||
mongoose.model('Experiment', ExperimentSchema); | ||
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,124 +1,6 @@ | ||
/** | ||
* Module dependencies. | ||
*/ | ||
var mongoose = require('mongoose'), | ||
Schema = mongoose.Schema, | ||
crypto = require('crypto'), | ||
var crypto = require('crypto'), | ||
_ = require('underscore'), | ||
authTypes = ['github', 'twitter', 'facebook', 'google']; | ||
|
||
|
||
/** | ||
* User Schema | ||
*/ | ||
var UserSchema = new Schema({ | ||
name: String, | ||
email: String, | ||
username: { | ||
type: String, | ||
unique: true | ||
}, | ||
provider: String, | ||
hashed_password: String, | ||
salt: String, | ||
facebook: {}, | ||
twitter: {}, | ||
github: {}, | ||
google: {} | ||
}); | ||
|
||
/** | ||
* Virtuals | ||
*/ | ||
UserSchema.virtual('password').set(function(password) { | ||
this._password = password; | ||
this.salt = this.makeSalt(); | ||
this.hashed_password = this.encryptPassword(password); | ||
}).get(function() { | ||
return this._password; | ||
}); | ||
|
||
/** | ||
* Validations | ||
*/ | ||
var validatePresenceOf = function(value) { | ||
return value && value.length; | ||
}; | ||
|
||
// the below 4 validations only apply if you are signing up traditionally | ||
UserSchema.path('name').validate(function(name) { | ||
// if you are authenticating by any of the oauth strategies, don't validate | ||
if (authTypes.indexOf(this.provider) !== -1) return true; | ||
return name.length; | ||
}, 'Name cannot be blank'); | ||
|
||
UserSchema.path('email').validate(function(email) { | ||
// if you are authenticating by any of the oauth strategies, don't validate | ||
if (authTypes.indexOf(this.provider) !== -1) return true; | ||
return email.length; | ||
}, 'Email cannot be blank'); | ||
|
||
UserSchema.path('username').validate(function(username) { | ||
// if you are authenticating by any of the oauth strategies, don't validate | ||
if (authTypes.indexOf(this.provider) !== -1) return true; | ||
return username.length; | ||
}, 'Username cannot be blank'); | ||
|
||
UserSchema.path('hashed_password').validate(function(hashed_password) { | ||
// if you are authenticating by any of the oauth strategies, don't validate | ||
if (authTypes.indexOf(this.provider) !== -1) return true; | ||
return hashed_password.length; | ||
}, 'Password cannot be blank'); | ||
|
||
|
||
/** | ||
* Pre-save hook | ||
*/ | ||
UserSchema.pre('save', function(next) { | ||
if (!this.isNew) return next(); | ||
|
||
if (!validatePresenceOf(this.password) && authTypes.indexOf(this.provider) === -1) | ||
next(new Error('Invalid password')); | ||
else | ||
next(); | ||
}); | ||
|
||
/** | ||
* Methods | ||
*/ | ||
UserSchema.methods = { | ||
/** | ||
* Authenticate - check if the passwords are the same | ||
* | ||
* @param {String} plainText | ||
* @return {Boolean} | ||
* @api public | ||
*/ | ||
authenticate: function(plainText) { | ||
return this.encryptPassword(plainText) === this.hashed_password; | ||
}, | ||
|
||
/** | ||
* Make salt | ||
* | ||
* @return {String} | ||
* @api public | ||
*/ | ||
makeSalt: function() { | ||
return Math.round((new Date().valueOf() * Math.random())) + ''; | ||
}, | ||
|
||
/** | ||
* Encrypt password | ||
* | ||
* @param {String} password | ||
* @return {String} | ||
* @api public | ||
*/ | ||
encryptPassword: function(password) { | ||
if (!password) return ''; | ||
return crypto.createHmac('sha1', this.salt).update(password).digest('hex'); | ||
} | ||
}; | ||
|
||
mongoose.model('User', UserSchema); |
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
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
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
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
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
Oops, something went wrong.