Browse Source

[Cloudtrust-1617] Get/Update account API

master
harture 6 years ago
committed by GitHub
parent
commit
509d5f3b96
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 15
      users.go

15
users.go

@ -4,6 +4,7 @@ import (
"fmt"
"gopkg.in/h2non/gentleman.v2/plugins/body"
"gopkg.in/h2non/gentleman.v2/plugins/headers"
"gopkg.in/h2non/gentleman.v2/plugins/url"
)
@ -22,6 +23,7 @@ const (
getCredentialsForUserPath = usersAdminExtensionApiPath + "/:id/credentials"
deleteCredentialsForUserPath = getCredentialsForUserPath + "/:credid"
accountPasswordPath = "/auth/realms/master/api/account/realms/:realm/credentials/password"
accountPath = "/auth/realms/master/api/account/realms/:realm/"
)
// GetUsers returns a list of users, filtered according to the query parameters.
@ -145,3 +147,16 @@ func (c *Client) UpdatePassword(accessToken, realm, currentPassword, newPassword
var m = map[string]string{"currentPassword": currentPassword, "newPassword": newPassword, "confirmation": confirmPassword}
return c.post(accessToken, nil, url.Path(accountPasswordPath), url.Param("realm", realm), body.JSON(m))
}
// GetAccount provides the user's information
func (c *Client) GetAccount(accessToken string, realm string) (UserRepresentation, error) {
var resp = UserRepresentation{}
var err = c.get(accessToken, &resp, url.Path(accountPath), url.Param("realm", realm), headers.Set("Accept", "application/json"))
return resp, err
}
// UpdateAccount updates the user's information
func (c *Client) UpdateAccount(accessToken string, realm string, user UserRepresentation) error {
_, err := c.post(accessToken, nil, url.Path(accountPath), url.Param("realm", realm), body.JSON(user))
return err
}

Loading…
Cancel
Save