Browse Source
Remove external grab into the object
This change removes server object interacting with an internal variable
from the user object creation and reduces the amount of code from 3 to 1
line. This also simplifies future testing.
test/user
Sheogorath
5 years ago
No known key found for this signature in database
GPG Key ID: 1F05CC3635CDDFFD
2 changed files with
3 additions and
6 deletions
src/server.js
src/user.js
@ -23,10 +23,7 @@ server.create = function create(config = {}) {
let userlist = { }
let userlist = { }
let channellist = { }
let channellist = { }
let server = net . createServer ( ( socket ) => {
let server = net . createServer ( ( socket ) => {
const user = new User ( socket )
if ( ! config . password ) {
user . authenticated = true
}
const user = new User ( socket , ! config . password )
socket . on ( 'data' , function ( data ) {
socket . on ( 'data' , function ( data ) {
data . toString ( "ascii" ) . split ( "\r\n" ) . forEach ( function ( commandline ) {
data . toString ( "ascii" ) . split ( "\r\n" ) . forEach ( function ( commandline ) {
if ( commandline == "" ) {
if ( commandline == "" ) {
@ -1,6 +1,6 @@
function User ( socket ) {
function User ( socket , authenticatedDefault ) {
this . registered = false
this . registered = false
this . authenticated = false
this . authenticated = authenticatedDefault
this . nickname = ""
this . nickname = ""
this . connection = socket
this . connection = socket
this . realname = ""
this . realname = ""