Skip to content

Commit

Permalink
Merge pull request #995 from slack-go/fix/issues992
Browse files Browse the repository at this point in the history
fix: Don't add API token as a query string in `users.setPhoto`
  • Loading branch information
kanata2 committed Nov 6, 2021
2 parents 1f5f0ca + 227a96c commit 979adb8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 1 addition & 3 deletions users.go
Expand Up @@ -469,9 +469,7 @@ func (api *Client) SetUserPhoto(image string, params UserSetPhotoParams) error {
// SetUserPhotoContext changes the currently authenticated user's profile image using a custom context
func (api *Client) SetUserPhotoContext(ctx context.Context, image string, params UserSetPhotoParams) (err error) {
response := &SlackResponse{}
values := url.Values{
"token": {api.token},
}
values := url.Values{}
if params.CropX != DEFAULT_USER_PHOTO_CROP_X {
values.Add("crop_x", strconv.Itoa(params.CropX))
}
Expand Down
4 changes: 3 additions & 1 deletion users_test.go
Expand Up @@ -13,6 +13,7 @@ import (
"os"
"reflect"
"strconv"
"strings"
"sync/atomic"
"testing"
)
Expand Down Expand Up @@ -509,7 +510,8 @@ func setUserPhotoHandler(wantBytes []byte, wantParams UserSetPhotoParams) http.H
}

// Test for expected token
if v := r.Form.Get("token"); v != validToken {
actualToken := strings.Split(r.Header.Get("Authorization"), "Bearer ")[1]
if actualToken != validToken {
httpTestErrReply(w, true, fmt.Sprintf("expected multipart form value token=%v", validToken))
return
}
Expand Down

0 comments on commit 979adb8

Please sign in to comment.