Implement complete user authentication system

- Configured Flask-Login with user_loader
- Added register, login, logout routes with proper validation
- Created login.html and register.html templates with auth forms
- Updated base.html navigation to show username and conditional menu
- Added auth page styling to style.css
- Protected all routes with @login_required decorator
- Updated all routes to filter by current_user.id
- Added user ownership validation for:
  - Channels (can only view/refresh own channels)
  - Videos (can only watch/download own videos)
  - Streams (can only stream videos from own channels)
- Updated save_to_db() calls to pass current_user.id
- Improved user_loader to properly handle session management

Features:
- User registration with password confirmation
- Secure password hashing with bcrypt
- Login with "remember me" functionality
- Flash messages for all auth actions
- Redirect to requested page after login
- User-specific data isolation (multi-tenant)

Security:
- All sensitive routes require authentication
- Users can only access their own data
- Passwords hashed with bcrypt salt
- Session-based authentication via Flask-Login

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-26 14:29:31 -05:00
parent 403d65e4ea
commit 1a4413ae1a
8 changed files with 445 additions and 146 deletions

View File

@@ -70,6 +70,17 @@ body {
background-color: var(--border-color);
}
.nav-user {
display: flex;
align-items: center;
gap: 1rem;
}
.nav-user span {
color: var(--text-primary);
font-weight: 500;
}
/* Container */
.container {
max-width: 1400px;
@@ -528,6 +539,80 @@ body {
color: var(--primary-color);
}
/* Auth Pages */
.auth-page {
display: flex;
justify-content: center;
align-items: center;
min-height: calc(100vh - 200px);
padding: 2rem;
}
.auth-container {
max-width: 450px;
width: 100%;
background-color: var(--card-background);
padding: 3rem;
border-radius: 8px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}
.auth-container h2 {
margin-bottom: 0.5rem;
text-align: center;
}
.auth-subtitle {
text-align: center;
color: var(--text-secondary);
margin-bottom: 2rem;
}
.auth-form {
margin-bottom: 1.5rem;
}
.checkbox-group {
display: flex;
align-items: center;
}
.checkbox-label {
display: flex;
align-items: center;
cursor: pointer;
color: var(--text-secondary);
}
.checkbox-label input[type="checkbox"] {
margin-right: 0.5rem;
cursor: pointer;
}
.btn-block {
width: 100%;
}
.auth-footer {
text-align: center;
padding-top: 1.5rem;
border-top: 1px solid var(--border-color);
}
.auth-footer p {
color: var(--text-secondary);
margin: 0;
}
.auth-footer a {
color: var(--primary-color);
text-decoration: none;
}
.auth-footer a:hover {
text-decoration: underline;
}
/* Footer */
.footer {
background-color: var(--secondary-color);