Skip to content

Commit

Permalink
api.user_manager: call UserManager parent with all arguments
Browse files Browse the repository at this point in the history
Rework the UserManager constructor to call the parent class with all
the arguments passed using the sandard idiom.  The arguments aren't
used in the constructor, so this makes it entirely generic, safer and
future-proof.

Signed-off-by: Guillaume Tucker <[email protected]>
  • Loading branch information
gctucker authored and JenySadadia committed Nov 16, 2023
1 parent 5111f91 commit 00b2703
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions api/user_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@
from fastapi.security import OAuth2PasswordRequestForm
from fastapi_users import BaseUserManager
from fastapi_users.db import (
BaseUserDatabase,
BeanieUserDatabase,
ObjectIDIDMixin,
)
from fastapi_users.password import PasswordHelperProtocol
from beanie import PydanticObjectId
import jinja2
from .user_models import User
Expand All @@ -28,14 +26,12 @@ class UserManager(ObjectIDIDMixin, BaseUserManager[User, PydanticObjectId]):
reset_password_token_secret = settings.secret_key
verification_token_secret = settings.secret_key

def __init__(self, user_db: BaseUserDatabase[User, PydanticObjectId],
password_helper: PasswordHelperProtocol | None = None):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self._email_sender = None
self._template_env = jinja2.Environment(
loader=jinja2.FileSystemLoader(
"./templates/")
)
super().__init__(user_db, password_helper)
loader=jinja2.FileSystemLoader("./templates/")
)

@property
def email_sender(self):
Expand Down

0 comments on commit 00b2703

Please sign in to comment.