mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-07-25 08:09:41 +02:00
Feature: Add "Authentication Method" to allow existing users to sign in with LDAP (#2143)
* adds authentication method for users * fix db migration with postgres * tests for auth method * update migration ids * hide auth method on user creation form * (docs): Added documentation for the new authentication method * update migration * add to auto-form instead of having hidden fields
This commit is contained in:
parent
39012adcc1
commit
2e6ad5da8e
24 changed files with 213 additions and 24 deletions
|
@ -4,6 +4,7 @@ import pytest
|
|||
from fastapi.testclient import TestClient
|
||||
|
||||
from mealie.db.db_setup import session_context
|
||||
from mealie.schema.user.user import PrivateUser
|
||||
from mealie.services.user_services.password_reset_service import PasswordResetService
|
||||
from tests.utils import api_routes
|
||||
from tests.utils.factories import random_string
|
||||
|
@ -56,3 +57,24 @@ def test_password_reset(api_client: TestClient, unique_user: TestUser, casing: s
|
|||
# Test successful password reset
|
||||
response = api_client.post(api_routes.users_reset_password, json=payload)
|
||||
assert response.status_code == 400
|
||||
|
||||
|
||||
@pytest.mark.parametrize("casing", ["lower", "upper", "mixed"])
|
||||
def test_password_reset_ldap(ldap_user: PrivateUser, casing: str):
|
||||
cased_email = ""
|
||||
if casing == "lower":
|
||||
cased_email = ldap_user.email.lower()
|
||||
elif casing == "upper":
|
||||
cased_email = ldap_user.email.upper()
|
||||
else:
|
||||
for i, letter in enumerate(ldap_user.email):
|
||||
if i % 2 == 0:
|
||||
cased_email += letter.upper()
|
||||
else:
|
||||
cased_email += letter.lower()
|
||||
cased_email
|
||||
|
||||
with session_context() as session:
|
||||
service = PasswordResetService(session)
|
||||
token = service.generate_reset_token(cased_email)
|
||||
assert token is None
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue