override example password

This commit is contained in:
long2ice
2021-08-06 23:12:18 +08:00
parent 6c1e270252
commit 22ce5d7b8d
5 changed files with 96 additions and 36 deletions

View File

@@ -1,7 +1,19 @@
from fastapi import Depends, Form
from starlette.requests import Request
from fastapi_admin.depends import get_current_admin, get_resources
from fastapi_admin.models import AbstractAdmin
from fastapi_admin.providers.login import UsernamePasswordProvider
class LoginProvider(UsernamePasswordProvider):
async def update_password(self, admin: AbstractAdmin, password: str):
pass
async def password(
self,
request: Request,
old_password: str = Form(...),
new_password: str = Form(...),
re_new_password: str = Form(...),
admin: AbstractAdmin = Depends(get_current_admin),
resources=Depends(get_resources),
):
return await self.logout(request)