Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.node.on('connect', () => {
if (!this.isSubprotocol(this.app.options.supports)) {
throw new LoguxError('wrong-subprotocol', {
supported: this.app.options.supports,
used: this.node.remoteSubprotocol
})
}
})
this.node.on('state', () => {
async auth (credentials, nodeId) {
this.nodeId = nodeId
let data = parseNodeId(nodeId)
this.clientId = data.clientId
this.userId = data.userId
if (nodeId === 'server' || data.userId === 'server') {
this.app.reporter('unauthenticated', reportDetails(this))
return false
}
let start = Date.now()
let result = await this.app.authenticator(this.userId, credentials, this)
if (this.app.isBruteforce(this.remoteAddress)) {
throw new LoguxError('bruteforce')
}
if (result) {
let zombie = this.app.clientIds[this.clientId]
if (zombie) {
zombie.zombie = true
this.app.reporter('zombie', { nodeId: zombie.nodeId })
zombie.destroy()
}
this.app.clientIds[this.clientId] = this
this.app.nodeIds[this.nodeId] = this
if (this.userId) {
if (!this.app.userIds[this.userId]) {
this.app.userIds[this.userId] = []
}
this.app.userIds[this.userId].push(this)