Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="ru">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Авторизация</title>
- <script src="https://cdn.tailwindcss.com"></script>
- <script>
- tailwind.config = {
- darkMode: 'class',
- theme: {
- extend: {
- colors: {
- telegram: {
- light: '#0088cc',
- DEFAULT: '#0088cc',
- dark: '#006699',
- }
- },
- transitionProperty: {
- 'height': 'height',
- 'spacing': 'margin, padding',
- },
- keyframes: {
- 'fade-in-down': {
- '0%': {
- opacity: '0',
- transform: 'translateY(-10px)'
- },
- '100%': {
- opacity: '1',
- transform: 'translateY(0)'
- },
- },
- 'fade-in': {
- '0%': { opacity: '0' },
- '100%': { opacity: '1' },
- },
- 'fade-out': {
- '0%': { opacity: '1' },
- '100%': { opacity: '0' },
- }
- },
- animation: {
- 'fade-in-down': 'fade-in-down 0.3s ease-out',
- 'fade-in': 'fade-in 0.3s ease-out',
- 'fade-out': 'fade-out 0.3s ease-out'
- }
- }
- }
- }
- </script>
- <style type="text/css">
- .telegram-btn {
- background: linear-gradient(135deg, #0088cc, #00a2e8);
- transition: all 0.3s ease;
- }
- .telegram-btn:hover {
- background: linear-gradient(135deg, #0077b3, #0088cc);
- transform: translateY(-2px);
- box-shadow: 0 4px 12px rgba(0, 136, 204, 0.3);
- }
- .telegram-btn:active {
- transform: translateY(0);
- }
- .telegram-icon {
- filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.1));
- }
- .auth-container {
- background: linear-gradient(145deg, #f9fafb, #f3f4f6);
- }
- .dark .auth-container {
- background: linear-gradient(145deg, #1f2937, #111827);
- }
- /* Скрываем стандартный виджет */
- #telegram-login-container iframe {
- display: none !important;
- }
- </style>
- </head>
- <body class="bg-gray-100 dark:bg-gray-900 transition-colors duration-200 min-h-screen flex items-center justify-center p-4">
- <div class="auth-container max-w-md w-full rounded-2xl shadow-xl overflow-hidden transition-all duration-300">
- <div class="bg-white dark:bg-gray-800 p-6 text-center border-b border-gray-200 dark:border-gray-700">
- <div class="flex justify-center mb-4">
- <svg xmlns="http://www.w3.org/2000/svg" class="h-12 w-12 text-blue-500" viewBox="0 0 24 24" fill="currentColor">
- <path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm4.64 6.8c-.15 1.58-.8 5.42-1.13 7.19-.14.75-.42 1-.68 1.03-.58.05-1.02-.38-1.58-.75-.88-.58-1.38-.94-2.23-1.5-.99-.65-.35-1.01.22-1.59.15-.15 2.71-2.48 2.76-2.69.03-.08.05-.18-.05-.26-.1-.08-.25-.05-.36-.03-.15.05-2.57 1.66-7.27 4.88-.7.46-1.34.69-1.91.68-.6-.01-1.75-.34-2.6-.62-1.05-.35-1.89-.54-1.82-1.14.03-.3.4-.61 1.1-.94 4.48-2.01 7.49-3.36 11.15-5.25.58-.3 1.11-.44 1.6-.45.38-.01 1.22.08 1.79.34.53.24.53.77.49.9z"/>
- </svg>
- </div>
- <h1 class="text-2xl font-bold text-gray-800 dark:text-gray-200">Модерация тем форума</h1>
- <p class="text-gray-600 dark:text-gray-400 mt-2">Для доступа требуется авторизация</p>
- </div>
- <div class="bg-white dark:bg-gray-800 p-6 sm:p-8">
- <div class="space-y-6">
- <div id="telegram-login-container">
- <!-- Кастомная кнопка авторизации -->
- <button id="custom-telegram-login" class="telegram-btn w-full flex items-center justify-center px-6 py-3 rounded-lg text-white font-medium text-lg shadow-md transition-all duration-300">
- <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 mr-2 telegram-icon" viewBox="0 0 24 24" fill="currentColor">
- <path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm4.64 6.8c-.15 1.58-.8 5.42-1.13 7.19-.14.75-.42 1-.68 1.03-.58.05-1.02-.38-1.58-.75-.88-.58-1.38-.94-2.23-1.5-.99-.65-.35-1.01.22-1.59.15-.15 2.71-2.48 2.76-2.69.03-.08.05-.18-.05-.26-.1-.08-.25-.05-.36-.03-.15.05-2.57 1.66-7.27 4.88-.7.46-1.34.69-1.91.68-.6-.01-1.75-.34-2.6-.62-1.05-.35-1.89-.54-1.82-1.14.03-.3.4-.61 1.1-.94 4.48-2.01 7.49-3.36 11.15-5.25.58-.3 1.11-.44 1.6-.45.38-.01 1.22.08 1.79.34.53.24.53.77.49.9z"/>
- </svg>
- Войти через Telegram
- </button>
- </div>
- </div>
- </div>
- </div>
- <script>
- // Проверяем, авторизован ли пользователь
- function checkAuth() {
- const token = localStorage.getItem('jwt_token');
- if (token) {
- // Если есть токен, проверяем его валидность
- fetch('/api/validate-token', {
- method: 'GET',
- headers: {
- 'Authorization': `Bearer ${token}`
- }
- })
- .then(response => {
- if (response.ok) {
- // Токен валиден, перенаправляем на главную
- window.location.href = '/';
- } else {
- // Токен невалиден, удаляем его
- localStorage.removeItem('jwt_token');
- }
- })
- .catch(() => {
- localStorage.removeItem('jwt_token');
- });
- }
- }
- function initTelegramAuth() {
- // First, check if Telegram widget script is already loaded
- if (window.Telegram && Telegram.Login) {
- setupTelegramAuth();
- } else {
- // Load the script if not present
- const script = document.createElement('script');
- script.src = 'https://telegram.org/js/telegram-widget.js?22';
- script.async = true;
- script.onload = setupTelegramAuth;
- document.body.appendChild(script);
- }
- }
- function setupTelegramAuth() {
- document.getElementById('custom-telegram-login').addEventListener('click', function() {
- Telegram.Login.auth(
- {
- bot_id: '5932509206', // Make sure this is your actual bot username
- request_access: 'write',
- lang: 'ru' // Optional: set language
- },
- function(user) {
- if (user) {
- // User authorized, send data to server
- fetch('https://music.esbot.ru/auth', {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- },
- body: JSON.stringify(user)
- })
- .then(response => response.json())
- .then(data => {
- if (data.token) {
- localStorage.setItem('jwt_token', data.token);
- window.location.href = '/';
- }
- })
- .catch(error => {
- console.error('Auth error:', error);
- });
- }
- }
- );
- });
- }
- // Проверяем авторизацию при загрузке страницы
- document.addEventListener('DOMContentLoaded', function() {
- checkAuth();
- initTelegramAuth();
- });
- </script>
- </body>
- </html>
- Теперь такая ошибка:
- Auth error: SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON
- Но get запрос отдал это
- {
- "user": {
- "id": 952766753,
- "first_name": "kus",
- "username": "kusehsup",
- "photo_url": "https:\/\/t.me\/i\/userpic\/320\/tPk8blL3u6-Yo_rviyVmeTrAj-9Vtw5UUEHg7mqTwWw.jpg",
- "auth_date": 1749554240,
- "hash": "ab6635a8981a1cf78db82433a0c8e7bda28e6947be28c38bdd12d9b9d80a91bc"
- },
- "html": "<button class=\"btn tgme_widget_login_button\" onclick=\"return TWidgetLogin.auth();\"><i class=\"tgme_widget_login_button_icon\"><\/i>Войти как <span dir=\"auto\">kus<\/span><\/button><i class=\"tgme_widget_login_user_photo bgcolor1\" data-content=\"k\" onclick=\"return TWidgetLogin.auth();\"><img src=\"https:\/\/cdn4.telesco.pe\/file\/DnbL7uje0SJsclj3LqBc-3EGB2ot0yZ77_C57PaOy5pJ9eIiRk75ZqOqD-e2KbsYTQqFTSp8IDM2pjEm985rziX-WtljOnrhOVxv32mb0xBBVR3YkMfk5I5OgUfwEjGnk3kVDa9Rz67aUvn6Gnf4DWuh7CproymKQPiLt-tLG97UU-Slf-2MISkyItURRD3GdWapmKRcAlLDFr5C5N3DHSChT1OMCN2kUB8gey1LtqJfcHYoEt7dc_LnDP6AZBb_TZhNnB1XmRituYbNz6vsN_ICrRXWt4phM5laMdyLdUU0JZqvdlw9Q-7uUY2aJlJWATjZHL2qacKgm-UAy_6Y_g.jpg\"><\/i>",
- "origin": "https:\/\/music.esbot.ru"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement