Browse Source

hash of password passed from md5 to sha256

master
arnaucode 8 years ago
parent
commit
1e9e4cdf94
1 changed files with 4 additions and 2 deletions
  1. +4
    -2
      controllers/userController.js

+ 4
- 2
controllers/userController.js

@ -10,6 +10,8 @@ var express = require("express");
var app = express(); var app = express();
var config = require('../config'); // get our config file var config = require('../config'); // get our config file
app.set('superSecret', config.secret); // secret variable app.set('superSecret', config.secret); // secret variable
var crypto = require('crypto');
/* */ /* */
//GET - Return all Users in the DB //GET - Return all Users in the DB
@ -75,7 +77,7 @@ exports.addUser = function(req, res) {
var user = new userModel({ var user = new userModel({
username: req.body.username, username: req.body.username,
password: md5(req.body.password),
password: crypto.createHash('sha256').update(req.body.password).digest('base64'),
description: req.body.description, description: req.body.description,
avatar: req.body.avatar, avatar: req.body.avatar,
mail: req.body.mail, mail: req.body.mail,
@ -237,7 +239,7 @@ exports.login = function(req, res) {
res.json({ success: false, message: 'Authentication failed. User not found.' }); res.json({ success: false, message: 'Authentication failed. User not found.' });
} else if (user) { } else if (user) {
req.body.password=md5(req.body.password);
req.body.password=crypto.createHash('sha256').update(req.body.password).digest('base64');
// check if password matches // check if password matches
if (user.password != req.body.password) { if (user.password != req.body.password) {

Loading…
Cancel
Save