mirror of
https://github.com/fastapi-users/fastapi-users.git
synced 2026-03-13 07:49:55 +08:00
Implement logout route
This commit is contained in:
@@ -28,3 +28,6 @@ class BaseAuthentication:
|
||||
|
||||
async def get_login_response(self, user: BaseUserDB, response: Response) -> Any:
|
||||
raise NotImplementedError()
|
||||
|
||||
async def get_logout_response(self, user: BaseUserDB, response: Response) -> Any:
|
||||
raise NotImplementedError()
|
||||
|
||||
@@ -67,5 +67,10 @@ class CookieAuthentication(JWTAuthentication):
|
||||
# so that FastAPI can terminate it properly
|
||||
return None
|
||||
|
||||
async def get_logout_response(self, user: BaseUserDB, response: Response) -> Any:
|
||||
response.delete_cookie(
|
||||
self.cookie_name, path=self.cookie_path, domain=self.cookie_domain
|
||||
)
|
||||
|
||||
async def _retrieve_token(self, request: Request) -> Optional[str]:
|
||||
return await self.api_key_cookie.__call__(request)
|
||||
|
||||
Reference in New Issue
Block a user