- Telegram bot (long polling) - /api/v1/auth/telegram (validate initData, auto-create user) - /api/v1/auth/consents (record acceptances) - users.telegram_id column, GetByTelegramID/CreateWithTelegramID - ValidateInitData (HMAC-SHA256 with WebAppData secret)
6 lines
294 B
SQL
6 lines
294 B
SQL
-- Telegram ID
|
|
ALTER TABLE users ADD COLUMN IF NOT EXISTS telegram_id BIGINT UNIQUE;
|
|
CREATE INDEX IF NOT EXISTS idx_users_telegram ON users(telegram_id) WHERE telegram_id IS NOT NULL;
|
|
|
|
-- username в Telegram (опционально)
|
|
ALTER TABLE users ADD COLUMN IF NOT EXISTS tg_username TEXT; |