Skip to content

Commit

Permalink
Merge pull request #388 from Scalingo/story/642/new-api-endpoint-to-h…
Browse files Browse the repository at this point in the history
…andle-password-reset

Story/642/new api endpoint to handle password reset
  • Loading branch information
sc-zenokerr authored Jul 5, 2024
2 parents 4d08aee + da64988 commit f01a25c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## To Be Released

* feat(apps): add the `private_network_ids` field to the model
* feat(database/users): add the `DatabaseUserResetPassword` method

## 7.0.0

Expand Down
16 changes: 16 additions & 0 deletions databases.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,3 +319,19 @@ func (c *Client) DatabaseListUsers(ctx context.Context, app, addonID string) ([]
func (c *Client) DatabaseDeleteUser(ctx context.Context, app, addonID, userName string) error {
return c.DBAPI(app, addonID).SubresourceDelete(ctx, "databases", addonID, "users", userName)
}

// DatabaseUserResetPassword resets the password for a user for given database addon
func (c *Client) DatabaseUserResetPassword(ctx context.Context, app, addonID, username string) (DatabaseUser, error) {
res := DatabaseUserResponse{}
req := &httpclient.APIRequest{
Method: "POST",
Endpoint: "/databases/" + addonID + "/users/" + username + "/reset_password",
Expected: httpclient.Statuses{http.StatusOK},
}
err := c.DBAPI(app, addonID).DoRequest(ctx, req, &res)
if err != nil {
return DatabaseUser{}, err
}

return res.DatabaseUser, nil
}

0 comments on commit f01a25c

Please sign in to comment.