Fix setting profile image for other users (#7306)

Этот коммит содержится в:
Joram Wilander
2017-08-31 08:57:35 -04:00
коммит произвёл GitHub
родитель e3b145236d
Коммит b37e17c032
2 изменённых файлов: 10 добавлений и 1 удалений

Просмотреть файл

@@ -267,7 +267,7 @@ func setProfileImage(c *Context, w http.ResponseWriter, r *http.Request) {
imageData := imageArray[0]
if err := app.SetProfileImage(c.Session.UserId, imageData); err != nil {
if err := app.SetProfileImage(c.Params.UserId, imageData); err != nil {
c.Err = err
return
}

Просмотреть файл

@@ -14,6 +14,8 @@ import (
"github.com/mattermost/platform/app"
"github.com/mattermost/platform/model"
"github.com/mattermost/platform/utils"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestCreateUser(t *testing.T) {
@@ -2040,9 +2042,16 @@ func TestSetProfileImage(t *testing.T) {
t.Fatal("Should have failed either forbidden or unauthorized")
}
buser, err := app.GetUser(user.Id)
require.Nil(t, err)
_, resp = th.SystemAdminClient.SetProfileImage(user.Id, data)
CheckNoError(t, resp)
ruser, err := app.GetUser(user.Id)
require.Nil(t, err)
assert.True(t, buser.LastPictureUpdate < ruser.LastPictureUpdate, "Picture should have updated for user")
info := &model.FileInfo{Path: "users/" + user.Id + "/profile.png"}
if err := cleanupTestFile(info); err != nil {
t.Fatal(err)