diff options
author | marzavec <admin@marzavec.com> | 2018-03-14 06:26:53 +0100 |
---|---|---|
committer | marzavec <admin@marzavec.com> | 2018-03-14 06:26:53 +0100 |
commit | 39ec02d3c4cb5f5980b172d30404210de2479f0f (patch) | |
tree | b837c9cfff94c62aa3de9880e4f7d07460734984 /server/src/commands/core/join.js | |
parent | stabilized modules and server cmd field (diff) | |
download | hackchat-39ec02d3c4cb5f5980b172d30404210de2479f0f.tar.gz hackchat-39ec02d3c4cb5f5980b172d30404210de2479f0f.zip |
Streamlined modules, server tweaks, better feedback
Diffstat (limited to 'server/src/commands/core/join.js')
-rw-r--r-- | server/src/commands/core/join.js | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/server/src/commands/core/join.js b/server/src/commands/core/join.js index 609e39d..e896361 100644 --- a/server/src/commands/core/join.js +++ b/server/src/commands/core/join.js @@ -1,20 +1,20 @@ /* - + Description: Initial entry point, applies `channel` and `nick` to the calling socket */ 'use strict'; const crypto = require('crypto'); -function hash(password) { - var sha = crypto.createHash('sha256'); +const hash = (password) => { + let sha = crypto.createHash('sha256'); sha.update(password); return sha.digest('base64').substr(0, 6); -} +}; -function verifyNickname(nick) { +const verifyNickname = (nick) => { return /^[a-zA-Z0-9_]{1,24}$/.test(nick); -} +}; exports.run = async (core, server, socket, data) => { if (server._police.frisk(socket.remoteAddress, 3)) { @@ -53,7 +53,7 @@ exports.run = async (core, server, socket, data) => { text: 'Nickname must consist of up to 24 letters, numbers, and underscores' }, socket); - return + return; } for (let client of server.clients) { @@ -99,7 +99,8 @@ exports.run = async (core, server, socket, data) => { server.broadcast({ cmd: 'onlineAdd', nick: nick, - trip: trip || 'null' + trip: trip || 'null', + hash: server.getSocketHash(socket) }, { channel: channel }); socket.uType = uType; |