File manager - Edit - /home2/zetasolve/poss.shayantraders.com/login.html
Back
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Login - Shayan Food Inventory</title> <link rel="icon" type="image/png" href="assets/favicon.png"> <link rel="stylesheet" href="styles/index.css"> <style> body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg-secondary); } .login-card { background: white; padding: 2.5rem; border-radius: var(--radius-lg); border: 1px solid var(--border-color); width: 100%; max-width: 400px; box-shadow: var(--shadow-lg); } .login-header { text-align: center; margin-bottom: 2rem; } .login-logo { width: 64px; height: 64px; margin-bottom: 1rem; color: var(--primary); } .login-title { font-size: 1.5rem; font-weight: 700; color: var(--text-primary); margin-bottom: 0.5rem; } .login-subtitle { color: var(--text-muted); font-size: 0.875rem; } .password-input-wrapper { position: relative; display: flex; align-items: center; } .password-input-field { flex: 1; margin: 0; padding-right: 40px; } .password-toggle-btn { position: absolute; right: 12px; background: transparent; border: none; cursor: pointer; padding: 4px; display: flex; align-items: center; justify-content: center; color: var(--text-muted); } .password-toggle-btn:hover { color: var(--text-primary); } .password-icon { width: 18px; height: 18px; } </style> </head> <body> <div class="login-card"> <div class="login-header"> <img src="assets/logo.png" alt="Shayan Food Logo" class="login-logo-img"> <h1 class="login-title">Shayan Food</h1> <p class="login-subtitle">Inventory Management System</p> </div> <form id="loginForm" onsubmit="handleLogin(event)"> <div class="form-group"> <label for="username">Username</label> <input type="text" id="username" class="form-control" placeholder="Enter username" required autofocus> </div> <div class="form-group"> <label for="password">Password</label> <div class="password-input-wrapper"> <input type="password" id="password" class="form-control password-input-field" placeholder="Enter password" required> <button type="button" class="password-toggle-btn" onclick="togglePasswordVisibility()"> <svg class="password-icon" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"> <path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z" stroke="currentColor" stroke-width="2" fill="none"/> <circle cx="12" cy="12" r="3" stroke="currentColor" stroke-width="2" fill="none"/> </svg> </button> </div> </div> <div id="loginError" class="text-danger text-center mb-2" style="font-size: 0.875rem; display: none;"> Invalid username or password </div> <button type="submit" class="btn btn-primary" style="width: 100%; justify-content: center; padding: 0.75rem;"> Sign In </button> </form> </div> <script> // API Configuration - Fixed for localhost and production const API_BASE_URL = (() => { // If opened from file:// or localhost, use localhost if (window.location.protocol === 'file:' || window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1') { return 'http://localhost:3000/api'; } // Production - poss.shayantraders.com calls backend.shayantraders.com if (window.location.hostname === 'poss.shayantraders.com') { return 'https://backend.shayantraders.com/api'; } // Default - use current origin return window.location.origin + '/api'; })(); // Check if already logged in if (localStorage.getItem('isLoggedIn') === 'true') { window.location.href = 'index.html'; } async function handleLogin(event) { event.preventDefault(); const username = document.getElementById('username').value; const password = document.getElementById('password').value; const errorDiv = document.getElementById('loginError'); console.log('API URL:', API_BASE_URL); try { const response = await fetch(API_BASE_URL + '/login', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ username, password }) }); const data = await response.json(); if (response.ok) { // Login successful localStorage.setItem('isLoggedIn', 'true'); localStorage.setItem('user', data.username); localStorage.setItem('role', data.role); localStorage.setItem('permissions', data.permissions); // Store JSON string localStorage.setItem('status', data.status || 'Active'); // Store user status // Check if user has dashboard permission before redirecting let userPermissions = []; try { userPermissions = JSON.parse(data.permissions) || []; } catch (e) { userPermissions = []; } // If user has dashboard permission, redirect to dashboard; otherwise, redirect to first allowed page if (userPermissions.includes('dashboard.html') || userPermissions.includes('*')) { window.location.href = 'index.html'; } else { // Find the first page the user has access to const allowedPages = [ 'pages/inventory.html', 'pages/billing.html', 'pages/invoices.html', 'pages/returns.html', 'pages/damage_items.html', 'pages/credit.html', 'pages/expenses.html', 'pages/reports.html', 'pages/admin.html' ]; let redirectToPage = null; for (const page of allowedPages) { const pageName = page.replace('pages/', ''); if (userPermissions.includes(pageName) || userPermissions.includes('*')) { redirectToPage = page; break; } } if (redirectToPage) { window.location.href = redirectToPage; } else { // If no pages allowed, show an error alert('You do not have access to any pages. Please contact your administrator.'); } } } else { // Login failed if (response.status === 403) { // Account disabled showError(data.error || 'Account disabled. Please contact administrator.'); } else { // Invalid credentials showError('Invalid username or password'); } } } catch (error) { console.error('Login error:', error); showError('An error occurred. Please try again.'); } } function showError(message = 'Invalid username or password') { const errorDiv = document.getElementById('loginError'); errorDiv.style.display = 'block'; errorDiv.textContent = message; // Shake animation const card = document.querySelector('.login-card'); card.style.animation = 'shake 0.5s'; setTimeout(() => card.style.animation = '', 500); } </script> <script> function togglePasswordVisibility() { const passwordInput = document.getElementById('password'); const toggleButton = document.querySelector('.password-toggle-btn'); const eyeIcon = toggleButton.querySelector('.password-icon'); if (passwordInput.type === 'password') { passwordInput.type = 'text'; // Change to eye-off icon eyeIcon.innerHTML = ` <path d="M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-5.77 3.23a12.86 12.86 0 0 1-5.65-5.69M1 1l22 22" stroke="currentColor" stroke-width="2" fill="none"/> `; } else { passwordInput.type = 'password'; // Change back to eye icon eyeIcon.innerHTML = ` <path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z" stroke="currentColor" stroke-width="2" fill="none"/> <circle cx="12" cy="12" r="3" stroke="currentColor" stroke-width="2" fill="none"/> `; } } </script> <style> @keyframes shake { 0%, 100% { transform: translateX(0); } 10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); } 20%, 40%, 60%, 80% { transform: translateX(5px); } } </style> </body> </html>
| ver. 1.4 |
Github
|
.
| PHP 8.2.31 | Generation time: 0.21 |
proxy
|
phpinfo
|
Settings