diff --git a/index.html b/index.html index 9218983..30c1a22 100644 --- a/index.html +++ b/index.html @@ -16,6 +16,13 @@ + + +
diff --git a/src/components/auth/LoginPage.vue b/src/components/auth/LoginPage.vue index bfe8f7b..dc35a68 100644 --- a/src/components/auth/LoginPage.vue +++ b/src/components/auth/LoginPage.vue @@ -17,7 +17,29 @@ const password = ref('') const userStore = useUserStore() +const telegramBtn = ref(null) + +function onTelegramAuth(user) { + console.log('TG login success', user) + alert(`Logged in as ${user.first_name} (@${user.username})`) + // 👉 здесь отправляешь user.auth_data на бэк для проверки Telegram-sign +} + onMounted(() => { + + // передаём функцию глобально чтобы виджет её увидел + window.onTelegramAuth = onTelegramAuth + + const script = document.createElement("script") + script.src = "https://telegram.org/js/telegram-widget.js?22" + script.setAttribute("data-telegram-login", "luminicspacebot") // ← твой bot + script.setAttribute("data-size", "large") + script.setAttribute("data-onauth", "onTelegramAuth(user)") + script.setAttribute("data-request-access", "write") + script.async = true + + telegramBtn.value.appendChild(script) + // сообщаем Telegram WebApp, что UI готов if (tgApp.initData) { tgData.value = tgApp.initDataUnsafe @@ -33,6 +55,9 @@ onMounted(() => {