hashPw = function(pw) { return bcrypt.hashSync(pw, bcrypt.genSaltSync(8), null); };
// methods ====================== // generating a hash function generateHash(password) { return bcrypt.hashSync(password, bcrypt.genSaltSync(8), null); };
exports.generateHash = function(password){ return bCrypt.hashSync(password, bCrypt.genSaltSync(10), null); };
var createHash = function(password){ return bCrypt.hashSync(password, bCrypt.genSaltSync(109), null); };
.set(function(password) { this.salt = bcrypt.genSaltSync(10); this.hash = bcrypt.hashSync(password, this.salt); });
UserSchema.methods.generateHash = function(password) { return bcrypt.hashSync(password, bcrypt.genSaltSync(SALT_WORK_FACTOR), null); };
set : function(password){ this.setDataValue('password',bcrypt.hashSync(password, bcrypt.genSaltSync(8), null)); }
beforeCreate: user => { const salt = bcrypt.genSaltSync(); user.password = bcrypt.hashSync(user.password, salt); },
userSchema.methods.encryptPassword = (password) => { return bcrypt.hashSync(password, bcrypt.genSaltSync(10), null); };
UserSchema.methods.setPassword = function(password) { this.local.password = bcrypt.hashSync(password, bcrypt.genSaltSync(8), null); };
userSchema.methods.hashPassword = function (password) { return bcrypt.hashSync(password, bcrypt.genSaltSync(10), null); };
UserUtils.prototype.createHash = function(password) { return bCrypt.hashSync(password, bCrypt.genSaltSync(10), null); };
UserSchema.methods.generateHash = function (pw) { return bcrypt.hashSync(pw, bcrypt.genSaltSync(11), null); };
var crearHash = function(password){ return bcrypt.hashSync(password, bcrypt.genSaltSync(10), null); };
generate: (password) => { const salt = bCrypt.genSaltSync(10); return bCrypt.hashSync(password, salt); },
generateHash(password) { return bcrypt.hashSync(password, bcrypt.genSaltSync(10)); }
User.methods.encrypt = function( password ) { return bcrypt.hashSync( password, bcrypt.genSaltSync( 8 ), null ); }
// methods ====================== // generating a hash function hashUserPassword(password) { return bcrypt.hashSync(password, bcrypt.genSaltSync(8), null); };
this.generateHash = function(str){ return bcrypt.hashSync(str, bcrypt.genSaltSync(8), null); };
} } else { callback(true); } }, 'Email already exists'); accountSchema.methods = { /** * Create an unique salt sequence * * @return {Number} * @api public */ makeSalt() { return bcrypt.genSaltSync(8); }, /** * Encrypt password * * @param {String} password * @return {String} * @api public */ encryptPassword(password) { return bcrypt.hashSync(password, this.makeSalt()); }, /** * Ensure the password is valid
module.exports = function(user, res) { var user_id = user._id; var token = bcrypt.genSaltSync(20); Users_online.findOne({ id: user_id }, function(err, user_online) { console.log(user_online); if (err) { console.log(err); } else { if (!user_online) { console.log('Make new user'); var new_user_online = new Users_online(); new_user_online.id = user_id; new_user_online.save(function(err) { console.log(new_user_online) }); } } }) UserAuthen.findOne({ user_id: user_id }, function(err, user_authen_exist) { if (err) { res.json({ error_code: '401', msg: err.toString() }); res.status(200).end(); } else if (user_authen_exist) { // UPDATE TOKEN OF USER user_authen_exist.token = token; user_authen_exist.save(function(err) { if (err) { console.error(err); res.json({ error_code: 402, msg: err.toString() }); // database can't save res.status(200).end(); } else { res.json({ error_code: 0, user: { email: user.email, username: user.username, id: user._id, avatar: user.avatar, city: user.city, country: user.country, fb_id: user.facebook.id, tw_id: user.twitter.id, type_account: user.type_account, avatar_small: user.avatar_small }, unread_msg: user.unread_msg, token: token }); res.status(200).end(); } }) } else { // CREATE NEW USER var user_authen = new UserAuthen(); user_authen.user_id = user_id; user_authen.token = token; user_authen.save(function(err, user_authen) { if (err) { res.json({ error_code: 402, msg: err.toString() }); // database can't save res.status(200).end(); } else { res.json({ error_code: 0, user: { email: user.email, username: user.username, id: user._id, avatar: user.avatar, avatar_small: user.avatar_small, city: user.city, country: user.country, fb_id: user.facebook.id, tw_id: user.twitter.id, type_account: user.type_account }, unread_msg: user.unread_msg, token: token }); res.status(200).end(); } }) } }) }
schema.statics.generateHash = function(password) { return bcrypt.hashSync(password, bcrypt.genSaltSync(8), null); };
userSchema.methods.generateHash = function(password){ //2^9 goes through the algorythm to make it secure //not do it more than 13 as it can become slow return bcrypt.hashSync(password, bcrypt.genSaltSync(9)); };
static hashPassword(password) { return Bcrypt.hashSync(password, Bcrypt.genSaltSync()); }
userSchema.methods.generateHash = function (password, next) { bcrypt.hash(password, bcrypt.genSaltSync(8), null, next); };
var db = require('../config'); var bcrypt = require('bcrypt-nodejs'); var Promise = require('bluebird'); var User = db.Model.extend({ tableName: 'users', hasTimestamps: true, username: null, password: null, salt: null, initialize: function(){ this.on('creating', function(model, attrs, options){ model.set('password', bcrypt.hashSync(model.get('password'), model.get('salt'))); return; }); }, defaults: { salt: bcrypt.genSaltSync(10) } }); module.exports = User;
.set(function(password){ this._password = password; this.passwordHash = bcrypt.hashSync(password, bcrypt.genSaltSync(8), null); });
describe('Brewtorial recipe put/del by id routes', function() { var password = bcrypt.hashSync('foobaz123', bcrypt.genSaltSync(8), null); var testRecipeId; beforeEach(function(done){ var testUser = new User({ userId: uuid.v4(), displayName: 'test', basic: { email: '*****@*****.**', password: password } }); testUser.save(function(err, user) { if (err) console.log(err); var testUserId = user._id; var testRecipe = new Recipe({ header: { abv: 5, author: testUserId, brewTime: 20, created: Date.now(), difficulty: 2, icon: 'www.test.com/img', likes: 10, popularity: [testUserId], style: 'Amber', title: 'American Amber' }, equipment: ['big brew pot', 'thermometer'], ingredients: [ {item: 'malt extract', amount: '3.3', unit: 'pounds'}, {item: 'hops', amount: '.5', unit: 'ounces'} ], steps: [ { directions: 'Fill brew pot with 3 gallons of fresh water.', offset: 0, complete: false }, { directions: 'Add steeping grains', offset: 15, complete: false } ] }); testRecipe.save(function(err, recipe) { if (err) console.log(err); testRecipeId = recipe._id; done(); }); }); }); afterEach(function(done) { mongoose.connection.db.dropDatabase(function() { done(); }); }); it('should be able to reference a recipe id', function() { expect(testRecipeId).to.not.eql(null); }); it('should be able to get a recipe by its id', function(done) { chai.request('localhost:3000') .get('/api/recipe/' + testRecipeId) .end(function(err, res) { expect(res.status).to.eql(200); expect(err).to.eql(null); expect(res.body.success).to.eql(true); expect(res.body.result.header.title).to.eql('American Amber'); done(); }); }); it('should be able to update a recipe by its id', function(done) { chai.request('localhost:3000') .put('/api/recipe/' + testRecipeId) .send({'header.abv': 7}) .end(function(err, res) { expect(res.status).to.eql(200); expect(err).to.eql(null); expect(res.body.success).to.eql(true); done(); }); }); it('should be able to remove a recipe by its id', function(done) { chai.request('localhost:3000') .del('/api/recipe/' + testRecipeId) .end(function(err, res) { expect(res.status).to.eql(200); expect(err).to.eql(null); expect(res.body.success).to.eql(true); done(); }); }); });
userSchema.methods.generateHash = function(password){ return bcrypt.hashSync(password, bcrypt.genSaltSync(8), null); };
var orm = require('orm'); var bcrypt = require('bcrypt-nodejs'); var salt = bcrypt.genSaltSync(10); var users = require('../models/user'), owner = require('../models/owner'), vet = require('../models/vet'), dog = require('../models/dog'), event_ = require('../models/event'), symptom = require('../models/symptom'), symptomEvent = require('../models/symptomEvent'), disease = require('../models/disease'), comment = require('../models/comment'); var DB = orm.express('mysql://*****:*****@#@jimis.net/dogz', { define: function(db,models,next){ models.user = db.define('users',user.model, { methods: user.methods }); models.owner = db.define('owners', owner.model, { methods: owner.methods }); models.vet = db.define('veterinarian', vet.model, { methods: vet.methods }); models.dog = db.define('dogmaster',dog.model,{ methods: dog.methods }); models.event_ = db.define('events', event_.model,{ methods: event_.methods });