редактирование сообщения авторизации

This commit is contained in:
Artem Tsyrulnikov
2026-01-19 19:16:13 +03:00
parent a90c8b7df6
commit 2a4e694ca4
10 changed files with 150 additions and 8 deletions

View File

@@ -106,6 +106,18 @@ func (c *Client) CreateLoginToken(ctx context.Context, telegramID int64) (string
return token, err
}
func (c *Client) AttachLoginTokenMessage(ctx context.Context, token string, messageID int) error {
req := struct {
Token string `json:"token"`
MessageID int `json:"message_id"`
}{
Token: token,
MessageID: messageID,
}
return c.do(ctx, http.MethodPost, "api/v1/internal/auth/login-token/message", req, nil)
}
func (c *Client) GetJWTByTelegramID(
ctx context.Context,
telegramID int64,

View File

@@ -32,7 +32,7 @@ func (s *Login) Enter(b *bot.Bot, mode bot.RenderMode) {
kb := Keyboard(Row(URLButton("Войти на сайт", loginURL)))
_, err = b.SendMessage(fmt.Sprintf(msgHelloLogin, usernameDisplay), b.ChatID, &echotron.MessageOptions{
res, err := b.SendMessage(fmt.Sprintf(msgHelloLogin, usernameDisplay), b.ChatID, &echotron.MessageOptions{
ReplyMarkup: kb,
ParseMode: echotron.HTML,
})
@@ -41,6 +41,12 @@ func (s *Login) Enter(b *bot.Bot, mode bot.RenderMode) {
return
}
if res.Result != nil {
if err := b.Backend.AttachLoginTokenMessage(context.Background(), token, res.Result.ID); err != nil {
log.Err(err).Msg("AttachLoginTokenMessage error")
}
}
b.SetState(&MainMenu{}, bot.NewMessage)
}
func (s *Login) HandleCallback(b *bot.Bot, u *echotron.Update) {}