Skip to content

Commit

Permalink
улучшения безопасности
Browse files Browse the repository at this point in the history
  • Loading branch information
xoticdsign committed Jan 1, 2025
1 parent 1e229af commit f221eb4
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion internal/bot/handlers/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ func (d *Dependencies) AdminPanel(c telebot.Context) error {
return telebot.ErrBadContext
}

_, ok = c.Get("admin").(string)
if !ok {
c.Delete()

return c.Send(models.FailedGlobalUnsupportedCmd, models.ReplyReturnToMenuWithSend)
}

if c.Callback() != nil {
data = c.Callback().Data
}
Expand Down Expand Up @@ -70,9 +77,16 @@ func (d *Dependencies) AdminPanel(c telebot.Context) error {

// Админский хендлер. Отправляет количество уникальных пользователей и сокращенных ссылок.
func (d *Dependencies) AdminUsersAndShorties(c telebot.Context) error {
_, ok := c.Get("admin").(string)
if !ok {
c.Delete()

return c.Send(models.FailedGlobalUnsupportedCmd, models.ReplyReturnToMenuWithSend)
}

usersCount, shortiesCount, err := d.DB.UsersAndShorties()
if err != nil {
return c.EditOrSend(models.MsgAdminSuccess+"\n"+err.Error(), models.ReplyReturnToAdminPanel)
return c.EditOrSend(models.MsgAdminSuccess+"\n\n"+err.Error(), models.ReplyReturnToAdminPanel)
}
result := []string{
models.MsgAdminSuccess,
Expand Down

0 comments on commit f221eb4

Please sign in to comment.