Added password hashing
This commit is contained in:
parent
9a7d00781f
commit
428f63946b
|
@ -142,7 +142,6 @@ $(function() {
|
|||
channels: [data.chan]
|
||||
})
|
||||
);
|
||||
|
||||
sidebar.find(".chan")
|
||||
.sort(function(a, b) { return $(a).data("id") - $(b).data("id") })
|
||||
.last()
|
||||
|
|
19
package.json
19
package.json
|
@ -1,20 +1,20 @@
|
|||
{
|
||||
"name": "shout",
|
||||
"description": "A web IRC client",
|
||||
"version": "0.24.0",
|
||||
"version": "0.25.0",
|
||||
"author": "Mattias Erming",
|
||||
"preferGlobal": true,
|
||||
"bin": {
|
||||
"shout": "index.js"
|
||||
},
|
||||
"main": "http://localhost:9000/",
|
||||
"node-main": "./index.js",
|
||||
"window": {
|
||||
"title": "Shout",
|
||||
"toolbar": false,
|
||||
"height": 640,
|
||||
"width": 1024
|
||||
},
|
||||
"main": "http://localhost:9000/",
|
||||
"node-main": "./index.js",
|
||||
"window": {
|
||||
"title": "Shout",
|
||||
"toolbar": false,
|
||||
"height": 640,
|
||||
"width": 1024
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/erming/shout.git"
|
||||
|
@ -32,6 +32,7 @@
|
|||
],
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"bcrypt": "^0.8.0",
|
||||
"commander": "^2.3.0",
|
||||
"connect": "~2.19.6",
|
||||
"lodash": "~2.4.1",
|
||||
|
|
|
@ -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(
|
||||
name,
|
||||
password
|
||||
);
|
||||
console.log("Added '" + name + "'.");
|
||||
console.log("");
|
||||
bcrypt.hash(password, 8, function(err, hash) {
|
||||
if (err) {
|
||||
return;
|
||||
}
|
||||
manager.addUser(
|
||||
name,
|
||||
hash
|
||||
);
|
||||
console.log("Added '" + name + "'.");
|
||||
console.log("");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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) {
|
||||
init(socket, client);
|
||||
success++;
|
||||
if (client.config.user == data.user) {
|
||||
if (bcrypt.compareSync(data.password, client.config.password)) {
|
||||
init(socket, client);
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
if (!success) {
|
||||
|
|
Loading…
Reference in New Issue