Changed the type hint of the "current_user" pseudo property of the AbstractUserUtils class to return None when the user has not logged in.
This commit is contained in:
parent
dc24af1db0
commit
31dc8fab04
@ -50,10 +50,11 @@ class AbstractUserUtils(t.Generic[T], ABC):
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def current_user(self) -> T:
|
||||
"""Returns the current user.
|
||||
def current_user(self) -> T | None:
|
||||
"""Returns the currently logged-in user.
|
||||
|
||||
:return: The current user.
|
||||
:return: The currently logged-in user, or None if the user has not
|
||||
logged in
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
@ -117,7 +118,7 @@ def get_user_pk(username: str) -> int:
|
||||
return __user_utils.get_pk(__user_utils.get_by_username(username))
|
||||
|
||||
|
||||
def get_current_user() -> user_cls:
|
||||
def get_current_user() -> user_cls | None:
|
||||
"""Returns the currently logged-in user. The result is cached in the
|
||||
current request.
|
||||
|
||||
|
@ -80,7 +80,7 @@ def create_app(is_testing: bool = False) -> Flask:
|
||||
return auth.User.id
|
||||
|
||||
@property
|
||||
def current_user(self) -> auth.User:
|
||||
def current_user(self) -> auth.User | None:
|
||||
return auth.current_user()
|
||||
|
||||
def get_by_username(self, username: str) -> auth.User | None:
|
||||
|
Loading…
Reference in New Issue
Block a user