v1.0
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 3.2 KiB |
+9537
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,5 @@
|
||||
<?python
|
||||
import sys
|
||||
with open('/home/claude/index.html', 'r', encoding='utf-8') as f:
|
||||
print(f.read(), end='')
|
||||
?>
|
||||
@@ -0,0 +1,443 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ko">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>SmallClaw — Login</title>
|
||||
<style>
|
||||
@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&family=IBM+Plex+Mono:wght@400;500;600&display=swap');
|
||||
|
||||
:root {
|
||||
--bg: #f4f6fb;
|
||||
--bg-soft: #eef2f8;
|
||||
--panel: #ffffff;
|
||||
--panel-2: #f8fafc;
|
||||
--line: #dbe3ee;
|
||||
--line-strong: #c7d3e3;
|
||||
--text: #0f172a;
|
||||
--muted: #5f6f86;
|
||||
--brand: #1668e3;
|
||||
--brand-2: #0f4fba;
|
||||
--ok: #0f9f6e;
|
||||
--warn: #d18b19;
|
||||
--err: #d14b4b;
|
||||
--radius-sm: 10px;
|
||||
--radius-md: 14px;
|
||||
--radius-lg: 18px;
|
||||
--shadow-sm: 0 2px 6px rgba(16, 32, 64, 0.06);
|
||||
--shadow-md: 0 8px 24px rgba(16, 32, 64, 0.08);
|
||||
}
|
||||
|
||||
:root[data-theme="dark"] {
|
||||
--bg: #1f242d;
|
||||
--bg-soft: #242a34;
|
||||
--panel: #2a313d;
|
||||
--panel-2: #323a47;
|
||||
--line: #3d4656;
|
||||
--line-strong: #505b70;
|
||||
--text: #e8edf6;
|
||||
--muted: #aeb9cb;
|
||||
--brand: #4c8dff;
|
||||
--brand-2: #2f6fe0;
|
||||
--ok: #31b884;
|
||||
--warn: #d6a64f;
|
||||
--err: #e06d6d;
|
||||
--shadow-sm: 0 2px 8px rgba(4, 7, 12, 0.28);
|
||||
--shadow-md: 0 10px 30px rgba(4, 7, 12, 0.36);
|
||||
}
|
||||
|
||||
* { margin: 0; padding: 0; box-sizing: border-box; }
|
||||
|
||||
body {
|
||||
min-height: 100vh;
|
||||
font-family: 'Manrope', sans-serif;
|
||||
color: var(--text);
|
||||
background:
|
||||
radial-gradient(900px 420px at 8% -15%, rgba(22, 104, 227, 0.12), transparent 65%),
|
||||
radial-gradient(900px 420px at 100% -20%, rgba(33, 166, 255, 0.12), transparent 62%),
|
||||
var(--bg);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 20px;
|
||||
}
|
||||
:root[data-theme="dark"] body {
|
||||
background:
|
||||
radial-gradient(900px 420px at 8% -15%, rgba(76, 141, 255, 0.12), transparent 65%),
|
||||
radial-gradient(900px 420px at 100% -20%, rgba(89, 188, 255, 0.1), transparent 62%),
|
||||
var(--bg);
|
||||
}
|
||||
|
||||
.login-card {
|
||||
width: 100%;
|
||||
max-width: 400px;
|
||||
background: var(--panel);
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--radius-lg);
|
||||
box-shadow: var(--shadow-md);
|
||||
padding: 40px 32px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 24px;
|
||||
}
|
||||
|
||||
.logo-area {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.logo-icon {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
background: linear-gradient(135deg, var(--brand), var(--brand-2));
|
||||
border-radius: 12px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #fff;
|
||||
font-weight: 800;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.logo-text {
|
||||
font-size: 24px;
|
||||
font-weight: 800;
|
||||
letter-spacing: -0.5px;
|
||||
}
|
||||
|
||||
.subtitle {
|
||||
font-size: 14px;
|
||||
color: var(--muted);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.form-group {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.form-label {
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.form-input {
|
||||
width: 100%;
|
||||
padding: 12px 14px;
|
||||
font-family: 'IBM Plex Mono', monospace;
|
||||
font-size: 14px;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--radius-sm);
|
||||
background: var(--panel-2);
|
||||
color: var(--text);
|
||||
outline: none;
|
||||
transition: border-color 0.2s, box-shadow 0.2s;
|
||||
}
|
||||
.form-input:focus {
|
||||
border-color: var(--brand);
|
||||
box-shadow: 0 0 0 3px rgba(22, 104, 227, 0.15);
|
||||
}
|
||||
:root[data-theme="dark"] .form-input:focus {
|
||||
box-shadow: 0 0 0 3px rgba(76, 141, 255, 0.2);
|
||||
}
|
||||
|
||||
.btn {
|
||||
width: 100%;
|
||||
padding: 12px 20px;
|
||||
font-family: 'Manrope', sans-serif;
|
||||
font-size: 15px;
|
||||
font-weight: 700;
|
||||
border: none;
|
||||
border-radius: var(--radius-sm);
|
||||
cursor: pointer;
|
||||
transition: background 0.2s, transform 0.1s;
|
||||
}
|
||||
.btn:active { transform: scale(0.98); }
|
||||
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
|
||||
|
||||
.btn-primary {
|
||||
background: linear-gradient(135deg, var(--brand), var(--brand-2));
|
||||
color: #fff;
|
||||
}
|
||||
.btn-primary:hover:not(:disabled) { filter: brightness(1.1); }
|
||||
|
||||
.error-msg {
|
||||
width: 100%;
|
||||
padding: 10px 14px;
|
||||
background: rgba(209, 75, 75, 0.1);
|
||||
border: 1px solid rgba(209, 75, 75, 0.3);
|
||||
border-radius: var(--radius-sm);
|
||||
color: var(--err);
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
display: none;
|
||||
}
|
||||
.error-msg.visible { display: block; }
|
||||
|
||||
.theme-toggle {
|
||||
position: absolute;
|
||||
top: 20px;
|
||||
right: 20px;
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
background: var(--panel);
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
font-size: 16px;
|
||||
color: var(--muted);
|
||||
transition: background 0.2s;
|
||||
}
|
||||
.theme-toggle:hover { background: var(--panel-2); }
|
||||
|
||||
.password-wrapper {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.toggle-pw {
|
||||
position: absolute;
|
||||
right: 12px;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
background: none;
|
||||
border: none;
|
||||
color: var(--muted);
|
||||
cursor: pointer;
|
||||
font-size: 16px;
|
||||
padding: 4px;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.migrate-notice {
|
||||
width: 100%;
|
||||
padding: 10px 14px;
|
||||
background: rgba(209, 143, 25, 0.1);
|
||||
border: 1px solid rgba(209, 143, 25, 0.3);
|
||||
border-radius: var(--radius-sm);
|
||||
color: var(--warn);
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
display: none;
|
||||
}
|
||||
.migrate-notice.visible { display: block; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<button class="theme-toggle" id="themeToggle" title="Toggle theme">☾</button>
|
||||
|
||||
<div class="login-card">
|
||||
<div class="logo-area">
|
||||
<div class="logo-icon">SC</div>
|
||||
<div class="logo-text">SmallClaw</div>
|
||||
</div>
|
||||
<p class="subtitle" id="subtitle">Checking authentication...</p>
|
||||
|
||||
<div class="migrate-notice" id="migrateNotice">
|
||||
Your account needs a username. Choose one to upgrade.
|
||||
</div>
|
||||
|
||||
<form id="authForm" style="display:none; width:100%; display:flex; flex-direction:column; gap:16px;">
|
||||
<div class="form-group" id="usernameGroup" style="display:none;">
|
||||
<label class="form-label" id="usernameLabel">Username</label>
|
||||
<input type="text" class="form-input" id="username" autocomplete="username" placeholder="Enter username">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label" id="pwLabel">Password</label>
|
||||
<div class="password-wrapper">
|
||||
<input type="password" class="form-input" id="password" autocomplete="current-password" placeholder="Enter password" style="padding-right:40px;">
|
||||
<button type="button" class="toggle-pw" id="togglePw" title="Show password">👁</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group" id="confirmGroup" style="display:none;">
|
||||
<label class="form-label">Confirm password</label>
|
||||
<input type="password" class="form-input" id="confirmPassword" autocomplete="new-password" placeholder="Confirm password">
|
||||
</div>
|
||||
<div class="error-msg" id="errorMsg"></div>
|
||||
<button type="submit" class="btn btn-primary" id="submitBtn">Login</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
(function() {
|
||||
const form = document.getElementById('authForm');
|
||||
const subtitle = document.getElementById('subtitle');
|
||||
const usernameInput = document.getElementById('username');
|
||||
const usernameGroup = document.getElementById('usernameGroup');
|
||||
const usernameLabel = document.getElementById('usernameLabel');
|
||||
const passwordInput = document.getElementById('password');
|
||||
const confirmInput = document.getElementById('confirmPassword');
|
||||
const confirmGroup = document.getElementById('confirmGroup');
|
||||
const pwLabel = document.getElementById('pwLabel');
|
||||
const errorMsg = document.getElementById('errorMsg');
|
||||
const submitBtn = document.getElementById('submitBtn');
|
||||
const togglePw = document.getElementById('togglePw');
|
||||
const themeToggle = document.getElementById('themeToggle');
|
||||
const migrateNotice = document.getElementById('migrateNotice');
|
||||
|
||||
let mode = 'login'; // 'setup' | 'login' | 'legacy-migrate'
|
||||
|
||||
// Theme
|
||||
const savedTheme = localStorage.getItem('sc-theme') || 'light';
|
||||
document.documentElement.setAttribute('data-theme', savedTheme);
|
||||
themeToggle.textContent = savedTheme === 'dark' ? '☀' : '☾';
|
||||
themeToggle.addEventListener('click', () => {
|
||||
const current = document.documentElement.getAttribute('data-theme');
|
||||
const next = current === 'dark' ? 'light' : 'dark';
|
||||
document.documentElement.setAttribute('data-theme', next);
|
||||
localStorage.setItem('sc-theme', next);
|
||||
themeToggle.textContent = next === 'dark' ? '☀' : '☾';
|
||||
});
|
||||
|
||||
// Toggle password visibility
|
||||
togglePw.addEventListener('click', () => {
|
||||
const isPassword = passwordInput.type === 'password';
|
||||
passwordInput.type = isPassword ? 'text' : 'password';
|
||||
togglePw.textContent = isPassword ? '✎' : '👁';
|
||||
});
|
||||
|
||||
function showError(msg) {
|
||||
errorMsg.textContent = msg;
|
||||
errorMsg.classList.add('visible');
|
||||
}
|
||||
function hideError() {
|
||||
errorMsg.classList.remove('visible');
|
||||
}
|
||||
|
||||
async function checkStatus() {
|
||||
try {
|
||||
const res = await fetch('/api/auth/status');
|
||||
const data = await res.json();
|
||||
|
||||
if (!data.enabled) {
|
||||
window.location.href = '/';
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.authenticated) {
|
||||
window.location.href = '/';
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.hasLegacyPassword && !data.hasUsers) {
|
||||
// Legacy mode: old password-only install needs migration
|
||||
mode = 'legacy-migrate';
|
||||
subtitle.textContent = 'Set a username to upgrade your account';
|
||||
migrateNotice.classList.add('visible');
|
||||
usernameGroup.style.display = 'flex';
|
||||
usernameLabel.textContent = 'Username';
|
||||
usernameInput.placeholder = 'Choose a username';
|
||||
pwLabel.textContent = 'Current password';
|
||||
submitBtn.textContent = 'Upgrade & Login';
|
||||
confirmGroup.style.display = 'none';
|
||||
passwordInput.autocomplete = 'current-password';
|
||||
passwordInput.placeholder = 'Enter your current password';
|
||||
} else if (!data.hasUsers) {
|
||||
// Fresh install: first user setup
|
||||
mode = 'setup';
|
||||
subtitle.textContent = 'Create an admin account';
|
||||
migrateNotice.classList.remove('visible');
|
||||
usernameGroup.style.display = 'flex';
|
||||
usernameLabel.textContent = 'Username';
|
||||
usernameInput.placeholder = 'Choose a username';
|
||||
pwLabel.textContent = 'Password';
|
||||
submitBtn.textContent = 'Create account';
|
||||
confirmGroup.style.display = 'flex';
|
||||
passwordInput.autocomplete = 'new-password';
|
||||
passwordInput.placeholder = 'Choose a password';
|
||||
} else {
|
||||
// Normal login
|
||||
mode = 'login';
|
||||
subtitle.textContent = 'Sign in to SmallClaw';
|
||||
migrateNotice.classList.remove('visible');
|
||||
usernameGroup.style.display = 'flex';
|
||||
usernameLabel.textContent = 'Username';
|
||||
usernameInput.placeholder = 'Enter username';
|
||||
pwLabel.textContent = 'Password';
|
||||
submitBtn.textContent = 'Login';
|
||||
confirmGroup.style.display = 'none';
|
||||
passwordInput.autocomplete = 'current-password';
|
||||
passwordInput.placeholder = 'Enter password';
|
||||
}
|
||||
|
||||
form.style.display = 'flex';
|
||||
usernameInput.focus();
|
||||
} catch (e) {
|
||||
subtitle.textContent = 'Unable to reach server';
|
||||
}
|
||||
}
|
||||
|
||||
form.addEventListener('submit', async (e) => {
|
||||
e.preventDefault();
|
||||
hideError();
|
||||
|
||||
const username = usernameInput.value.trim();
|
||||
const password = passwordInput.value;
|
||||
|
||||
if (mode === 'login') {
|
||||
if (!username) { showError('Please enter your username'); return; }
|
||||
if (!password) { showError('Please enter your password'); return; }
|
||||
} else if (mode === 'setup') {
|
||||
if (!username || username.length < 2) { showError('Username must be at least 2 characters'); return; }
|
||||
if (!/^[a-zA-Z0-9_-]+$/.test(username)) { showError('Username: letters, numbers, dash, underscore only'); return; }
|
||||
if (!password || password.length < 4) { showError('Password must be at least 4 characters'); return; }
|
||||
if (password !== confirmInput.value) { showError('Passwords do not match'); return; }
|
||||
} else if (mode === 'legacy-migrate') {
|
||||
if (!username || username.length < 2) { showError('Username must be at least 2 characters'); return; }
|
||||
if (!/^[a-zA-Z0-9_-]+$/.test(username)) { showError('Username: letters, numbers, dash, underscore only'); return; }
|
||||
if (!password) { showError('Please enter your current password'); return; }
|
||||
}
|
||||
|
||||
submitBtn.disabled = true;
|
||||
const btnText = submitBtn.textContent;
|
||||
submitBtn.textContent = mode === 'setup' ? 'Creating account...' : mode === 'legacy-migrate' ? 'Upgrading...' : 'Logging in...';
|
||||
|
||||
try {
|
||||
let endpoint, body;
|
||||
if (mode === 'setup' || mode === 'legacy-migrate') {
|
||||
endpoint = '/api/auth/setup';
|
||||
body = { username, password };
|
||||
} else {
|
||||
endpoint = '/api/auth/login';
|
||||
body = { username, password };
|
||||
}
|
||||
const res = await fetch(endpoint, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(body),
|
||||
});
|
||||
const data = await res.json();
|
||||
|
||||
if (res.ok && data.success) {
|
||||
window.location.href = '/';
|
||||
} else {
|
||||
showError(data.error || 'Authentication failed');
|
||||
submitBtn.disabled = false;
|
||||
submitBtn.textContent = btnText;
|
||||
}
|
||||
} catch (e) {
|
||||
showError('Connection error — please try again');
|
||||
submitBtn.disabled = false;
|
||||
submitBtn.textContent = btnText;
|
||||
}
|
||||
});
|
||||
|
||||
usernameInput.addEventListener('input', hideError);
|
||||
passwordInput.addEventListener('input', hideError);
|
||||
confirmInput.addEventListener('input', hideError);
|
||||
|
||||
checkStatus();
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user