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 удалений

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

@@ -725,6 +725,12 @@ func (api *PluginAPI) CreateBot(bot *model.Bot) (*model.Bot, *model.AppError) {
if bot.OwnerId == "" {
bot.OwnerId = api.id
}
// Bots cannot be owners of other bots
if user, err := api.app.GetUser(bot.OwnerId); err == nil {
if user.IsBot {
return nil, model.NewAppError("CreateBot", "plugin_api.bot_cant_create_bot", nil, "", http.StatusBadRequest)
}
}
return api.app.CreateBot(bot)
}