Define on_after_forgot_password with a decorator

This commit is contained in:
François Voron
2019-10-24 09:18:07 +02:00
parent 636dd86987
commit 008a8296f2
6 changed files with 83 additions and 59 deletions

View File

@ -35,16 +35,16 @@ class User(BaseUser):
auth = JWTAuthentication(secret=SECRET, lifetime_seconds=3600)
app = FastAPI()
fastapi_users = FastAPIUsers(user_db, auth, User, SECRET)
app.include_router(fastapi_users.router, prefix="/users", tags=["users"])
@fastapi_users.on_after_forgot_password()
def on_after_forgot_password(user, token):
print(f"User {user.id} has forgot their password. Reset token: {token}")
app = FastAPI()
fastapi_users = FastAPIUsers(user_db, auth, User, on_after_forgot_password, SECRET)
app.include_router(fastapi_users.router, prefix="/users", tags=["users"])
@app.on_event("startup")
async def startup():
await database.connect()