mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-08-03 04:25:24 +02:00
fix: Prevent login via credentials when Auth Method is Mealie (#4370)
This commit is contained in:
parent
03485ecc73
commit
80caa5ffaf
4 changed files with 47 additions and 7 deletions
|
@ -0,0 +1,23 @@
|
|||
from mealie.core.security.providers.credentials_provider import CredentialsProvider
|
||||
from mealie.db.models.users.users import AuthMethod
|
||||
from mealie.schema.user.auth import CredentialsRequest
|
||||
from tests.utils.fixture_schemas import TestUser
|
||||
|
||||
|
||||
def test_login(unique_user: TestUser):
|
||||
data = {"username": unique_user.username, "password": unique_user.password}
|
||||
auth_provider = CredentialsProvider(unique_user.repos.session, CredentialsRequest(**data))
|
||||
|
||||
assert auth_provider.authenticate() is not None
|
||||
|
||||
|
||||
def test_login_incorrect_auth_method(unique_user: TestUser):
|
||||
db = unique_user.repos
|
||||
user = db.users.get_by_username(unique_user.username)
|
||||
user.auth_method = AuthMethod.OIDC
|
||||
db.users.update(unique_user.user_id, user)
|
||||
|
||||
data = {"username": unique_user.username, "password": unique_user.password}
|
||||
auth_provider = CredentialsProvider(db.session, CredentialsRequest(**data))
|
||||
|
||||
assert auth_provider.authenticate() is None
|
Loading…
Add table
Add a link
Reference in a new issue