forked from kindrat86/agentshield
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauth.html
More file actions
183 lines (166 loc) · 8.35 KB
/
Copy pathauth.html
File metadata and controls
183 lines (166 loc) · 8.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>AgentShield, Login or Register</title>
<style>
:root {
--bg: #0a0a0a; --surface: #141414; --surface2: #1a1a1a;
--accent: #00d4aa; --text: #e0e0e0; --muted: #888;
--border: #2a2a2a; --danger: #ff4444;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.container { max-width: 420px; width: 100%; padding: 20px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 32px; }
h1 { font-size: 1.5em; text-align: center; margin-bottom: 8px; }
.subtitle { text-align: center; color: var(--muted); font-size: 14px; margin-bottom: 24px; }
.tabs { display: flex; gap: 0; margin-bottom: 24px; border-bottom: 1px solid var(--border); }
.tab { flex: 1; padding: 10px; text-align: center; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; transition: all 0.2s; font-size: 14px; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.form-group { margin-bottom: 16px; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
input { width: 100%; padding: 12px; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-size: 14px; outline: none; }
input:focus { border-color: var(--accent); }
.btn { width: 100%; padding: 12px; background: var(--accent); color: #000; border: none; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; transition: opacity 0.2s; }
.btn:hover { opacity: 0.9; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.error { color: var(--danger); font-size: 13px; margin-top: 12px; display: none; }
.success { color: var(--accent); font-size: 13px; margin-top: 12px; display: none; }
.back { text-align: center; margin-top: 20px; }
.back a { color: var(--muted); text-decoration: none; font-size: 13px; }
.back a:hover { color: var(--accent); }
</style>
</head>
<body>
<div class="container">
<div class="card">
<h1>AgentShield</h1>
<p class="subtitle">The Safety Layer for Autonomous AI Agents</p>
<div class="tabs">
<div class="tab active" id="tab-login" onclick="switchTab('login')">Login</div>
<div class="tab" id="tab-register" onclick="switchTab('register')">Register</div>
</div>
<form id="login-form" onsubmit="handleLogin(event)">
<div class="form-group">
<label>Email</label>
<input type="email" id="login-email" required placeholder="you@example.com">
</div>
<div class="form-group">
<label>Password</label>
<input type="password" id="login-password" required placeholder="••••••••">
</div>
<button type="submit" class="btn">Login →</button>
<div class="error" id="login-error"></div>
</form>
<form id="register-form" style="display:none" onsubmit="handleRegister(event)">
<div class="form-group">
<label>Email</label>
<input type="email" id="reg-email" required placeholder="you@example.com">
</div>
<div class="form-group">
<label>Password (min 8 characters)</label>
<input type="password" id="reg-password" required minlength="8" placeholder="••••••••">
</div>
<button type="submit" class="btn">Create Account →</button>
<div class="error" id="reg-error"></div>
</form>
<div class="divider" style="text-align:center;margin:16px 0;color:var(--muted);font-size:13px;position:relative">
<span style="background:var(--surface);padding:0 12px;position:relative;z-index:1">or</span>
<div style="position:absolute;top:50%;left:0;right:0;height:1px;background:var(--border)"></div>
</div>
<a href="#" onclick="handleGoogleLogin(event)" style="display:flex;align-items:center;justify-content:center;gap:10px;width:100%;padding:12px;background:#fff;color:#333;border:none;border-radius:8px;font-size:14px;font-weight:500;text-decoration:none;cursor:pointer">
<svg width="18" height="18" viewBox="0 0 24 24"><path fill="#4285F4" d="M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"/><path fill="#34A853" d="M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"/><path fill="#FBBC05" d="M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"/><path fill="#EA4335" d="M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"/></svg>
Continue with Google
</a>
<div class="success" id="success-msg"></div>
</div>
<div class="back">
<a href="/">← Back to home</a>
</div>
</div>
<script>
function switchTab(tab) {
document.getElementById('login-form').style.display = tab === 'login' ? 'block' : 'none';
document.getElementById('register-form').style.display = tab === 'register' ? 'block' : 'none';
document.getElementById('tab-login').classList.toggle('active', tab === 'login');
document.getElementById('tab-register').classList.toggle('active', tab === 'register');
document.getElementById('success-msg').style.display = 'none';
}
async function handleGoogleLogin(e) {
e.preventDefault();
// Google OAuth is configured server-side, redirect directly
window.location.href = '/api/auth/google';
}
async function handleLogin(event) {
event.preventDefault();
const btn = event.target.querySelector('.btn');
btn.disabled = true;
btn.textContent = 'Logging in...';
const email = document.getElementById('login-email').value;
const password = document.getElementById('login-password').value;
try {
const resp = await fetch('/api/auth/login', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ email, password })
});
const data = await resp.json();
if (resp.ok) {
document.getElementById('success-msg').textContent = 'Login successful! Redirecting...';
document.getElementById('success-msg').style.display = 'block';
setTimeout(() => { window.location.href = '/dashboard'; }, 1000);
} else {
document.getElementById('login-error').textContent = data.error || 'Login failed';
document.getElementById('login-error').style.display = 'block';
btn.disabled = false;
btn.textContent = 'Login →';
}
} catch (e) {
document.getElementById('login-error').textContent = 'Network error';
document.getElementById('login-error').style.display = 'block';
btn.disabled = false;
btn.textContent = 'Login →';
}
}
async function handleRegister(event) {
event.preventDefault();
const btn = event.target.querySelector('.btn');
btn.disabled = true;
btn.textContent = 'Creating account...';
const email = document.getElementById('reg-email').value;
const password = document.getElementById('reg-password').value;
try {
const resp = await fetch('/api/auth/register', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ email, password })
});
const data = await resp.json();
if (resp.ok) {
document.getElementById('success-msg').textContent = 'Account created! Redirecting to dashboard...';
document.getElementById('success-msg').style.display = 'block';
setTimeout(() => { window.location.href = '/dashboard'; }, 1000);
} else {
document.getElementById('reg-error').textContent = data.error || 'Registration failed';
document.getElementById('reg-error').style.display = 'block';
btn.disabled = false;
btn.textContent = 'Create Account →';
}
} catch (e) {
document.getElementById('reg-error').textContent = 'Network error';
document.getElementById('reg-error').style.display = 'block';
btn.disabled = false;
btn.textContent = 'Create Account →';
}
}
// Check if already logged in
fetch('/api/auth/me').then(r => r.json()).then(data => {
if (data && data.email) {
window.location.href = '/dashboard';
}
}).catch(() => {});
</script>
</body>
</html>