diff options
author | Jesús Espino <jespinog@gmail.com> | 2018-04-18 22:46:10 +0200 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2018-04-18 13:46:10 -0700 |
commit | 0910eae31de8ed7b409654515dbd11f5c86dbf71 (patch) | |
tree | 3d5fb47842693cd2ea1a357994c85d04902773a7 /model/client4.go | |
parent | b13a228b0451098ea32933a36fe64566e366583d (diff) | |
download | chat-0910eae31de8ed7b409654515dbd11f5c86dbf71.tar.gz chat-0910eae31de8ed7b409654515dbd11f5c86dbf71.tar.bz2 chat-0910eae31de8ed7b409654515dbd11f5c86dbf71.zip |
MM-9779: Incorporate a Token into the invitations system (#8604)
* Incorporate a Token into the invitations system
* Adding unit tests
* Fixing some api4 client tests
* Removing unnecesary hash validation
* Change the Hash concept on invitations with tokenId
* Not send invitation if it wasn't able to create the Token
* Fixing some naming problems
* Changing the hash query params received from the client side
* Removed unneded data param in the token usage
Diffstat (limited to 'model/client4.go')
-rw-r--r-- | model/client4.go | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/model/client4.go b/model/client4.go index f1feb1bfe..870e440e8 100644 --- a/model/client4.go +++ b/model/client4.go @@ -530,13 +530,13 @@ func (c *Client4) CreateUser(user *User) (*User, *Response) { } } -// CreateUserWithHash creates a user in the system based on the provided user struct and hash created. -func (c *Client4) CreateUserWithHash(user *User, hash, data string) (*User, *Response) { +// CreateUserWithToken creates a user in the system based on the provided tokenId. +func (c *Client4) CreateUserWithToken(user *User, tokenId string) (*User, *Response) { var query string - if hash != "" && data != "" { - query = fmt.Sprintf("?d=%v&h=%v", url.QueryEscape(data), hash) + if tokenId != "" { + query = fmt.Sprintf("?t=%v", tokenId) } else { - err := NewAppError("MissingHashOrData", "api.user.create_user.missing_hash_or_data.app_error", nil, "", http.StatusBadRequest) + err := NewAppError("MissingHashOrData", "api.user.create_user.missing_token.app_error", nil, "", http.StatusBadRequest) return nil, &Response{StatusCode: err.StatusCode, Error: err} } if r, err := c.DoApiPost(c.GetUsersRoute()+query, user.ToJson()); err != nil { @@ -1340,16 +1340,16 @@ func (c *Client4) AddTeamMember(teamId, userId string) (*TeamMember, *Response) } // AddTeamMemberFromInvite adds a user to a team and return a team member using an invite id -// or an invite hash/data pair. -func (c *Client4) AddTeamMemberFromInvite(hash, dataToHash, inviteId string) (*TeamMember, *Response) { +// or an invite token/data pair. +func (c *Client4) AddTeamMemberFromInvite(token, inviteId string) (*TeamMember, *Response) { var query string if inviteId != "" { query += fmt.Sprintf("?invite_id=%v", inviteId) } - if hash != "" && dataToHash != "" { - query += fmt.Sprintf("?hash=%v&data=%v", hash, dataToHash) + if token != "" { + query += fmt.Sprintf("?token=%v", token) } if r, err := c.DoApiPost(c.GetTeamsRoute()+"/members/invite"+query, ""); err != nil { |