This repository has been archived on 2026-03-15. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
cau-praktikum/app/models/user.py
T

16 lines
494 B
Python

from typing import Optional
from app.db import get_db
from flask_login import UserMixin
class User(UserMixin):
def __init__(self, id: int, username: str ):
self.id: int = id
self.username: str = username
@staticmethod
def get(user_id: int | str) -> Optional["User"]:
db = get_db()
user = db.execute("SELECT * FROM users WHERE id = ?", (user_id,)).fetchone()
if user:
return User(user["id"], user["username"])
return None