Save users in ~/.shout/
This commit is contained in:
parent
fb6ac7168e
commit
752c4c491b
|
@ -168,6 +168,7 @@
|
||||||
<script src="js/libs/string.contains.js"></script>
|
<script src="js/libs/string.contains.js"></script>
|
||||||
<script src="js/libs/uri.js"></script>
|
<script src="js/libs/uri.js"></script>
|
||||||
<script src="js/shout.js"></script>
|
<script src="js/shout.js"></script>
|
||||||
|
<script src="js/shout.templates.js"></script>
|
||||||
<% } else { %>
|
<% } else { %>
|
||||||
<script src="dist/build.js"></script>
|
<script src="dist/build.js"></script>
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "shout",
|
"name": "shout",
|
||||||
"description": "A web IRC client",
|
"description": "A web IRC client",
|
||||||
"version": "0.11.0",
|
"version": "0.12.0",
|
||||||
"author": "Mattias Erming",
|
"author": "Mattias Erming",
|
||||||
"preferGlobal": true,
|
"preferGlobal": true,
|
||||||
"bin": {
|
"bin": {
|
||||||
|
@ -12,7 +12,7 @@
|
||||||
"url": "https://github.com/erming/shout.git"
|
"url": "https://github.com/erming/shout.git"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node index start"
|
"start": "node index"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"browser",
|
"browser",
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
var _ = require("lodash");
|
var _ = require("lodash");
|
||||||
var fs = require("fs");
|
var fs = require("fs");
|
||||||
var Client = require("./client");
|
var Client = require("./client");
|
||||||
|
var mkdirp = require("mkdirp");
|
||||||
|
|
||||||
|
const HOME = process.env.HOME + "/.shout";
|
||||||
|
|
||||||
module.exports = ClientManager;
|
module.exports = ClientManager;
|
||||||
|
|
||||||
|
@ -37,7 +40,10 @@ ClientManager.prototype.loadUsers = function(sockets) {
|
||||||
|
|
||||||
ClientManager.prototype.loadUser = function(name) {
|
ClientManager.prototype.loadUser = function(name) {
|
||||||
try {
|
try {
|
||||||
var json = fs.readFileSync("users/" + name + "/user.json", "utf-8");
|
var json = fs.readFileSync(
|
||||||
|
HOME + "/users/" + name + "/user.json",
|
||||||
|
"utf-8"
|
||||||
|
);
|
||||||
json = JSON.parse(json);
|
json = JSON.parse(json);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
|
@ -48,8 +54,10 @@ ClientManager.prototype.loadUser = function(name) {
|
||||||
|
|
||||||
ClientManager.prototype.getUsers = function() {
|
ClientManager.prototype.getUsers = function() {
|
||||||
var users = [];
|
var users = [];
|
||||||
|
var path = HOME + "/users/";
|
||||||
|
mkdirp.sync(path);
|
||||||
try {
|
try {
|
||||||
users = fs.readdirSync("users/");
|
users = fs.readdirSync(path);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
return;
|
return;
|
||||||
|
@ -67,7 +75,7 @@ ClientManager.prototype.addUser = function(name, password) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
var path = "users/" + name;
|
var path = HOME + "/users/" + name;
|
||||||
var user = {
|
var user = {
|
||||||
user: name,
|
user: name,
|
||||||
password: password || "",
|
password: password || "",
|
||||||
|
@ -91,7 +99,7 @@ ClientManager.prototype.removeUser = function(name) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
var path = "users/" + name;
|
var path = HOME + "/users/" + name;
|
||||||
fs.unlinkSync(path + "/user.json");
|
fs.unlinkSync(path + "/user.json");
|
||||||
fs.rmdirSync(path);
|
fs.rmdirSync(path);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
|
|
|
@ -2,12 +2,14 @@ var ClientManager = new require("../clientManager");
|
||||||
var fs = require("fs");
|
var fs = require("fs");
|
||||||
var program = require("commander");
|
var program = require("commander");
|
||||||
|
|
||||||
|
const HOME = process.env.HOME + "/.shout";
|
||||||
|
|
||||||
program
|
program
|
||||||
.command("add <name>")
|
.command("add <name>")
|
||||||
.description("Add a new user")
|
.description("Add a new user")
|
||||||
.action(function(name) {
|
.action(function(name) {
|
||||||
try {
|
try {
|
||||||
var path = process.cwd() + "/users";
|
var path = HOME + "/users";
|
||||||
var test = path + "/.test";
|
var test = path + "/.test";
|
||||||
fs.mkdirSync(test);
|
fs.mkdirSync(test);
|
||||||
fs.rmdirSync(test);
|
fs.rmdirSync(test);
|
||||||
|
|
|
@ -2,6 +2,8 @@ var ClientManager = new require("../clientManager");
|
||||||
var program = require("commander");
|
var program = require("commander");
|
||||||
var child = require("child_process");
|
var child = require("child_process");
|
||||||
|
|
||||||
|
const HOME = process.env.HOME + "/.shout";
|
||||||
|
|
||||||
program
|
program
|
||||||
.command("edit <name>")
|
.command("edit <name>")
|
||||||
.description("Edit an existing user")
|
.description("Edit an existing user")
|
||||||
|
@ -13,9 +15,10 @@ program
|
||||||
console.log("");
|
console.log("");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
var path = HOME + "/users/";
|
||||||
child.spawn(
|
child.spawn(
|
||||||
"sudo",
|
"vi",
|
||||||
["vi", process.cwd() + "/users/" + name + "/user.json"],
|
[path + name + "/user.json"],
|
||||||
{stdio: "inherit"}
|
{stdio: "inherit"}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,12 +2,14 @@ var ClientManager = new require("../clientManager");
|
||||||
var fs = require("fs");
|
var fs = require("fs");
|
||||||
var program = require("commander");
|
var program = require("commander");
|
||||||
|
|
||||||
|
const HOME = process.env.HOME + "/.shout";
|
||||||
|
|
||||||
program
|
program
|
||||||
.command("remove <name>")
|
.command("remove <name>")
|
||||||
.description("Remove an existing user")
|
.description("Remove an existing user")
|
||||||
.action(function(name) {
|
.action(function(name) {
|
||||||
try {
|
try {
|
||||||
var path = process.cwd() + "/users";
|
var path = HOME + "/users";
|
||||||
var test = path + "/.test";
|
var test = path + "/.test";
|
||||||
fs.mkdirSync(test);
|
fs.mkdirSync(test);
|
||||||
fs.rmdirSync(test);
|
fs.rmdirSync(test);
|
||||||
|
|
Loading…
Reference in New Issue