* 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>
394 lines
12 KiB
HTML
394 lines
12 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Profile Settings - OpenCompletion</title>
|
|
<link rel="icon" href="{{ url_for('static', filename='favicon.ico') }}">
|
|
<style>
|
|
:root {
|
|
--bg-primary: #ffffff;
|
|
--bg-secondary: #f7f7f7;
|
|
--bg-tertiary: #e1e1e1;
|
|
--text-primary: #333333;
|
|
--text-secondary: #666666;
|
|
--border-color: #e1e1e1;
|
|
--button-primary: #667eea;
|
|
--button-hover: #764ba2;
|
|
--input-bg: #ffffff;
|
|
--input-border: #e1e1e1;
|
|
--success-color: #28a745;
|
|
--error-color: #dc3545;
|
|
}
|
|
|
|
[data-theme="dark"] {
|
|
--bg-primary: #1a1a1a;
|
|
--bg-secondary: #2d2d2d;
|
|
--bg-tertiary: #3d3d3d;
|
|
--text-primary: #e1e1e1;
|
|
--text-secondary: #a0a0a0;
|
|
--border-color: #3d3d3d;
|
|
--button-primary: #667eea;
|
|
--button-hover: #764ba2;
|
|
--input-bg: #2d2d2d;
|
|
--input-border: #3d3d3d;
|
|
--success-color: #28a745;
|
|
--error-color: #dc3545;
|
|
}
|
|
|
|
body {
|
|
font-family: Arial, sans-serif;
|
|
background-color: var(--bg-secondary);
|
|
color: var(--text-primary);
|
|
display: flex;
|
|
flex-direction: column;
|
|
justify-content: center;
|
|
align-items: center;
|
|
min-height: 100vh;
|
|
margin: 0;
|
|
padding: 20px;
|
|
transition: background-color 0.3s, color 0.3s;
|
|
}
|
|
|
|
#main-container {
|
|
background-color: var(--bg-primary);
|
|
border-radius: 10px;
|
|
padding: 30px;
|
|
width: 100%;
|
|
max-width: 600px;
|
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
|
}
|
|
|
|
h1 {
|
|
color: var(--text-primary);
|
|
margin-bottom: 10px;
|
|
text-align: center;
|
|
}
|
|
|
|
.subtitle {
|
|
text-align: center;
|
|
color: var(--text-secondary);
|
|
margin-bottom: 30px;
|
|
}
|
|
|
|
.section {
|
|
background-color: var(--bg-secondary);
|
|
border-radius: 8px;
|
|
padding: 25px;
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
.section h2 {
|
|
margin-top: 0;
|
|
color: var(--text-primary);
|
|
font-size: 18px;
|
|
margin-bottom: 15px;
|
|
}
|
|
|
|
.form-group {
|
|
margin-bottom: 15px;
|
|
}
|
|
|
|
label {
|
|
display: block;
|
|
margin-bottom: 5px;
|
|
color: var(--text-secondary);
|
|
font-size: 14px;
|
|
}
|
|
|
|
input[type="text"] {
|
|
width: 100%;
|
|
border: 2px solid var(--input-border);
|
|
border-radius: 5px;
|
|
padding: 12px;
|
|
font-size: 16px;
|
|
box-sizing: border-box;
|
|
background-color: var(--input-bg);
|
|
color: var(--text-primary);
|
|
transition: border-color 0.3s;
|
|
}
|
|
|
|
input[type="text"]:focus {
|
|
outline: none;
|
|
border-color: var(--button-primary);
|
|
}
|
|
|
|
.availability-indicator {
|
|
font-size: 14px;
|
|
margin-top: 5px;
|
|
min-height: 20px;
|
|
}
|
|
|
|
.available {
|
|
color: var(--success-color);
|
|
}
|
|
|
|
.unavailable {
|
|
color: var(--error-color);
|
|
}
|
|
|
|
.current-value {
|
|
background-color: var(--bg-tertiary);
|
|
padding: 10px;
|
|
border-radius: 5px;
|
|
margin-bottom: 15px;
|
|
font-size: 14px;
|
|
}
|
|
|
|
.current-value strong {
|
|
color: var(--text-primary);
|
|
}
|
|
|
|
button {
|
|
background: linear-gradient(135deg, var(--button-primary) 0%, var(--button-hover) 100%);
|
|
color: white;
|
|
border: none;
|
|
border-radius: 5px;
|
|
padding: 12px 24px;
|
|
font-size: 16px;
|
|
cursor: pointer;
|
|
transition: transform 0.2s;
|
|
width: 100%;
|
|
}
|
|
|
|
button:hover {
|
|
transform: translateY(-2px);
|
|
}
|
|
|
|
button:disabled {
|
|
opacity: 0.5;
|
|
cursor: not-allowed;
|
|
transform: none;
|
|
}
|
|
|
|
.theme-selector {
|
|
display: grid;
|
|
grid-template-columns: 1fr 1fr;
|
|
gap: 10px;
|
|
}
|
|
|
|
.theme-option {
|
|
padding: 15px;
|
|
border: 2px solid var(--input-border);
|
|
border-radius: 5px;
|
|
cursor: pointer;
|
|
text-align: center;
|
|
transition: all 0.3s;
|
|
background-color: var(--input-bg);
|
|
}
|
|
|
|
.theme-option:hover {
|
|
border-color: var(--button-primary);
|
|
}
|
|
|
|
.theme-option.active {
|
|
border-color: var(--button-primary);
|
|
background-color: var(--bg-tertiary);
|
|
}
|
|
|
|
.theme-option .icon {
|
|
font-size: 32px;
|
|
margin-bottom: 5px;
|
|
}
|
|
|
|
.back-link {
|
|
text-align: center;
|
|
margin-top: 20px;
|
|
}
|
|
|
|
.back-link a {
|
|
color: var(--button-primary);
|
|
text-decoration: none;
|
|
font-weight: bold;
|
|
}
|
|
|
|
.back-link a:hover {
|
|
text-decoration: underline;
|
|
}
|
|
|
|
.message {
|
|
padding: 10px;
|
|
border-radius: 5px;
|
|
margin-bottom: 15px;
|
|
display: none;
|
|
}
|
|
|
|
.message.success {
|
|
background-color: var(--success-color);
|
|
color: white;
|
|
}
|
|
|
|
.message.error {
|
|
background-color: var(--error-color);
|
|
color: white;
|
|
}
|
|
|
|
.message.show {
|
|
display: block;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div id="main-container">
|
|
<h1>Profile Settings</h1>
|
|
<p class="subtitle">Manage your account preferences</p>
|
|
|
|
<!-- Username Section -->
|
|
<div class="section">
|
|
<h2>Change Username</h2>
|
|
<div class="current-value">
|
|
Current username: <strong>{{ user.display_name }}</strong>
|
|
</div>
|
|
<div id="username-message" class="message"></div>
|
|
<form id="username-form">
|
|
<div class="form-group">
|
|
<label for="new-username">New Username</label>
|
|
<input
|
|
type="text"
|
|
id="new-username"
|
|
placeholder="Enter new username"
|
|
pattern="[a-zA-Z0-9_-]{3,50}"
|
|
title="3-50 characters (letters, numbers, underscores, hyphens only)"
|
|
required
|
|
>
|
|
<div id="availability-indicator" class="availability-indicator"></div>
|
|
</div>
|
|
<button type="submit" id="update-username-btn" disabled>Update Username</button>
|
|
</form>
|
|
</div>
|
|
|
|
<!-- Theme Section -->
|
|
<div class="section">
|
|
<h2>Appearance</h2>
|
|
<div class="theme-selector">
|
|
<div class="theme-option" data-theme="light" onclick="setTheme('light')">
|
|
<div class="icon">☀️</div>
|
|
<div>Light Mode</div>
|
|
</div>
|
|
<div class="theme-option" data-theme="dark" onclick="setTheme('dark')">
|
|
<div class="icon">🌙</div>
|
|
<div>Dark Mode</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="back-link">
|
|
<a href="/">← Back to Home</a>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
let checkTimeout;
|
|
const currentUsername = "{{ user.display_name }}";
|
|
|
|
// Theme Management
|
|
function setTheme(theme) {
|
|
document.documentElement.setAttribute('data-theme', theme);
|
|
localStorage.setItem('theme', theme);
|
|
|
|
// Update active state
|
|
document.querySelectorAll('.theme-option').forEach(option => {
|
|
option.classList.remove('active');
|
|
});
|
|
document.querySelector(`.theme-option[data-theme="${theme}"]`).classList.add('active');
|
|
}
|
|
|
|
// Load saved theme on page load
|
|
const savedTheme = localStorage.getItem('theme') || 'light';
|
|
setTheme(savedTheme);
|
|
|
|
// Username availability check
|
|
document.getElementById('new-username').addEventListener('input', function(e) {
|
|
const username = e.target.value.trim();
|
|
const indicator = document.getElementById('availability-indicator');
|
|
const submitBtn = document.getElementById('update-username-btn');
|
|
|
|
// Clear previous timeout
|
|
clearTimeout(checkTimeout);
|
|
|
|
// Reset if empty or same as current
|
|
if (!username || username === currentUsername) {
|
|
indicator.textContent = '';
|
|
submitBtn.disabled = true;
|
|
return;
|
|
}
|
|
|
|
// Validate format
|
|
const isValid = /^[a-zA-Z0-9_-]{3,50}$/.test(username);
|
|
if (!isValid) {
|
|
indicator.textContent = 'Invalid format (3-50 chars: letters, numbers, _, -)';
|
|
indicator.className = 'availability-indicator unavailable';
|
|
submitBtn.disabled = true;
|
|
return;
|
|
}
|
|
|
|
// Check availability after 500ms delay
|
|
indicator.textContent = 'Checking availability...';
|
|
indicator.className = 'availability-indicator';
|
|
|
|
checkTimeout = setTimeout(async () => {
|
|
try {
|
|
const response = await fetch(`/api/check-username?username=${encodeURIComponent(username)}`);
|
|
const data = await response.json();
|
|
|
|
if (data.available) {
|
|
indicator.textContent = '✓ Username is available';
|
|
indicator.className = 'availability-indicator available';
|
|
submitBtn.disabled = false;
|
|
} else {
|
|
indicator.textContent = '✗ Username is already taken';
|
|
indicator.className = 'availability-indicator unavailable';
|
|
submitBtn.disabled = true;
|
|
}
|
|
} catch (error) {
|
|
indicator.textContent = 'Error checking availability';
|
|
indicator.className = 'availability-indicator unavailable';
|
|
submitBtn.disabled = true;
|
|
}
|
|
}, 500);
|
|
});
|
|
|
|
// Username update form
|
|
document.getElementById('username-form').addEventListener('submit', async function(e) {
|
|
e.preventDefault();
|
|
|
|
const newUsername = document.getElementById('new-username').value.trim();
|
|
const messageDiv = document.getElementById('username-message');
|
|
const submitBtn = document.getElementById('update-username-btn');
|
|
|
|
submitBtn.disabled = true;
|
|
submitBtn.textContent = 'Updating...';
|
|
|
|
try {
|
|
const response = await fetch('/api/update-username', {
|
|
method: 'POST',
|
|
headers: {'Content-Type': 'application/json'},
|
|
body: JSON.stringify({ new_username: newUsername })
|
|
});
|
|
|
|
const data = await response.json();
|
|
|
|
if (response.ok) {
|
|
messageDiv.textContent = 'Username updated successfully! Redirecting...';
|
|
messageDiv.className = 'message success show';
|
|
|
|
// Redirect after 2 seconds
|
|
setTimeout(() => {
|
|
window.location.reload();
|
|
}, 2000);
|
|
} else {
|
|
messageDiv.textContent = data.error || 'Failed to update username';
|
|
messageDiv.className = 'message error show';
|
|
submitBtn.disabled = false;
|
|
submitBtn.textContent = 'Update Username';
|
|
}
|
|
} catch (error) {
|
|
messageDiv.textContent = 'Network error. Please try again.';
|
|
messageDiv.className = 'message error show';
|
|
submitBtn.disabled = false;
|
|
submitBtn.textContent = 'Update Username';
|
|
}
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|