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] channels: [data.chan]
}) })
); );
sidebar.find(".chan") sidebar.find(".chan")
.sort(function(a, b) { return $(a).data("id") - $(b).data("id") }) .sort(function(a, b) { return $(a).data("id") - $(b).data("id") })
.last() .last()

View File

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

View File

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

View File

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