Files
colibre/src/auth/models.py
T
Colin Maudry 72fd495c5b src/auth/models.py : classe User Flask-Login (#73)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-20 17:25:56 +02:00

35 lines
714 B
Python

import sqlite3
from src.auth import db
class User:
def __init__(self, row: sqlite3.Row):
self.id: int = row["id"]
self.email: str = row["email"]
self.email_verified: bool = bool(row["email_verified"])
@property
def is_authenticated(self) -> bool:
return True
@property
def is_active(self) -> bool:
return True
@property
def is_anonymous(self) -> bool:
return False
def get_id(self) -> str:
return str(self.id)
def load_user(user_id: str) -> User | None:
try:
uid = int(user_id)
except (TypeError, ValueError):
return None
row = db.get_user_by_id(uid)
return User(row) if row else None