* Add email OTP authentication system and private room management ## Authentication System - Implement email OTP-based authentication with User and OTPToken models - Add auth.py module with OTP generation, email sending, and session management - Create authentication endpoints: /auth/send-otp, /auth/verify-otp, /auth/claim-name, /auth/status, /auth/logout - Add authentication modal UI with email verification and display name claiming - Support SMTP configuration via environment variables (optional) ## Room Privacy & Ownership - Add is_private, is_archived, owner_id, and forked_from_id fields to Room model - Implement private rooms (single-user, owner-only access) - Add room forking: users can fork public rooms to public or private - Add room archive/delete endpoints (owner-only operations) - Implement access control for private room viewing ## UI Improvements - Add public/private room tabs in sidebar - Show authentication prompt in private rooms tab for non-authenticated users - Add room action buttons (fork, archive, delete) with proper permissions - Update homepage with statistics (public/private rooms, active users, active rooms) - Remove model/voice from URL query strings, use localStorage exclusively ## Database Migration - Create migration 2025011100 for User, OTPToken tables and Room model updates - Add indexes for email, display_name, is_private, is_archived, owner_id ## Breaking Changes - URL parameters now only include username (model/voice moved to localStorage) - Private rooms require authentication to access - Room creation can now require authentication (for private rooms) * Update README with authentication and private room documentation * Simplify README to be less verbose * Add missing session import to fix linter errors * Fix migration dependency to resolve multiple heads conflict * asdf * Fix SQLAlchemy auto-correlation error in homepage statistics query * Change tagline from AI-Powered to Machine Learning Powered * Add dedicated authentication page instead of modal - Create new /auth route with full-page authentication flow - Remove modal code from index.html - Update Sign in link to point to /auth page - Auth page has 4-step flow: email, OTP, display name, success - Better UX with gradient background and cleaner design * Fix migration: remove batch_alter_table to avoid circular dependency - Use op.add_column() directly instead of batch_alter_table() - Remove foreign key constraints (defined in models, not needed in migration) - User and OTPToken tables created by db.create_all() in make init-db - Fixes CircularDependencyError during migration * Fix migration: check if columns exist before adding - Use inspector to check existing columns and indexes - Only add columns/indexes if they don't already exist - Handles case where db.create_all() was run before migration - Fixes 'duplicate column name' error * Add profile page, room browsing, and updated_at timestamp Features: - Profile page with username change and dark/light mode settings - Browse page for discovering public and private rooms - Room updated_at timestamp (integer Unix epoch) that updates on new messages - Dynamic room tabs based on current room type (public/private) - Fork and delete room actions moved to right sidebar utility belt - Remove archive feature and success alerts from room actions Technical changes: - Add updated_at column to Room model (integer timestamp) - Add /profile route with authentication requirement - Add /browse route for room discovery - Add API endpoints for username availability check and update - Update room.updated_at on message creation in app.py:1189 - Wider right sidebar (25% instead of 15%) for better button layout - Profile link on homepage and browse page for authenticated users --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: russell@unturf. <russell@unturf.com>
263 lines
8.3 KiB
HTML
263 lines
8.3 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>OpenCompletion - AI-Powered Chat Rooms</title>
|
|
<link rel="icon" href="{{ url_for('static', filename='favicon.ico') }}">
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.0.1/socket.io.min.js"></script>
|
|
<script src="{{ url_for('static', filename='js/utils.js') }}"></script>
|
|
<style>
|
|
body {
|
|
font-family: Arial, sans-serif;
|
|
background-color: #f7f7f7;
|
|
display: flex;
|
|
flex-direction: column;
|
|
justify-content: center;
|
|
align-items: center;
|
|
min-height: 100vh;
|
|
margin: 0;
|
|
padding: 20px;
|
|
}
|
|
#main-container {
|
|
background-color: #ffffff;
|
|
border-radius: 10px;
|
|
padding: 30px;
|
|
width: 100%;
|
|
max-width: 800px;
|
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
|
}
|
|
h1 {
|
|
color: #333;
|
|
margin-bottom: 10px;
|
|
text-align: center;
|
|
}
|
|
.tagline {
|
|
text-align: center;
|
|
color: #666;
|
|
margin-bottom: 30px;
|
|
}
|
|
.stats-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
|
|
gap: 15px;
|
|
margin-bottom: 30px;
|
|
}
|
|
.stat-card {
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
color: white;
|
|
padding: 20px;
|
|
border-radius: 8px;
|
|
text-align: center;
|
|
}
|
|
.stat-number {
|
|
font-size: 32px;
|
|
font-weight: bold;
|
|
margin-bottom: 5px;
|
|
}
|
|
.stat-label {
|
|
font-size: 14px;
|
|
opacity: 0.9;
|
|
}
|
|
#join-section {
|
|
background-color: #f9f9f9;
|
|
border-radius: 8px;
|
|
padding: 25px;
|
|
margin-bottom: 20px;
|
|
}
|
|
#join-section h2 {
|
|
margin-top: 0;
|
|
color: #333;
|
|
}
|
|
#join-room-form {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 10px;
|
|
}
|
|
input[type="text"] {
|
|
width: 100%;
|
|
border: 2px solid #e1e1e1;
|
|
border-radius: 5px;
|
|
padding: 12px;
|
|
font-size: 16px;
|
|
box-sizing: border-box;
|
|
}
|
|
input[type="text"]:focus {
|
|
outline: none;
|
|
border-color: #667eea;
|
|
}
|
|
.room-type-selector {
|
|
display: flex;
|
|
gap: 20px;
|
|
align-items: center;
|
|
padding: 10px 0;
|
|
}
|
|
.room-type-selector label {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 5px;
|
|
cursor: pointer;
|
|
font-size: 16px;
|
|
}
|
|
.room-type-selector input[type="radio"] {
|
|
width: auto;
|
|
cursor: pointer;
|
|
}
|
|
button {
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
color: white;
|
|
border: none;
|
|
border-radius: 5px;
|
|
padding: 12px;
|
|
font-size: 16px;
|
|
cursor: pointer;
|
|
transition: transform 0.2s;
|
|
}
|
|
button:hover {
|
|
transform: translateY(-2px);
|
|
}
|
|
.auth-status {
|
|
text-align: center;
|
|
padding: 15px;
|
|
background: #e7f3ff;
|
|
border-radius: 8px;
|
|
margin-bottom: 20px;
|
|
}
|
|
.auth-status.logged-in {
|
|
background: #d4edda;
|
|
}
|
|
.browse-link {
|
|
text-align: center;
|
|
margin-top: 20px;
|
|
}
|
|
.browse-link a {
|
|
color: #667eea;
|
|
text-decoration: none;
|
|
font-weight: bold;
|
|
}
|
|
.browse-link a:hover {
|
|
text-decoration: underline;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div id="main-container">
|
|
<h1>🚀 OpenCompletion</h1>
|
|
<p class="tagline">Machine Learning Powered Collaboration</p>
|
|
|
|
<!-- Statistics -->
|
|
<div class="stats-grid">
|
|
<div class="stat-card">
|
|
<div class="stat-number">{{ stats.total_public_rooms }}</div>
|
|
<div class="stat-label">Public Rooms</div>
|
|
</div>
|
|
{% if user %}
|
|
<div class="stat-card">
|
|
<div class="stat-number">{{ stats.total_private_rooms }}</div>
|
|
<div class="stat-label">Private Rooms</div>
|
|
</div>
|
|
{% endif %}
|
|
<div class="stat-card">
|
|
<div class="stat-number">{{ stats.active_public_rooms }}</div>
|
|
<div class="stat-label">Active Rooms</div>
|
|
</div>
|
|
<div class="stat-card">
|
|
<div class="stat-number">{{ stats.active_users }}</div>
|
|
<div class="stat-label">Active Users</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Auth status -->
|
|
{% if user %}
|
|
<div class="auth-status logged-in">
|
|
✅ Signed in as <strong>{{ user.display_name }}</strong> ({{ user.email }})
|
|
<div style="margin-top: 10px;">
|
|
<a href="/profile" style="color: #667eea; text-decoration: none; font-weight: bold;">⚙️ Profile Settings</a>
|
|
</div>
|
|
</div>
|
|
{% else %}
|
|
<div class="auth-status">
|
|
👋 Welcome! <a href="/auth">Sign in</a> to create private rooms
|
|
</div>
|
|
{% endif %}
|
|
|
|
<!-- Join room form -->
|
|
<div id="join-section">
|
|
<h2>Join or Create a Room</h2>
|
|
<form id="join-room-form">
|
|
<input id="room" type="text" placeholder="Enter room name" required>
|
|
<div class="room-type-selector">
|
|
<label>
|
|
<input type="radio" name="room-type" value="public" checked>
|
|
🌍 Public Room
|
|
</label>
|
|
<label>
|
|
<input type="radio" name="room-type" value="private">
|
|
🔐 Private Room
|
|
</label>
|
|
</div>
|
|
<button type="submit">Create/Join Room</button>
|
|
</form>
|
|
</div>
|
|
|
|
<div class="browse-link">
|
|
<a href="/browse">Or browse existing rooms →</a>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
document.getElementById('join-room-form').addEventListener('submit', async function(e) {
|
|
e.preventDefault();
|
|
const roomInput = document.getElementById('room').value.trim();
|
|
const roomType = document.querySelector('input[name="room-type"]:checked').value;
|
|
|
|
if (!roomInput) {
|
|
alert('Please enter a room name');
|
|
return;
|
|
}
|
|
|
|
const room = slugify(roomInput);
|
|
|
|
if (!room) {
|
|
alert('Please enter a valid room name with at least some letters or numbers');
|
|
return;
|
|
}
|
|
|
|
// If private room, check authentication
|
|
if (roomType === 'private') {
|
|
{% if not user %}
|
|
alert('You must be signed in to create private rooms. Please sign in first.');
|
|
window.location.href = '/auth';
|
|
return;
|
|
{% endif %}
|
|
|
|
// Create private room via API
|
|
try {
|
|
const response = await fetch('/api/rooms/create', {
|
|
method: 'POST',
|
|
headers: {'Content-Type': 'application/json'},
|
|
body: JSON.stringify({
|
|
name: room,
|
|
is_private: true
|
|
})
|
|
});
|
|
|
|
const data = await response.json();
|
|
|
|
if (response.ok) {
|
|
window.location.href = `/chat/${data.room.name}`;
|
|
} else {
|
|
alert(data.error || 'Failed to create private room');
|
|
}
|
|
} catch (error) {
|
|
alert('Network error. Please try again.');
|
|
}
|
|
} else {
|
|
// Public room - just navigate
|
|
window.location.href = `/chat/${room}`;
|
|
}
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|
|
|