@@ -20,7 +20,7 @@ const (
2020)
2121
2222func (um * UserManager ) KeystoreStatus (scope , id string ) (* keystore.Status , error ) {
23- userKeystorePath := UsersPath + "/" + scope + "/" + id + ".ks.json"
23+ userKeystorePath := generateUserPath ( scope , id ) + ".ks.json"
2424
2525 response , err := um .instance .http .Request ().Get (userKeystorePath )
2626
@@ -48,7 +48,7 @@ func (um *UserManager) KeystoreCreate(scope, id, keystorePassword string) (bool,
4848 return false , statusError
4949 }
5050
51- if statusResponse .Created == true {
51+ if statusResponse .Created {
5252 return false , nil
5353 }
5454
@@ -58,7 +58,7 @@ func (um *UserManager) KeystoreCreate(scope, id, keystorePassword string) (bool,
5858 ":operation" : "createStore" ,
5959 }
6060
61- userKeystoreCreatePath := UsersPath + "/" + scope + "/" + id + ".ks.html"
61+ userKeystoreCreatePath := generateUserPath ( scope , id ) + ".ks.html"
6262 postResponse , postError := um .instance .http .Request ().SetQueryParams (pathParams ).Post (userKeystoreCreatePath )
6363
6464 if postError != nil {
@@ -73,7 +73,7 @@ func (um *UserManager) KeystoreCreate(scope, id, keystorePassword string) (bool,
7373}
7474
7575func (um * UserManager ) ReadState (scope string , id string ) (* user.Status , error ) {
76- userPath := UsersPath + "/" + scope + "/" + id
76+ userPath := generateUserPath ( scope , id )
7777
7878 response , err := um .instance .http .Request ().Get (userPath + ".json" )
7979
@@ -93,14 +93,14 @@ func (um *UserManager) ReadState(scope string, id string) (*user.Status, error)
9393 return result , nil
9494}
9595
96- func (um * UserManager ) PasswordSet (scope string , id string , password string ) (bool , error ) {
96+ func (um * UserManager ) SetPassword (scope string , id string , password string ) (bool , error ) {
9797 userStatus , err := um .ReadState (scope , id )
9898
9999 if err != nil {
100100 return false , err
101101 }
102102
103- userPath := UsersPath + "/" + scope + "/" + id
103+ userPath := generateUserPath ( scope , id )
104104
105105 passwordCheckResponse , err := um .instance .http .Request ().
106106 SetBasicAuth (userStatus .AuthorizableID , password ).
@@ -128,3 +128,10 @@ func (um *UserManager) PasswordSet(scope string, id string, password string) (bo
128128
129129 return true , nil
130130}
131+
132+ func generateUserPath (scope string , id string ) string {
133+ if scope == "" {
134+ return UsersPath + "/" + id
135+ }
136+ return UsersPath + "/" + scope + "/" + id
137+ }
0 commit comments