Auth- Added Back-end Logic

removed personal details
This commit is contained in:
Curtis SerVaas
2014-08-07 17:47:09 -04:00
parent 91661c448c
commit bd8b510a73
8 changed files with 220 additions and 83 deletions
+10 -27
View File
@@ -1,29 +1,12 @@
//(not being used yet)
var mongoose = require('mongoose');
var crypto = require('crypto')
var db = require('../lib/db');
var UserSchema = new db.Schema({
username : {type: String, unique: true}
, password : String
})
var MyUser = db.mongoose.model('User', UserSchema);
// Exports
module.exports.addUser = addUser;
// Add user to database
function addUser(username, password, callback) {
var instance = new MyUser();
instance.username = username;
instance.password = encryptPassword(password);
instance.save(function (err) {
if (err) {
callback(err);
}
else {
callback(null, instance);
var userSchema = mongoose.Schema({
google : {
id : String,
token : String,
email : String,
name : String
}
});
}
function encryptPassword(plainText) {
return crypto.createHash('md5').update(plainText).digest('hex');
}
});
// create the model for users and expose it to our app
module.exports = mongoose.model('User', userSchema);