Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix login with 2fa #331

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions pkg/appstore/appstore_login.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,15 @@

func (t *appstore) login(email, password, authCode, guid string) (Account, error) {
redirect := ""
var err error

Check failure on line 66 in pkg/appstore/appstore_login.go

View workflow job for this annotation

GitHub Actions / Lint

declarations should never be cuddled (wsl)
retry := true

Check failure on line 67 in pkg/appstore/appstore_login.go

View workflow job for this annotation

GitHub Actions / Lint

assignments should only be cuddled with other assignments (wsl)
var res http.Result[loginResult]

Check failure on line 68 in pkg/appstore/appstore_login.go

View workflow job for this annotation

GitHub Actions / Lint

declarations should never be cuddled (wsl)

for attempt := 1; retry && attempt <= 4; attempt++ {
ac := authCode
if attempt == 1 {
ac = ""
}
request := t.loginRequest(email, password, ac, guid, attempt)
request := t.loginRequest(email, password, authCode, guid, attempt)
request.URL, redirect = util.IfEmpty(redirect, request.URL), ""

Check failure on line 72 in pkg/appstore/appstore_login.go

View workflow job for this annotation

GitHub Actions / Lint

ineffectual assignment to redirect (ineffassign)
res, err = t.loginClient.Send(request)
if err != nil {

Check failure on line 74 in pkg/appstore/appstore_login.go

View workflow job for this annotation

GitHub Actions / Lint

only one cuddle assignment allowed before if statement (wsl)
return Account{}, fmt.Errorf("request failed: %w", err)
}

Expand Down Expand Up @@ -116,8 +112,8 @@
return acc, nil
}

func (t *appstore) parseLoginResponse(res *http.Result[loginResult], attempt int, authCode string) (retry bool, redirect string, err error) {

Check failure on line 115 in pkg/appstore/appstore_login.go

View workflow job for this annotation

GitHub Actions / Lint

named return "retry" with type "bool" found (nonamedreturns)
if res.StatusCode == 302 {

Check failure on line 116 in pkg/appstore/appstore_login.go

View workflow job for this annotation

GitHub Actions / Lint

"302" can be replaced by http.StatusFound (usestdlibvars)
if redirect, err = res.GetHeader("location"); err != nil {
err = fmt.Errorf("failed to retrieve redirect location: %w", err)
} else {
Expand All @@ -136,7 +132,7 @@
} else if res.StatusCode != 200 || res.Data.PasswordToken == "" || res.Data.DirectoryServicesID == "" {
err = NewErrorWithMetadata(errors.New("something went wrong"), res)
}
return

Check failure on line 135 in pkg/appstore/appstore_login.go

View workflow job for this annotation

GitHub Actions / Lint

return statements should not be cuddled if block has more than two lines (wsl)
}

func (t *appstore) loginRequest(email, password, authCode, guid string, attempt int) http.Request {
Expand Down
Loading