Skip to content

Commit 65c841c

Browse files
author
Piotr Andruszkiewicz
committed
Refactor UserPasswordSet to simplify password check logic
1 parent 036d2b3 commit 65c841c

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

pkg/user_manager.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package pkg
33
import (
44
"fmt"
55

6-
"github.com/go-resty/resty/v2"
76
"github.com/wttech/aemc/pkg/keystore"
87
"github.com/wttech/aemc/pkg/user"
98
)
@@ -103,18 +102,16 @@ func (um *UserManager) UserPasswordSet(scope string, id string, password string)
103102

104103
userPath := UsersPath + "/" + scope + "/" + id
105104

106-
passwordCheckResponse, passwordCheckError := um.instance.http.Client().
107-
SetRedirectPolicy(resty.NoRedirectPolicy()).
108-
R().
105+
passwordCheckResponse, passwordCheckError := um.instance.http.Request().
109106
SetBasicAuth(userStatus.AuthorizableID, password).
110-
Get(userPath)
107+
Get(userPath + ".json")
111108

112109
if passwordCheckError != nil {
113-
if passwordCheckResponse != nil && !passwordCheckResponse.IsError() {
114-
return false, nil
115-
}
116110
return false, fmt.Errorf("%s > cannot check user password: %w", um.instance.IDColor(), passwordCheckError)
117111
}
112+
if passwordCheckError == nil && passwordCheckResponse != nil && !passwordCheckResponse.IsError() {
113+
return false, nil
114+
}
118115

119116
props := map[string]any{
120117
"rep:password": password,

0 commit comments

Comments
 (0)