How to use the @logux/core.LoguxError function in @logux/core

To help you get started, we’ve selected a few @logux/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github logux / server / server-client.js View on Github external
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', () => {
github logux / server / server-client.js View on Github external
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)