Skip to content

Commit 51b087a

Browse files
committed
v0.26.7 - Show user IPs to admins on Users panel
1 parent 9c103aa commit 51b087a

4 files changed

Lines changed: 25 additions & 8 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Node.JS Chat
22
============
3-
[![GitHub Stars](https://img.shields.io/github/stars/IgorAntun/node-chat.svg)](https://github.com/IgorAntun/node-chat/stargazers) [![GitHub Issues](https://img.shields.io/github/issues/IgorAntun/node-chat.svg)](https://github.com/IgorAntun/node-chat/issues) [![Current Version](https://img.shields.io/badge/version-0.26.3-green.svg)](https://github.com/IgorAntun/node-chat) [![Live Demo](https://img.shields.io/badge/demo-online-green.svg)](https://igorantun.com/chat) " [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/IgorAntun/node-chat?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
3+
[![GitHub Stars](https://img.shields.io/github/stars/IgorAntun/node-chat.svg)](https://github.com/IgorAntun/node-chat/stargazers) [![GitHub Issues](https://img.shields.io/github/issues/IgorAntun/node-chat.svg)](https://github.com/IgorAntun/node-chat/issues) [![Current Version](https://img.shields.io/badge/version-0.26.7-green.svg)](https://github.com/IgorAntun/node-chat) [![Live Demo](https://img.shields.io/badge/demo-online-green.svg)](https://igorantun.com/chat) " [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/IgorAntun/node-chat?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
44

55
This is a node.js chat application powered by SockJS and Express that provides the main functions you'd expect from a chat, such as emojis, private messages, an admin system, etc.
66

lib/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ module.exports = {
2020
if(clients[client].role > 1 && (data.info === 'connection' || data.info === 'disconnection')) {
2121
data.user.ip = clients[client].ip;
2222
} else if(data.user) {
23-
data.user.ip = null;
23+
delete data.user.ip;
2424
}
2525

2626
clients[client].con.write(JSON.stringify(data));

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "node-chat",
3-
"version": "0.26.3",
3+
"version": "0.26.7",
44
"private": true,
55
"scripts": {
66
"start": "node app.js"

public/js/chat.js

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -441,15 +441,32 @@ function updateStyle() {
441441
$(document).ready(function() {
442442
$('#user').bind('click', function() {
443443
var content = '';
444+
var userip = '';
444445
var admin;
445446

446447
for(var i in clients) {
447448
if(clients[i] != undefined) {
448-
if(clients[i].role == 0) admin = '</li>'
449-
if(clients[i].role == 1) admin = ' - <b>Helper</b></li>';
450-
if(clients[i].role == 2) admin = ' - <b>Moderator</b></li>';
451-
if(clients[i].role == 3) admin = ' - <b>Administrator</b></li>';
452-
content += '<li><b>ID:</b> ' + clients[i].id + ' - <b>Name:</b> ' + clients[i].un + admin;
449+
if(clients[i].ip) {
450+
userip = '(' + clients[i].ip + ')';
451+
}
452+
453+
if(clients[i].role === 0) {
454+
admin = '</li>';
455+
}
456+
457+
if(clients[i].role === 1) {
458+
admin = ' - <b>Helper</b></li>';
459+
}
460+
461+
if(clients[i].role === 2) {
462+
admin = ' - <b>Moderator</b></li>';
463+
}
464+
465+
if(clients[i].role === 3) {
466+
admin = ' - <b>Administrator</b></li>';
467+
}
468+
469+
content += '<li>' + '<b>#' + clients[i].id + '</b> ' + userip + ' - ' + clients[i].un + admin;
453470
}
454471
}
455472

0 commit comments

Comments
 (0)