mirror of
https://github.com/m1k1o/neko.git
synced 2025-05-15 10:07:40 +02:00
refactor authentication code.
This commit is contained in:
parent
bc961c5170
commit
c4d67d416e
3 changed files with 18 additions and 29 deletions
|
@ -22,7 +22,7 @@ type MessageHandler struct {
|
|||
locked map[string]string
|
||||
}
|
||||
|
||||
func (h *MessageHandler) Connected(admin bool, socket *WebSocket) (bool, string, error) {
|
||||
func (h *MessageHandler) Connected(admin bool, socket *WebSocket) (bool, string) {
|
||||
address := socket.Address()
|
||||
if address == "" {
|
||||
h.logger.Debug().Msg("no remote address")
|
||||
|
@ -30,17 +30,17 @@ func (h *MessageHandler) Connected(admin bool, socket *WebSocket) (bool, string,
|
|||
ok, banned := h.banned[address]
|
||||
if ok && banned {
|
||||
h.logger.Debug().Str("address", address).Msg("banned")
|
||||
return false, "banned", nil
|
||||
return false, "banned"
|
||||
}
|
||||
}
|
||||
|
||||
_, ok := h.locked["login"]
|
||||
if ok && !admin {
|
||||
h.logger.Debug().Msg("server locked")
|
||||
return false, "locked", nil
|
||||
return false, "locked"
|
||||
}
|
||||
|
||||
return true, "", nil
|
||||
return true, ""
|
||||
}
|
||||
|
||||
func (h *MessageHandler) Disconnected(id string) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue