Files
rx.scoreodonto.com/dental-server/bkp/docs/auth\login.html
T
VPS 4 Builder f30c4fe002
continuous-integration/webhook Deploy concluido (rx.scoreodonto.com)
chore: mover docs, scripts e arquivos obsoletos para dental-server/bkp/
2026-05-27 02:18:54 +02:00

222 lines
6.0 KiB
HTML

<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login - Dental Server</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
padding: 20px;
}
.login-container {
background: white;
border-radius: 15px;
box-shadow: 0 20px 60px rgba(0,0,0,0.3);
padding: 40px;
max-width: 400px;
width: 100%;
}
h1 {
text-align: center;
color: #667eea;
font-size: 2rem;
margin-bottom: 10px;
}
p {
text-align: center;
color: #666;
margin-bottom: 30px;
}
.form-group {
margin-bottom: 20px;
}
label {
display: block;
margin-bottom: 8px;
color: #333;
font-weight: 600;
}
input {
width: 100%;
padding: 12px;
border: 2px solid #e0e0e0;
border-radius: 8px;
font-size: 1rem;
transition: border-color 0.3s;
}
input:focus {
outline: none;
border-color: #667eea;
}
button {
width: 100%;
padding: 12px;
background: linear-gradient(135deg, #667eea, #764ba2);
color: white;
border: none;
border-radius: 8px;
font-size: 1rem;
font-weight: 600;
cursor: pointer;
transition: transform 0.3s;
}
button:hover {
transform: translateY(-2px);
}
button:active {
transform: translateY(0);
}
.alert {
padding: 12px;
border-radius: 8px;
margin-bottom: 20px;
display: none;
}
.alert.error {
background: #fee;
color: #c33;
border: 1px solid #fcc;
}
.alert.success {
background: #efe;
color: #3c3;
border: 1px solid #cfc;
}
#loginBtn {
position: relative;
}
#loginBtn.loading {
opacity: 0.7;
cursor: not-allowed;
}
#loginBtn.loading::after {
content: '';
position: absolute;
width: 16px;
height: 16px;
border: 2px solid #fff;
border-top-color: transparent;
border-radius: 50%;
animation: spin 0.8s linear infinite;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
</style>
</head>
<body>
<div class="login-container">
<h1>🦷 Dental Server</h1>
<p>Área Administrativa</p>
<div class="alert error" id="errorAlert"></div>
<form id="loginForm">
<div class="form-group">
<label for="username">Usuário ou Email</label>
<input
type="text"
id="username"
name="username"
required
autofocus
placeholder="rcesar ou rcesar@rcesar.com"
>
</div>
<div class="form-group">
<label for="password">Senha</label>
<input
type="password"
id="password"
name="password"
required
placeholder="Digite sua senha"
>
</div>
<button type="submit" class="btn" id="loginBtn">Entrar</button>
</form>
</div>
<script>
const loginForm = document.getElementById('loginForm');
const errorAlert = document.getElementById('errorAlert');
const loginBtn = document.getElementById('loginBtn');
loginForm.addEventListener('submit', async (e) => {
e.preventDefault();
const username = document.getElementById('username').value;
const password = document.getElementById('password').value;
// Mostrar loading
loginBtn.classList.add('loading');
loginBtn.disabled = true;
errorAlert.style.display = 'none';
try {
const response = await fetch('/api/auth/login', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ username, password })
});
const data = await response.json();
if (data.success && data.token) {
// Salvar token
localStorage.setItem('auth_token', data.token);
// Redirecionar usando replace para evitar loop no histórico
window.location.replace('/');
} else {
throw new Error(data.error || 'Erro ao fazer login');
}
} catch (error) {
errorAlert.textContent = error.message;
errorAlert.style.display = 'block';
} finally {
loginBtn.classList.remove('loading');
loginBtn.disabled = false;
}
});
// Verificar se já está logado (desabilitado para evitar loops - usuário pode fazer login manualmente)
// A verificação de autenticação será feita na página principal (app.js)
</script>
</body>
</html>