- New web assets for 6.0.5.
This commit is contained in:
parent
9c36aa10fa
commit
01264411ba
3 changed files with 813 additions and 0 deletions
24
migrations/6.0.5.sql
Normal file
24
migrations/6.0.5.sql
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
-- Migration 6.0.5: Add update-summary.bas scheduled automation
|
||||
-- Description: Creates a scheduled automation that runs every minute to update summaries
|
||||
-- This replaces the announcements system in legacy mode
|
||||
|
||||
-- Add name column to system_automations if it doesn't exist
|
||||
ALTER TABLE public.system_automations ADD COLUMN IF NOT EXISTS name VARCHAR(255);
|
||||
|
||||
-- Insert update-summary automation (runs every minute)
|
||||
-- kind = 3 (Scheduled trigger)
|
||||
-- schedule format: minute hour day month weekday
|
||||
-- "* * * * *" = every minute
|
||||
INSERT INTO public.system_automations (name, kind, target, param, schedule, is_active)
|
||||
VALUES (
|
||||
'Update Summary',
|
||||
3,
|
||||
NULL,
|
||||
'update-summary.bas',
|
||||
'* * * * *',
|
||||
true
|
||||
)
|
||||
ON CONFLICT DO NOTHING;
|
||||
|
||||
-- Create index on name column for faster lookups
|
||||
CREATE INDEX IF NOT EXISTS idx_system_automations_name ON public.system_automations(name);
|
||||
344
web/static/about/index.html
Normal file
344
web/static/about/index.html
Normal file
|
|
@ -0,0 +1,344 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>About - BotServer</title>
|
||||
<style>
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
min-height: 100vh;
|
||||
padding: 40px 20px;
|
||||
}
|
||||
|
||||
.container {
|
||||
max-width: 800px;
|
||||
margin: 0 auto;
|
||||
background: white;
|
||||
border-radius: 16px;
|
||||
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.header {
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
color: white;
|
||||
padding: 50px 40px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.header h1 {
|
||||
font-size: 48px;
|
||||
margin-bottom: 10px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.header .version {
|
||||
font-size: 18px;
|
||||
opacity: 0.9;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.content {
|
||||
padding: 50px 40px;
|
||||
}
|
||||
|
||||
.section {
|
||||
margin-bottom: 40px;
|
||||
}
|
||||
|
||||
.section h2 {
|
||||
color: #1f2937;
|
||||
font-size: 28px;
|
||||
margin-bottom: 15px;
|
||||
padding-bottom: 10px;
|
||||
border-bottom: 3px solid #667eea;
|
||||
}
|
||||
|
||||
.section p {
|
||||
color: #4b5563;
|
||||
line-height: 1.8;
|
||||
font-size: 16px;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.section ul {
|
||||
list-style: none;
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
.section ul li {
|
||||
color: #4b5563;
|
||||
line-height: 1.8;
|
||||
font-size: 16px;
|
||||
margin-bottom: 10px;
|
||||
padding-left: 30px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.section ul li:before {
|
||||
content: "→";
|
||||
position: absolute;
|
||||
left: 0;
|
||||
color: #667eea;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.maintainer-box {
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
color: white;
|
||||
padding: 30px;
|
||||
border-radius: 12px;
|
||||
text-align: center;
|
||||
margin: 30px 0;
|
||||
}
|
||||
|
||||
.maintainer-box h3 {
|
||||
font-size: 24px;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.maintainer-box a {
|
||||
color: white;
|
||||
text-decoration: none;
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
border-bottom: 2px solid rgba(255, 255, 255, 0.5);
|
||||
transition: border-color 0.3s;
|
||||
}
|
||||
|
||||
.maintainer-box a:hover {
|
||||
border-bottom-color: white;
|
||||
}
|
||||
|
||||
.links {
|
||||
display: flex;
|
||||
gap: 20px;
|
||||
flex-wrap: wrap;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.link-card {
|
||||
flex: 1;
|
||||
min-width: 200px;
|
||||
background: #f9fafb;
|
||||
padding: 25px;
|
||||
border-radius: 12px;
|
||||
text-align: center;
|
||||
transition: transform 0.3s, box-shadow 0.3s;
|
||||
border: 2px solid #e5e7eb;
|
||||
}
|
||||
|
||||
.link-card:hover {
|
||||
transform: translateY(-5px);
|
||||
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
|
||||
border-color: #667eea;
|
||||
}
|
||||
|
||||
.link-card h4 {
|
||||
color: #1f2937;
|
||||
margin-bottom: 10px;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.link-card a {
|
||||
color: #667eea;
|
||||
text-decoration: none;
|
||||
font-weight: 600;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.link-card a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.features {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
|
||||
gap: 20px;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.feature-card {
|
||||
background: #f9fafb;
|
||||
padding: 20px;
|
||||
border-radius: 8px;
|
||||
border-left: 4px solid #667eea;
|
||||
}
|
||||
|
||||
.feature-card h4 {
|
||||
color: #1f2937;
|
||||
margin-bottom: 8px;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.feature-card p {
|
||||
color: #6b7280;
|
||||
font-size: 14px;
|
||||
line-height: 1.6;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.back-link {
|
||||
text-align: center;
|
||||
padding: 30px;
|
||||
background: #f9fafb;
|
||||
}
|
||||
|
||||
.back-link a {
|
||||
color: #667eea;
|
||||
text-decoration: none;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.back-link a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.badge {
|
||||
display: inline-block;
|
||||
padding: 6px 12px;
|
||||
background: #667eea;
|
||||
color: white;
|
||||
border-radius: 20px;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
margin: 5px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="header">
|
||||
<h1>BotServer</h1>
|
||||
<p>Open-source conversational AI platform</p>
|
||||
<div class="version">Version 6.0.5</div>
|
||||
</div>
|
||||
|
||||
<div class="content">
|
||||
<div class="section">
|
||||
<h2>About BotServer</h2>
|
||||
<p>
|
||||
BotServer is a comprehensive, open-source platform for building and deploying conversational AI bots.
|
||||
It provides a complete ecosystem for creating intelligent chatbots with natural language processing,
|
||||
knowledge management, and multi-channel deployment capabilities.
|
||||
</p>
|
||||
<p>
|
||||
Built with performance and scalability in mind, BotServer leverages Rust's safety and efficiency
|
||||
to deliver enterprise-grade bot infrastructure that can handle thousands of concurrent conversations.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="maintainer-box">
|
||||
<h3>Main Maintainer</h3>
|
||||
<a href="https://pragmatismo.com.br" target="_blank">Pragmatismo.com.br</a>
|
||||
<p style="margin-top: 15px; font-size: 14px; opacity: 0.9;">
|
||||
Professional consulting and implementation services available
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="section">
|
||||
<h2>Open Source</h2>
|
||||
<div class="links">
|
||||
<div class="link-card">
|
||||
<h4>GitHub Organization</h4>
|
||||
<a href="https://github.com/GeneralBots" target="_blank">github.com/GeneralBots</a>
|
||||
</div>
|
||||
<div class="link-card">
|
||||
<h4>Repository</h4>
|
||||
<a href="https://github.com/GeneralBots/BotServer" target="_blank">BotServer Repository</a>
|
||||
</div>
|
||||
</div>
|
||||
<p style="margin-top: 20px;">
|
||||
BotServer is licensed under AGPL-3.0, ensuring it remains free and open source.
|
||||
Contributions, bug reports, and feature requests are welcome!
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="section">
|
||||
<h2>Key Features</h2>
|
||||
<div class="features">
|
||||
<div class="feature-card">
|
||||
<h4>🤖 AI-Powered</h4>
|
||||
<p>Local LLM support with DeepSeek and embeddings for intelligent conversations</p>
|
||||
</div>
|
||||
<div class="feature-card">
|
||||
<h4>📚 Knowledge Base</h4>
|
||||
<p>Vector database integration for semantic search and context-aware responses</p>
|
||||
</div>
|
||||
<div class="feature-card">
|
||||
<h4>🔌 Multi-Channel</h4>
|
||||
<p>Deploy to web, WhatsApp, voice, and more with unified bot logic</p>
|
||||
</div>
|
||||
<div class="feature-card">
|
||||
<h4>📦 Modular Architecture</h4>
|
||||
<p>Install only what you need - email, proxy, meeting, and more</p>
|
||||
</div>
|
||||
<div class="feature-card">
|
||||
<h4>🚀 High Performance</h4>
|
||||
<p>Built with Rust for speed, safety, and efficient resource usage</p>
|
||||
</div>
|
||||
<div class="feature-card">
|
||||
<h4>🔒 Secure by Default</h4>
|
||||
<p>Authentication, encryption, and secure credential management</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="section">
|
||||
<h2>Technology Stack</h2>
|
||||
<div>
|
||||
<span class="badge">Rust</span>
|
||||
<span class="badge">Actix-Web</span>
|
||||
<span class="badge">PostgreSQL</span>
|
||||
<span class="badge">Redis</span>
|
||||
<span class="badge">MinIO</span>
|
||||
<span class="badge">Qdrant</span>
|
||||
<span class="badge">LLama.cpp</span>
|
||||
<span class="badge">WebSocket</span>
|
||||
<span class="badge">Docker</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="section">
|
||||
<h2>Community</h2>
|
||||
<p>
|
||||
BotServer is built and maintained by a dedicated community of developers passionate about
|
||||
conversational AI and open source software. Special thanks to all contributors who have
|
||||
helped make this project possible.
|
||||
</p>
|
||||
<ul>
|
||||
<li>Join discussions and get support on GitHub</li>
|
||||
<li>Report bugs and request features through Issues</li>
|
||||
<li>Contribute code via Pull Requests</li>
|
||||
<li>Share your bot creations with the community</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="section">
|
||||
<h2>Getting Started</h2>
|
||||
<p>
|
||||
Download the source code, press F5 (or run with <code>cargo run</code>), and everything
|
||||
will be automatically set up. BotServer includes sample bots to get you started immediately.
|
||||
</p>
|
||||
<p style="margin-top: 15px; padding: 15px; background: #fef3c7; border-left: 4px solid #f59e0b; border-radius: 4px;">
|
||||
<strong>Quick Start:</strong> Clone the repository, ensure Rust is installed, and run
|
||||
<code>cargo run</code>. The first launch will download and configure all required components.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="back-link">
|
||||
<a href="/">← Back to BotServer</a>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
445
web/static/auth/login.html
Normal file
445
web/static/auth/login.html
Normal file
|
|
@ -0,0 +1,445 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>BotServer - Login</title>
|
||||
<style>
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family:
|
||||
-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
|
||||
Oxygen, Ubuntu, Cantarell, sans-serif;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.container {
|
||||
background: white;
|
||||
border-radius: 16px;
|
||||
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
|
||||
width: 100%;
|
||||
max-width: 400px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.header {
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
color: white;
|
||||
padding: 30px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.header h1 {
|
||||
font-size: 28px;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.header p {
|
||||
font-size: 14px;
|
||||
opacity: 0.9;
|
||||
}
|
||||
|
||||
.form-container {
|
||||
padding: 30px;
|
||||
}
|
||||
|
||||
.tabs {
|
||||
display: flex;
|
||||
margin-bottom: 30px;
|
||||
border-bottom: 2px solid #e5e7eb;
|
||||
}
|
||||
|
||||
.tab {
|
||||
flex: 1;
|
||||
padding: 12px;
|
||||
text-align: center;
|
||||
cursor: pointer;
|
||||
font-weight: 600;
|
||||
color: #6b7280;
|
||||
transition: all 0.3s;
|
||||
border-bottom: 3px solid transparent;
|
||||
margin-bottom: -2px;
|
||||
}
|
||||
|
||||
.tab.active {
|
||||
color: #667eea;
|
||||
border-bottom-color: #667eea;
|
||||
}
|
||||
|
||||
.form-group {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.form-group label {
|
||||
display: block;
|
||||
margin-bottom: 8px;
|
||||
font-weight: 500;
|
||||
color: #374151;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.form-group input {
|
||||
width: 100%;
|
||||
padding: 12px 16px;
|
||||
border: 2px solid #e5e7eb;
|
||||
border-radius: 8px;
|
||||
font-size: 14px;
|
||||
transition: border-color 0.3s;
|
||||
}
|
||||
|
||||
.form-group input:focus {
|
||||
outline: none;
|
||||
border-color: #667eea;
|
||||
}
|
||||
|
||||
.btn {
|
||||
width: 100%;
|
||||
padding: 14px;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
transition:
|
||||
transform 0.2s,
|
||||
box-shadow 0.2s;
|
||||
}
|
||||
|
||||
.btn:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 10px 20px rgba(102, 126, 234, 0.4);
|
||||
}
|
||||
|
||||
.btn:active {
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
.form-section {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.form-section.active {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.message {
|
||||
padding: 12px;
|
||||
border-radius: 8px;
|
||||
margin-bottom: 20px;
|
||||
font-size: 14px;
|
||||
display: none;
|
||||
}
|
||||
|
||||
.message.error {
|
||||
background-color: #fee2e2;
|
||||
color: #991b1b;
|
||||
border: 1px solid #fecaca;
|
||||
}
|
||||
|
||||
.message.success {
|
||||
background-color: #d1fae5;
|
||||
color: #065f46;
|
||||
border: 1px solid #a7f3d0;
|
||||
}
|
||||
|
||||
.footer {
|
||||
text-align: center;
|
||||
padding: 20px;
|
||||
color: #6b7280;
|
||||
font-size: 12px;
|
||||
background: #f9fafb;
|
||||
}
|
||||
|
||||
.footer a {
|
||||
color: #667eea;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.footer a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.anonymous-link {
|
||||
text-align: center;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.anonymous-link a {
|
||||
color: #667eea;
|
||||
text-decoration: none;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.anonymous-link a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="header">
|
||||
<h1>BotServer</h1>
|
||||
<p>by Pragmatismo.com.br</p>
|
||||
</div>
|
||||
|
||||
<div class="form-container">
|
||||
<div id="message" class="message"></div>
|
||||
|
||||
<div
|
||||
style="
|
||||
background: #f0f9ff;
|
||||
border-left: 4px solid #3b82f6;
|
||||
padding: 15px;
|
||||
margin-bottom: 20px;
|
||||
border-radius: 8px;
|
||||
"
|
||||
>
|
||||
<p
|
||||
style="
|
||||
margin: 0;
|
||||
color: #1e40af;
|
||||
font-size: 14px;
|
||||
line-height: 1.6;
|
||||
"
|
||||
>
|
||||
💡 <strong>Anonymous Sessions:</strong> Each visitor
|
||||
automatically gets a unique session. Register to save
|
||||
your conversations and access them across devices!
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="tabs">
|
||||
<div class="tab active" onclick="switchTab('signin')">
|
||||
Sign In
|
||||
</div>
|
||||
<div class="tab" onclick="switchTab('signup')">Sign Up</div>
|
||||
</div>
|
||||
|
||||
<!-- Sign In Form -->
|
||||
<div id="signin-form" class="form-section active">
|
||||
<form onsubmit="handleSignIn(event)">
|
||||
<div class="form-group">
|
||||
<label for="signin-email">Email</label>
|
||||
<input
|
||||
type="email"
|
||||
id="signin-email"
|
||||
required
|
||||
placeholder="your@email.com"
|
||||
/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="signin-password">Password</label>
|
||||
<input
|
||||
type="password"
|
||||
id="signin-password"
|
||||
required
|
||||
placeholder="••••••••"
|
||||
/>
|
||||
</div>
|
||||
<button type="submit" class="btn">Sign In</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- Sign Up Form -->
|
||||
<div id="signup-form" class="form-section">
|
||||
<form onsubmit="handleSignUp(event)">
|
||||
<div class="form-group">
|
||||
<label for="signup-name">Full Name</label>
|
||||
<input
|
||||
type="text"
|
||||
id="signup-name"
|
||||
required
|
||||
placeholder="John Doe"
|
||||
/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="signup-email">Email</label>
|
||||
<input
|
||||
type="email"
|
||||
id="signup-email"
|
||||
required
|
||||
placeholder="your@email.com"
|
||||
/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="signup-password">Password</label>
|
||||
<input
|
||||
type="password"
|
||||
id="signup-password"
|
||||
required
|
||||
placeholder="••••••••"
|
||||
minlength="6"
|
||||
/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="signup-confirm">Confirm Password</label>
|
||||
<input
|
||||
type="password"
|
||||
id="signup-confirm"
|
||||
required
|
||||
placeholder="••••••••"
|
||||
minlength="6"
|
||||
/>
|
||||
</div>
|
||||
<button type="submit" class="btn">Sign Up</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="anonymous-link">
|
||||
<a href="/">← Continue with anonymous session</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="footer">
|
||||
Maintained by
|
||||
<a href="https://pragmatismo.com.br" target="_blank"
|
||||
>Pragmatismo.com.br</a
|
||||
><br />
|
||||
Open source at
|
||||
<a href="https://github.com/GeneralBots" target="_blank"
|
||||
>github.com/GeneralBots</a
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function switchTab(tab) {
|
||||
// Update tabs
|
||||
document
|
||||
.querySelectorAll(".tab")
|
||||
.forEach((t) => t.classList.remove("active"));
|
||||
event.target.classList.add("active");
|
||||
|
||||
// Update forms
|
||||
document
|
||||
.querySelectorAll(".form-section")
|
||||
.forEach((f) => f.classList.remove("active"));
|
||||
document.getElementById(tab + "-form").classList.add("active");
|
||||
|
||||
// Clear message
|
||||
hideMessage();
|
||||
}
|
||||
|
||||
function showMessage(text, type) {
|
||||
const messageEl = document.getElementById("message");
|
||||
messageEl.textContent = text;
|
||||
messageEl.className = "message " + type;
|
||||
messageEl.style.display = "block";
|
||||
}
|
||||
|
||||
function hideMessage() {
|
||||
const messageEl = document.getElementById("message");
|
||||
messageEl.style.display = "none";
|
||||
}
|
||||
|
||||
async function handleSignIn(event) {
|
||||
event.preventDefault();
|
||||
hideMessage();
|
||||
|
||||
const email = document.getElementById("signin-email").value;
|
||||
const password =
|
||||
document.getElementById("signin-password").value;
|
||||
|
||||
try {
|
||||
const response = await fetch("/api/auth/login", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({ email, password }),
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
if (response.ok) {
|
||||
showMessage(
|
||||
"Login successful! Redirecting...",
|
||||
"success",
|
||||
);
|
||||
localStorage.setItem("token", data.token);
|
||||
setTimeout(() => {
|
||||
window.location.href = "/";
|
||||
}, 1000);
|
||||
} else {
|
||||
showMessage(
|
||||
data.error || "Login failed. Please try again.",
|
||||
"error",
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
showMessage("Network error. Please try again.", "error");
|
||||
console.error("Login error:", error);
|
||||
}
|
||||
}
|
||||
|
||||
async function handleSignUp(event) {
|
||||
event.preventDefault();
|
||||
hideMessage();
|
||||
|
||||
const name = document.getElementById("signup-name").value;
|
||||
const email = document.getElementById("signup-email").value;
|
||||
const password =
|
||||
document.getElementById("signup-password").value;
|
||||
const confirm = document.getElementById("signup-confirm").value;
|
||||
|
||||
if (password !== confirm) {
|
||||
showMessage("Passwords do not match!", "error");
|
||||
return;
|
||||
}
|
||||
|
||||
if (password.length < 6) {
|
||||
showMessage(
|
||||
"Password must be at least 6 characters long.",
|
||||
"error",
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch("/api/auth/register", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({ name, email, password }),
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
if (response.ok) {
|
||||
showMessage(
|
||||
"Registration successful! Please sign in.",
|
||||
"success",
|
||||
);
|
||||
setTimeout(() => {
|
||||
switchTab("signin");
|
||||
document.getElementById("signin-email").value =
|
||||
email;
|
||||
}, 1500);
|
||||
} else {
|
||||
showMessage(
|
||||
data.error ||
|
||||
"Registration failed. Please try again.",
|
||||
"error",
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
showMessage("Network error. Please try again.", "error");
|
||||
console.error("Registration error:", error);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Reference in a new issue