Fix setting profile image for other users (#7306)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
e3b145236d
Коммит
b37e17c032
@@ -267,7 +267,7 @@ func setProfileImage(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
imageData := imageArray[0]
|
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
|
c.Err = err
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ import (
|
|||||||
"github.com/mattermost/platform/app"
|
"github.com/mattermost/platform/app"
|
||||||
"github.com/mattermost/platform/model"
|
"github.com/mattermost/platform/model"
|
||||||
"github.com/mattermost/platform/utils"
|
"github.com/mattermost/platform/utils"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestCreateUser(t *testing.T) {
|
func TestCreateUser(t *testing.T) {
|
||||||
@@ -2040,9 +2042,16 @@ func TestSetProfileImage(t *testing.T) {
|
|||||||
t.Fatal("Should have failed either forbidden or unauthorized")
|
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)
|
_, resp = th.SystemAdminClient.SetProfileImage(user.Id, data)
|
||||||
CheckNoError(t, resp)
|
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"}
|
info := &model.FileInfo{Path: "users/" + user.Id + "/profile.png"}
|
||||||
if err := cleanupTestFile(info); err != nil {
|
if err := cleanupTestFile(info); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user