mirror of
https://github.com/arnaucube/commonroutesServer.git
synced 2026-02-28 05:26:42 +01:00
hash of password passed from md5 to sha256
This commit is contained in:
@@ -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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user