PLT-5355: Fix permalink to private/direct channels. (#5574)

Appropriate permission checks depend on the type of channel this
permalink links to.
Этот коммит содержится в:
George Goldberg
2017-03-02 14:08:00 +00:00
коммит произвёл Corey Hulen
родитель 991925b7ee
Коммит f4aebed220
2 изменённых файлов: 55 добавлений и 3 удалений

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

@@ -264,11 +264,26 @@ func getPermalinkTmp(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
if !app.HasPermissionToChannelByPost(c.Session.UserId, postId, model.PERMISSION_JOIN_PUBLIC_CHANNELS) {
c.SetPermissionError(model.PERMISSION_JOIN_PUBLIC_CHANNELS)
var channel *model.Channel
if result := <-app.Srv.Store.Channel().GetForPost(postId); result.Err == nil {
channel = result.Data.(*model.Channel)
} else {
c.SetInvalidParam("getPermalinkTmp", "postId")
return
}
if channel.Type == model.CHANNEL_OPEN {
if !app.HasPermissionToChannelByPost(c.Session.UserId, postId, model.PERMISSION_JOIN_PUBLIC_CHANNELS) {
c.SetPermissionError(model.PERMISSION_JOIN_PUBLIC_CHANNELS)
return
}
} else {
if !app.HasPermissionToChannelByPost(c.Session.UserId, postId, model.PERMISSION_READ_CHANNEL) {
c.SetPermissionError(model.PERMISSION_READ_CHANNEL)
return
}
}
if list, err := app.GetPermalinkPost(postId, c.Session.UserId); err != nil {
c.Err = err
return