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,20 +1,20 @@
{ {
"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": {
"shout": "index.js" "shout": "index.js"
}, },
"main": "http://localhost:9000/", "main": "http://localhost:9000/",
"node-main": "./index.js", "node-main": "./index.js",
"window": { "window": {
"title": "Shout", "title": "Shout",
"toolbar": false, "toolbar": false,
"height": 640, "height": 640,
"width": 1024 "width": 1024
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/erming/shout.git" "url": "https://github.com/erming/shout.git"
@ -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) {
name, if (err) {
password return;
); }
console.log("Added '" + name + "'."); manager.addUser(
console.log(""); name,
hash
);
console.log("Added '" + name + "'.");
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) {
init(socket, client); if (bcrypt.compareSync(data.password, client.config.password)) {
success++; init(socket, client);
success = true;
}
} }
}); });
if (!success) { if (!success) {