mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
interact: add more error check for /auth command
This commit is contained in:
parent
8e557b3da2
commit
6c7b6c6def
|
@ -90,6 +90,9 @@ func (it *AuthInteract) Commands(interact *Interact) {
|
|||
|
||||
case AuthModeOTP:
|
||||
reply.Message("Enter your one-time password")
|
||||
|
||||
default:
|
||||
log.Warn("unexpected auth mode: %s", it.Mode)
|
||||
}
|
||||
return nil
|
||||
}).NamedNext(StateAuthenticated, func(code string, reply Reply, session Session) error {
|
||||
|
@ -101,6 +104,7 @@ func (it *AuthInteract) Commands(interact *Interact) {
|
|||
session.SetAuthorized()
|
||||
return nil
|
||||
}
|
||||
reply.Message("Incorrect authentication token")
|
||||
|
||||
case AuthModeOTP:
|
||||
if totp.Validate(code, it.OneTimePasswordKey.Secret()) {
|
||||
|
@ -109,9 +113,12 @@ func (it *AuthInteract) Commands(interact *Interact) {
|
|||
session.SetAuthorized()
|
||||
return nil
|
||||
}
|
||||
reply.Message("Incorrect one-time pass code")
|
||||
|
||||
default:
|
||||
log.Warn("unexpected auth mode: %s", it.Mode)
|
||||
}
|
||||
|
||||
reply.Message("Incorrect authentication code")
|
||||
return ErrAuthenticationFailed
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user