Advertisement
kusehsup

Untitled

Jun 10th, 2025
430
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 10.24 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="ru">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6.     <title>Авторизация</title>
  7.     <script src="https://cdn.tailwindcss.com"></script>
  8.     <script>
  9.         tailwind.config = {
  10.             darkMode: 'class',
  11.             theme: {
  12.                 extend: {
  13.                     colors: {
  14.                         telegram: {
  15.                             light: '#0088cc',
  16.                             DEFAULT: '#0088cc',
  17.                             dark: '#006699',
  18.                         }
  19.                     },
  20.                     transitionProperty: {
  21.                         'height': 'height',
  22.                         'spacing': 'margin, padding',
  23.                     },
  24.                     keyframes: {
  25.                         'fade-in-down': {
  26.                             '0%': {
  27.                                 opacity: '0',
  28.                                 transform: 'translateY(-10px)'
  29.                             },
  30.                             '100%': {
  31.                                 opacity: '1',
  32.                                 transform: 'translateY(0)'
  33.                             },
  34.                         },
  35.                         'fade-in': {
  36.                             '0%': { opacity: '0' },
  37.                             '100%': { opacity: '1' },
  38.                         },
  39.                         'fade-out': {
  40.                             '0%': { opacity: '1' },
  41.                             '100%': { opacity: '0' },
  42.                         }
  43.                     },
  44.                     animation: {
  45.                         'fade-in-down': 'fade-in-down 0.3s ease-out',
  46.                         'fade-in': 'fade-in 0.3s ease-out',
  47.                         'fade-out': 'fade-out 0.3s ease-out'
  48.                     }
  49.                 }
  50.             }
  51.         }
  52.     </script>
  53.     <style type="text/css">
  54.         .telegram-btn {
  55.             background: linear-gradient(135deg, #0088cc, #00a2e8);
  56.             transition: all 0.3s ease;
  57.         }
  58.        
  59.         .telegram-btn:hover {
  60.             background: linear-gradient(135deg, #0077b3, #0088cc);
  61.             transform: translateY(-2px);
  62.             box-shadow: 0 4px 12px rgba(0, 136, 204, 0.3);
  63.         }
  64.        
  65.         .telegram-btn:active {
  66.             transform: translateY(0);
  67.         }
  68.        
  69.         .telegram-icon {
  70.             filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.1));
  71.         }
  72.        
  73.         .auth-container {
  74.             background: linear-gradient(145deg, #f9fafb, #f3f4f6);
  75.         }
  76.        
  77.         .dark .auth-container {
  78.             background: linear-gradient(145deg, #1f2937, #111827);
  79.         }
  80.        
  81.         /* Скрываем стандартный виджет */
  82.         #telegram-login-container iframe {
  83.             display: none !important;
  84.         }
  85.     </style>
  86. </head>
  87. <body class="bg-gray-100 dark:bg-gray-900 transition-colors duration-200 min-h-screen flex items-center justify-center p-4">
  88.     <div class="auth-container max-w-md w-full rounded-2xl shadow-xl overflow-hidden transition-all duration-300">
  89.         <div class="bg-white dark:bg-gray-800 p-6 text-center border-b border-gray-200 dark:border-gray-700">
  90.             <div class="flex justify-center mb-4">
  91.                 <svg xmlns="http://www.w3.org/2000/svg" class="h-12 w-12 text-blue-500" viewBox="0 0 24 24" fill="currentColor">
  92.                     <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"/>
  93.                 </svg>
  94.             </div>
  95.             <h1 class="text-2xl font-bold text-gray-800 dark:text-gray-200">Модерация тем форума</h1>
  96.             <p class="text-gray-600 dark:text-gray-400 mt-2">Для доступа требуется авторизация</p>
  97.         </div>
  98.        
  99.         <div class="bg-white dark:bg-gray-800 p-6 sm:p-8">
  100.             <div class="space-y-6">
  101.                 <div id="telegram-login-container">
  102.                     <!-- Кастомная кнопка авторизации -->
  103.                     <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">
  104.                         <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 mr-2 telegram-icon" viewBox="0 0 24 24" fill="currentColor">
  105.                             <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"/>
  106.                         </svg>
  107.                         Войти через Telegram
  108.                     </button>
  109.                 </div>
  110.             </div>
  111.         </div>
  112.     </div>
  113.    
  114.     <script>
  115.         // Проверяем, авторизован ли пользователь
  116.         function checkAuth() {
  117.             const token = localStorage.getItem('jwt_token');
  118.             if (token) {
  119.                 // Если есть токен, проверяем его валидность
  120.                 fetch('/api/validate-token', {
  121.                     method: 'GET',
  122.                     headers: {
  123.                         'Authorization': `Bearer ${token}`
  124.                     }
  125.                 })
  126.                 .then(response => {
  127.                     if (response.ok) {
  128.                         // Токен валиден, перенаправляем на главную
  129.                         window.location.href = '/';
  130.                     } else {
  131.                         // Токен невалиден, удаляем его
  132.                         localStorage.removeItem('jwt_token');
  133.                     }
  134.                 })
  135.                 .catch(() => {
  136.                     localStorage.removeItem('jwt_token');
  137.                 });
  138.             }
  139.         }
  140.  
  141.         function initTelegramAuth() {
  142.             // First, check if Telegram widget script is already loaded
  143.             if (window.Telegram && Telegram.Login) {
  144.                 setupTelegramAuth();
  145.             } else {
  146.                 // Load the script if not present
  147.                 const script = document.createElement('script');
  148.                 script.src = 'https://telegram.org/js/telegram-widget.js?22';
  149.                 script.async = true;
  150.                 script.onload = setupTelegramAuth;
  151.                 document.body.appendChild(script);
  152.             }
  153.         }
  154.  
  155.         function setupTelegramAuth() {
  156.             document.getElementById('custom-telegram-login').addEventListener('click', function() {
  157.                 Telegram.Login.auth(
  158.                     {
  159.                         bot_id: '5932509206', // Make sure this is your actual bot username
  160.                         request_access: 'write',
  161.                         lang: 'ru' // Optional: set language
  162.                     },
  163.                     function(user) {
  164.                         if (user) {
  165.                             // User authorized, send data to server
  166.                             fetch('https://music.esbot.ru/auth', {
  167.                                 method: 'POST',
  168.                                 headers: {
  169.                                     'Content-Type': 'application/json',
  170.                                 },
  171.                                 body: JSON.stringify(user)
  172.                             })
  173.                             .then(response => response.json())
  174.                             .then(data => {
  175.                                 if (data.token) {
  176.                                     localStorage.setItem('jwt_token', data.token);
  177.                                     window.location.href = '/';
  178.                                 }
  179.                             })
  180.                             .catch(error => {
  181.                                 console.error('Auth error:', error);
  182.                             });
  183.                         }
  184.                     }
  185.                 );
  186.             });
  187.         }
  188.  
  189.         // Проверяем авторизацию при загрузке страницы
  190.         document.addEventListener('DOMContentLoaded', function() {
  191.             checkAuth();
  192.             initTelegramAuth();
  193.         });
  194.     </script>
  195. </body>
  196. </html>
  197.  
  198. Теперь такая ошибка:
  199.  
  200. Auth error: SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON
  201.  
  202. Но get запрос отдал это
  203.  
  204. {
  205.     "user": {
  206.         "id": 952766753,
  207.         "first_name": "kus",
  208.         "username": "kusehsup",
  209.         "photo_url": "https:\/\/t.me\/i\/userpic\/320\/tPk8blL3u6-Yo_rviyVmeTrAj-9Vtw5UUEHg7mqTwWw.jpg",
  210.         "auth_date": 1749554240,
  211.         "hash": "ab6635a8981a1cf78db82433a0c8e7bda28e6947be28c38bdd12d9b9d80a91bc"
  212.     },
  213.     "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>",
  214.     "origin": "https:\/\/music.esbot.ru"
  215. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement