From 9c9815544fabb4d9d4c48155eaec3db044ede36d Mon Sep 17 00:00:00 2001 From: ayn2op Date: Tue, 9 Dec 2025 01:25:09 -0500 Subject: [PATCH] fix(login): illogical conditional --- internal/login/form.go | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/internal/login/form.go b/internal/login/form.go index 5cce6ec..7b99931 100644 --- a/internal/login/form.go +++ b/internal/login/form.go @@ -70,22 +70,25 @@ func (f *Form) login() { return } - if resp.MFA && resp.TOTP { - code := f.form.GetFormItem(2).(*tview.InputField).GetText() - if code == "" { - f.onError(errors.New("code required")) - return - } + if resp.MFA { + switch { + case resp.TOTP: + code := f.form.GetFormItem(2).(*tview.InputField).GetText() + if code == "" { + f.onError(errors.New("code required")) + return + } - // Attempt to login using the code. - resp, err = client.TOTP(code, resp.Ticket) - if err != nil { - f.onError(err) + // Attempt to login using the code. + resp, err = client.TOTP(code, resp.Ticket) + if err != nil { + f.onError(err) + return + } + default: + f.onError(errors.New("unsupported mfa type")) return } - } else { - f.onError(errors.New("unsupported mfa type")) - return } if resp.Token == "" {