Refactor user authentication and dashboard features
- Added `is_admin` field to User model for role management. - Updated user context middleware to include current user in templates. - Enhanced session management with improved debug middleware. - Refactored dashboard view to fetch user-specific data and recent events. - Improved login and registration templates for better user experience. - Added admin routes with access control for admin users. - Updated Docker configuration for better error logging and dependency management. - Updated requirements to include new dependencies and specify versions.
This commit is contained in:
+6
-10
@@ -1,18 +1,14 @@
|
||||
# Add is_admin field to User model if it's missing
|
||||
|
||||
from sqlalchemy import Column, Integer, String, Boolean
|
||||
# ...existing imports...
|
||||
from sqlalchemy import Column, Integer, String, Boolean, DateTime
|
||||
from sqlalchemy.sql import func
|
||||
from ..db import Base
|
||||
|
||||
class User(Base):
|
||||
__tablename__ = "users"
|
||||
|
||||
# ...existing fields...
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
username = Column(String(50), unique=True, index=True)
|
||||
email = Column(String(100), unique=True, index=True)
|
||||
password = Column(String(255))
|
||||
|
||||
# Add is_admin field if it doesn't exist
|
||||
password_hash = Column(String(255)) # Renamed from password to password_hash for clarity
|
||||
is_admin = Column(Boolean, default=False)
|
||||
|
||||
# ...existing methods...
|
||||
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
||||
updated_at = Column(DateTime(timezone=True), onupdate=func.now())
|
||||
|
||||
Reference in New Issue
Block a user