MM-14722 - Don't let bots create other bot accounts (#10808)

Этот коммит содержится в:
scott lee davis
2019-05-14 13:15:23 -07:00
коммит произвёл Hanzei
родитель 1a4ea94805
Коммит ae951f6449
6 изменённых файлов: 120 добавлений и 0 удалений

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

@@ -36,6 +36,13 @@ func createBot(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
if user, err := c.App.GetUser(c.App.Session.UserId); err == nil {
if user.IsBot {
c.SetPermissionError(model.PERMISSION_CREATE_BOT)
return
}
}
if !*c.App.Config().ServiceSettings.CreateBotAccounts {
c.Err = model.NewAppError("createBot", "api.bot.create_disabled", nil, "", http.StatusForbidden)
return
@@ -195,6 +202,13 @@ func assignBot(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
if user, err := c.App.GetUser(userId); err == nil {
if user.IsBot {
c.SetPermissionError(model.PERMISSION_ASSIGN_BOT)
return
}
}
bot, err := c.App.UpdateBotOwner(botUserId, userId)
if err != nil {
c.Err = err