редактирование сообщения авторизации
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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) {}
|
||||
|
||||
Reference in New Issue
Block a user