diff options
author | Chris Duarte <csduarte@users.noreply.github.com> | 2018-01-04 09:45:59 -0800 |
---|---|---|
committer | Joram Wilander <jwawilander@gmail.com> | 2018-01-04 12:45:59 -0500 |
commit | 5e78d7fe12a39e28a6520b023b0df0fc66a826d5 (patch) | |
tree | d4eacf4c02f5300917093efc13e73f9761c7756c /model/client4.go | |
parent | e5dad3cf681fb038ce5dd3dcf7b5468d59b8ea8e (diff) | |
download | chat-5e78d7fe12a39e28a6520b023b0df0fc66a826d5.tar.gz chat-5e78d7fe12a39e28a6520b023b0df0fc66a826d5.tar.bz2 chat-5e78d7fe12a39e28a6520b023b0df0fc66a826d5.zip |
Add admin update endpoint that can update authservice and authdata (#7842)
* add admin update endpoint that can upate authservice and authdata
* Control only SystemAdmin access
* Refactored AdminUpdate endpoint to only be able to update AuthData, AuthService and Password by User.Id
* Refactor to move `PUT /api/v4/users/{user_id}/auth`. Created a struct to hold UserAuth info.
Diffstat (limited to 'model/client4.go')
-rw-r--r-- | model/client4.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/model/client4.go b/model/client4.go index d37fb3b0f..e84a23e5f 100644 --- a/model/client4.go +++ b/model/client4.go @@ -766,6 +766,16 @@ func (c *Client4) PatchUser(userId string, patch *UserPatch) (*User, *Response) } } +// UpdateUserAuth updates a user AuthData (uthData, authService and password) in the system. +func (c *Client4) UpdateUserAuth(userId string, userAuth *UserAuth) (*UserAuth, *Response) { + if r, err := c.DoApiPut(c.GetUserRoute(userId)+"/auth", userAuth.ToJson()); err != nil { + return nil, BuildErrorResponse(r, err) + } else { + defer closeBody(r) + return UserAuthFromJson(r.Body), BuildResponse(r) + } +} + // UpdateUserMfa activates multi-factor authentication for a user if activate // is true and a valid code is provided. If activate is false, then code is not // required and multi-factor authentication is disabled for the user. |