diff --git a/docs/src/full_mongodb.py b/docs/src/full_mongodb.py index 71233385..42eb5e70 100644 --- a/docs/src/full_mongodb.py +++ b/docs/src/full_mongodb.py @@ -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( diff --git a/docs/src/full_sqlalchemy.py b/docs/src/full_sqlalchemy.py index 2a3e21d3..b441b8bb 100644 --- a/docs/src/full_sqlalchemy.py +++ b/docs/src/full_sqlalchemy.py @@ -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( diff --git a/docs/src/full_tortoise.py b/docs/src/full_tortoise.py index 748a3ca8..8a442fb7 100644 --- a/docs/src/full_tortoise.py +++ b/docs/src/full_tortoise.py @@ -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, diff --git a/docs/src/oauth_full_mongodb.py b/docs/src/oauth_full_mongodb.py index f0d21674..fff186a3 100644 --- a/docs/src/oauth_full_mongodb.py +++ b/docs/src/oauth_full_mongodb.py @@ -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( diff --git a/docs/src/oauth_full_sqlalchemy.py b/docs/src/oauth_full_sqlalchemy.py index 60e487d7..fdd680bb 100644 --- a/docs/src/oauth_full_sqlalchemy.py +++ b/docs/src/oauth_full_sqlalchemy.py @@ -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( diff --git a/docs/src/oauth_full_tortoise.py b/docs/src/oauth_full_tortoise.py index b7cb69bf..80830740 100644 --- a/docs/src/oauth_full_tortoise.py +++ b/docs/src/oauth_full_tortoise.py @@ -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, diff --git a/fastapi_users/authentication/jwt.py b/fastapi_users/authentication/jwt.py index e238e28e..5cacf271 100644 --- a/fastapi_users/authentication/jwt.py +++ b/fastapi_users/authentication/jwt.py @@ -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) diff --git a/tests/conftest.py b/tests/conftest.py index 8d2733b9..91885064 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -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: