Added password hashing

This commit is contained in:
Mattias Erming 2014-09-11 13:37:16 -07:00
parent 9a7d00781f
commit 428f63946b
4 changed files with 29 additions and 20 deletions

View File

@ -142,7 +142,6 @@ $(function() {
channels: [data.chan]
})
);
sidebar.find(".chan")
.sort(function(a, b) { return $(a).data("id") - $(b).data("id") })
.last()

View File

@ -1,7 +1,7 @@
{
"name": "shout",
"description": "A web IRC client",
"version": "0.24.0",
"version": "0.25.0",
"author": "Mattias Erming",
"preferGlobal": true,
"bin": {
@ -32,6 +32,7 @@
],
"license": "MIT",
"dependencies": {
"bcrypt": "^0.8.0",
"commander": "^2.3.0",
"connect": "~2.19.6",
"lodash": "~2.4.1",

View File

@ -1,4 +1,5 @@
var ClientManager = new require("../clientManager");
var bcrypt = require("bcrypt");
var fs = require("fs");
var program = require("commander");
var mkdirp = require("mkdirp");
@ -46,11 +47,16 @@ program
if (err) {
return;
}
var success = manager.addUser(
bcrypt.hash(password, 8, function(err, hash) {
if (err) {
return;
}
manager.addUser(
name,
password
hash
);
console.log("Added '" + name + "'.");
console.log("");
});
});
});

View File

@ -1,4 +1,5 @@
var _ = require("lodash");
var bcrypt = require("bcrypt");
var Client = require("./client");
var ClientManager = require("./clientManager");
var config = require("../config.json");
@ -94,11 +95,13 @@ function auth(data) {
});
init(socket, client);
} else {
var success = 0;
var success = false;
_.each(manager.clients, function(client) {
if (client.config.user == data.user && client.config.password == data.password) {
if (client.config.user == data.user) {
if (bcrypt.compareSync(data.password, client.config.password)) {
init(socket, client);
success++;
success = true;
}
}
});
if (!success) {