feat(user.py): add user management
This commit is contained in:
29
src/judas_server/web/user.py
Normal file
29
src/judas_server/web/user.py
Normal file
@@ -0,0 +1,29 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import flask_login
|
||||
|
||||
|
||||
class User(flask_login.UserMixin):
|
||||
"""Represents a user for authentication purposes."""
|
||||
|
||||
def __init__(self, id: str) -> None:
|
||||
super().__init__()
|
||||
self.id = id
|
||||
|
||||
def get_id(self) -> str:
|
||||
"""Return the unique identifier for the user."""
|
||||
return self.id
|
||||
|
||||
def __str__(self) -> str:
|
||||
return f"User(id={self.id})"
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f"User(id={self.id})"
|
||||
|
||||
|
||||
def load_user(user_id):
|
||||
if user_id == "admin":
|
||||
return User("admin")
|
||||
return None
|
||||
Reference in New Issue
Block a user