219 lines
6.9 KiB
HTML
219 lines
6.9 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>SmartCane Web Apps - Login</title>
|
|
<link rel="stylesheet" href="theme.css">
|
|
<style>
|
|
* {
|
|
margin: 0;
|
|
padding: 0;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
body {
|
|
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
|
background: linear-gradient(135deg, var(--sc-primary) 0%, var(--sc-primary-light) 100%);
|
|
min-height: 100vh;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
padding: 20px;
|
|
}
|
|
|
|
.login-container {
|
|
background: white;
|
|
border-radius: 12px;
|
|
box-shadow: 0 20px 60px rgba(0,0,0,0.3);
|
|
width: 100%;
|
|
max-width: 400px;
|
|
padding: 50px 40px;
|
|
text-align: center;
|
|
}
|
|
|
|
.logo-section {
|
|
margin-bottom: 40px;
|
|
}
|
|
|
|
.logo {
|
|
height: 60px;
|
|
width: auto;
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
h1 {
|
|
color: #333;
|
|
font-size: 28px;
|
|
margin-bottom: 10px;
|
|
}
|
|
|
|
.subtitle {
|
|
color: #666;
|
|
font-size: 14px;
|
|
margin-bottom: 30px;
|
|
}
|
|
|
|
.form-group {
|
|
margin-bottom: 20px;
|
|
text-align: left;
|
|
}
|
|
|
|
label {
|
|
display: block;
|
|
color: #333;
|
|
font-weight: 600;
|
|
margin-bottom: 8px;
|
|
font-size: 14px;
|
|
}
|
|
|
|
input[type="password"] {
|
|
width: 100%;
|
|
padding: 12px;
|
|
border: 2px solid #e0d9d0;
|
|
border-radius: 6px;
|
|
font-size: 14px;
|
|
transition: border-color 0.3s ease;
|
|
font-family: inherit;
|
|
}
|
|
|
|
input[type="password"]:focus {
|
|
outline: none;
|
|
border-color: var(--sc-primary);
|
|
box-shadow: 0 0 0 3px rgba(42, 171, 149, 0.1);
|
|
}
|
|
|
|
button {
|
|
width: 100%;
|
|
padding: 12px;
|
|
background: linear-gradient(135deg, var(--sc-primary) 0%, var(--sc-primary-light) 100%);
|
|
color: white;
|
|
border: none;
|
|
border-radius: 6px;
|
|
font-size: 16px;
|
|
font-weight: 600;
|
|
cursor: pointer;
|
|
transition: transform 0.2s ease, box-shadow 0.2s ease;
|
|
}
|
|
|
|
button:hover {
|
|
transform: translateY(-2px);
|
|
box-shadow: 0 10px 20px rgba(42, 171, 149, 0.3);
|
|
}
|
|
|
|
button:active {
|
|
transform: translateY(0);
|
|
}
|
|
|
|
.error-message {
|
|
background: #f8d7da;
|
|
color: #721c24;
|
|
padding: 12px;
|
|
border-radius: 6px;
|
|
margin-bottom: 20px;
|
|
font-size: 14px;
|
|
display: none;
|
|
border-left: 4px solid #dc3545;
|
|
}
|
|
|
|
.error-message.show {
|
|
display: block;
|
|
}
|
|
|
|
.info-text {
|
|
color: #999;
|
|
font-size: 12px;
|
|
margin-top: 20px;
|
|
line-height: 1.6;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="login-container">
|
|
<div class="logo-section">
|
|
<img src="https://www.smartcane.ag/wp-content/uploads/2023/09/smartcane-logo.png" alt="SmartCane" class="logo" onerror="this.style.display='none'">
|
|
<h1>SmartCane</h1>
|
|
<p class="subtitle">Web Apps Portal</p>
|
|
</div>
|
|
|
|
<form id="loginForm">
|
|
<div class="error-message" id="errorMessage"></div>
|
|
|
|
<div class="form-group">
|
|
<label for="password">Password</label>
|
|
<input type="password" id="password" placeholder="Enter password" required>
|
|
</div>
|
|
|
|
<button type="submit">Access Tools</button>
|
|
</form>
|
|
|
|
<p class="info-text">
|
|
Enter your password to access the SmartCane Web Apps tools.<br><br>
|
|
<small>Learn more at <a href="https://www.smartcane.ag" target="_blank" style="color: var(--sc-primary); text-decoration: none; font-weight: 600;">www.smartcane.ag</a></small>
|
|
</p>
|
|
</div>
|
|
|
|
<script>
|
|
// Check if already authenticated
|
|
window.addEventListener('load', function() {
|
|
if (sessionStorage.getItem('authenticated') === 'true') {
|
|
window.location.href = 'index.html';
|
|
}
|
|
});
|
|
|
|
// Handle login form
|
|
document.getElementById('loginForm').addEventListener('submit', async function(e) {
|
|
e.preventDefault();
|
|
|
|
const password = document.getElementById('password').value;
|
|
const errorMessage = document.getElementById('errorMessage');
|
|
const button = this.querySelector('button');
|
|
|
|
// Disable button during request
|
|
button.disabled = true;
|
|
button.textContent = 'Verifying...';
|
|
|
|
try {
|
|
// Send password to Netlify function for server-side verification
|
|
const response = await fetch('/.netlify/functions/login', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
body: JSON.stringify({ password })
|
|
});
|
|
|
|
const data = await response.json();
|
|
|
|
if (response.ok) {
|
|
// Authentication successful
|
|
sessionStorage.setItem('authenticated', 'true');
|
|
window.location.href = 'index.html';
|
|
} else {
|
|
// Authentication failed
|
|
errorMessage.textContent = data.error || 'Invalid password. Please try again.';
|
|
errorMessage.classList.add('show');
|
|
document.getElementById('password').value = '';
|
|
document.getElementById('password').focus();
|
|
button.disabled = false;
|
|
button.textContent = 'Access Tools';
|
|
}
|
|
} catch (error) {
|
|
console.error('Login error:', error);
|
|
errorMessage.textContent = 'Connection error. Please check your internet and try again.';
|
|
errorMessage.classList.add('show');
|
|
button.disabled = false;
|
|
button.textContent = 'Access Tools';
|
|
}
|
|
});
|
|
|
|
// Allow Enter key to submit
|
|
document.getElementById('password').addEventListener('keypress', function(e) {
|
|
if (e.key === 'Enter') {
|
|
document.getElementById('loginForm').dispatchEvent(new Event('submit'));
|
|
}
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|