mirror of
https://github.com/fastapi-users/fastapi-users.git
synced 2026-03-13 07:49:55 +08:00
fix documentation tokenUrl (#210)
* fix documentation tokenUrl * Change default login tokenUrl
This commit is contained in:
@@ -40,7 +40,7 @@ def on_after_forgot_password(user: UserDB, token: str, request: Request):
|
||||
print(f"User {user.id} has forgot their password. Reset token: {token}")
|
||||
|
||||
|
||||
jwt_authentication = JWTAuthentication(secret=SECRET, lifetime_seconds=3600)
|
||||
jwt_authentication = JWTAuthentication(secret=SECRET, lifetime_seconds=3600, tokenUrl='/auth/jwt/login')
|
||||
|
||||
app = FastAPI()
|
||||
fastapi_users = FastAPIUsers(
|
||||
|
||||
@@ -51,7 +51,7 @@ def on_after_forgot_password(user: UserDB, token: str, request: Request):
|
||||
print(f"User {user.id} has forgot their password. Reset token: {token}")
|
||||
|
||||
|
||||
jwt_authentication = JWTAuthentication(secret=SECRET, lifetime_seconds=3600)
|
||||
jwt_authentication = JWTAuthentication(secret=SECRET, lifetime_seconds=3600, tokenUrl='/auth/jwt/login')
|
||||
|
||||
app = FastAPI()
|
||||
fastapi_users = FastAPIUsers(
|
||||
|
||||
@@ -41,7 +41,7 @@ def on_after_forgot_password(user: UserDB, token: str, request: Request):
|
||||
print(f"User {user.id} has forgot their password. Reset token: {token}")
|
||||
|
||||
|
||||
jwt_authentication = JWTAuthentication(secret=SECRET, lifetime_seconds=3600)
|
||||
jwt_authentication = JWTAuthentication(secret=SECRET, lifetime_seconds=3600, tokenUrl='/auth/jwt/login')
|
||||
|
||||
fastapi_users = FastAPIUsers(
|
||||
user_db, [jwt_authentication], User, UserCreate, UserUpdate, UserDB,
|
||||
|
||||
@@ -44,7 +44,7 @@ def on_after_forgot_password(user: UserDB, token: str, request: Request):
|
||||
print(f"User {user.id} has forgot their password. Reset token: {token}")
|
||||
|
||||
|
||||
jwt_authentication = JWTAuthentication(secret=SECRET, lifetime_seconds=3600)
|
||||
jwt_authentication = JWTAuthentication(secret=SECRET, lifetime_seconds=3600, tokenUrl='/auth/jwt/login')
|
||||
|
||||
app = FastAPI()
|
||||
fastapi_users = FastAPIUsers(
|
||||
|
||||
@@ -64,7 +64,7 @@ def on_after_forgot_password(user: UserDB, token: str, request: Request):
|
||||
print(f"User {user.id} has forgot their password. Reset token: {token}")
|
||||
|
||||
|
||||
jwt_authentication = JWTAuthentication(secret=SECRET, lifetime_seconds=3600)
|
||||
jwt_authentication = JWTAuthentication(secret=SECRET, lifetime_seconds=3600, tokenUrl='/auth/jwt/login')
|
||||
|
||||
app = FastAPI()
|
||||
fastapi_users = FastAPIUsers(
|
||||
|
||||
@@ -54,7 +54,7 @@ def on_after_forgot_password(user: UserDB, token: str, request: Request):
|
||||
print(f"User {user.id} has forgot their password. Reset token: {token}")
|
||||
|
||||
|
||||
jwt_authentication = JWTAuthentication(secret=SECRET, lifetime_seconds=3600)
|
||||
jwt_authentication = JWTAuthentication(secret=SECRET, lifetime_seconds=3600, tokenUrl='/auth/jwt/login')
|
||||
|
||||
fastapi_users = FastAPIUsers(
|
||||
user_db, [jwt_authentication], User, UserCreate, UserUpdate, UserDB,
|
||||
|
||||
@@ -30,7 +30,7 @@ class JWTAuthentication(BaseAuthentication[str]):
|
||||
self,
|
||||
secret: str,
|
||||
lifetime_seconds: int,
|
||||
tokenUrl: str = "/users/login",
|
||||
tokenUrl: str = "/login",
|
||||
name: str = "jwt",
|
||||
):
|
||||
super().__init__(name, logout=False)
|
||||
|
||||
@@ -229,7 +229,7 @@ def mock_user_db_oauth(
|
||||
class MockAuthentication(BaseAuthentication[str]):
|
||||
def __init__(self, name: str = "mock"):
|
||||
super().__init__(name, logout=True)
|
||||
self.scheme = OAuth2PasswordBearer("/users/login", auto_error=False)
|
||||
self.scheme = OAuth2PasswordBearer("/login", auto_error=False)
|
||||
|
||||
async def __call__(self, credentials: Optional[str], user_db: BaseUserDatabase):
|
||||
if credentials is not None:
|
||||
|
||||
Reference in New Issue
Block a user