mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-08-07 14:35:25 +02:00
feat: auto detect first login (#2722)
* 'hide' default email and password env variables * first login API endpoint * run code-generators * frontend indicators for default username and pw * remove old env variables from docs * fix env set variable * remove password from tests
This commit is contained in:
parent
71f95ca3c6
commit
bc575ec5ae
22 changed files with 234 additions and 120 deletions
6
tests/fixtures/fixture_admin.py
vendored
6
tests/fixtures/fixture_admin.py
vendored
|
@ -10,7 +10,7 @@ from tests.utils import api_routes
|
|||
def admin_token(api_client: TestClient):
|
||||
settings = get_app_settings()
|
||||
|
||||
form_data = {"username": settings.DEFAULT_EMAIL, "password": settings.DEFAULT_PASSWORD}
|
||||
form_data = {"username": settings._DEFAULT_EMAIL, "password": settings._DEFAULT_PASSWORD}
|
||||
return utils.login(form_data, api_client)
|
||||
|
||||
|
||||
|
@ -18,7 +18,7 @@ def admin_token(api_client: TestClient):
|
|||
def admin_user(api_client: TestClient):
|
||||
settings = get_app_settings()
|
||||
|
||||
form_data = {"username": settings.DEFAULT_EMAIL, "password": settings.DEFAULT_PASSWORD}
|
||||
form_data = {"username": settings._DEFAULT_EMAIL, "password": settings._DEFAULT_PASSWORD}
|
||||
|
||||
token = utils.login(form_data, api_client)
|
||||
|
||||
|
@ -33,7 +33,7 @@ def admin_user(api_client: TestClient):
|
|||
yield utils.TestUser(
|
||||
_group_id=user_data.get("groupId"),
|
||||
user_id=user_data.get("id"),
|
||||
password=settings.DEFAULT_PASSWORD,
|
||||
password=settings._DEFAULT_PASSWORD,
|
||||
username=user_data.get("username"),
|
||||
email=user_data.get("email"),
|
||||
token=token,
|
||||
|
|
|
@ -36,7 +36,7 @@ def test_init_superuser(api_client: TestClient, admin_user: TestUser):
|
|||
assert admin_data["groupId"] == admin_user.group_id
|
||||
|
||||
assert admin_data["fullName"] == "Change Me"
|
||||
assert admin_data["email"] == settings.DEFAULT_EMAIL
|
||||
assert admin_data["email"] == settings._DEFAULT_EMAIL
|
||||
|
||||
|
||||
def test_create_user(api_client: TestClient, admin_token):
|
||||
|
@ -95,7 +95,7 @@ def test_update_other_user_as_not_admin(api_client: TestClient, unique_user: Tes
|
|||
update_data = {
|
||||
"id": unique_user.user_id,
|
||||
"fullName": "Updated Name",
|
||||
"email": settings.DEFAULT_EMAIL,
|
||||
"email": settings._DEFAULT_EMAIL,
|
||||
"group": "Home",
|
||||
"admin": True,
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ from tests.utils.fixture_schemas import TestUser
|
|||
def test_failed_login(api_client: TestClient):
|
||||
settings = get_app_settings()
|
||||
|
||||
form_data = {"username": settings.DEFAULT_EMAIL, "password": "WRONG_PASSWORD"}
|
||||
form_data = {"username": settings._DEFAULT_EMAIL, "password": "WRONG_PASSWORD"}
|
||||
response = api_client.post(api_routes.auth_token, data=form_data)
|
||||
|
||||
assert response.status_code == 401
|
||||
|
@ -23,7 +23,7 @@ def test_failed_login(api_client: TestClient):
|
|||
def test_superuser_login(api_client: TestClient, admin_token):
|
||||
settings = get_app_settings()
|
||||
|
||||
form_data = {"username": settings.DEFAULT_EMAIL, "password": settings.DEFAULT_PASSWORD}
|
||||
form_data = {"username": settings._DEFAULT_EMAIL, "password": settings._DEFAULT_PASSWORD}
|
||||
response = api_client.post(api_routes.auth_token, data=form_data)
|
||||
|
||||
assert response.status_code == 200
|
||||
|
|
|
@ -9,7 +9,6 @@ from mealie.core.settings.settings import AppSettings
|
|||
|
||||
def test_non_default_settings(monkeypatch):
|
||||
monkeypatch.setenv("DEFAULT_GROUP", "Test Group")
|
||||
monkeypatch.setenv("DEFAULT_PASSWORD", "Test Password")
|
||||
monkeypatch.setenv("API_PORT", "8000")
|
||||
monkeypatch.setenv("API_DOCS", "False")
|
||||
|
||||
|
@ -17,7 +16,6 @@ def test_non_default_settings(monkeypatch):
|
|||
app_settings = get_app_settings()
|
||||
|
||||
assert app_settings.DEFAULT_GROUP == "Test Group"
|
||||
assert app_settings.DEFAULT_PASSWORD == "Test Password"
|
||||
assert app_settings.API_PORT == 8000
|
||||
assert app_settings.API_DOCS is False
|
||||
|
||||
|
|
|
@ -45,6 +45,10 @@ admin_users_unlock = "/api/admin/users/unlock"
|
|||
"""`/api/admin/users/unlock`"""
|
||||
app_about = "/api/app/about"
|
||||
"""`/api/app/about`"""
|
||||
app_about_startup_info = "/api/app/about/startup-info"
|
||||
"""`/api/app/about/startup-info`"""
|
||||
app_about_theme = "/api/app/about/theme"
|
||||
"""`/api/app/about/theme`"""
|
||||
auth_refresh = "/api/auth/refresh"
|
||||
"""`/api/auth/refresh`"""
|
||||
auth_token = "/api/auth/token"
|
||||
|
@ -183,6 +187,8 @@ users_reset_password = "/api/users/reset-password"
|
|||
"""`/api/users/reset-password`"""
|
||||
users_self = "/api/users/self"
|
||||
"""`/api/users/self`"""
|
||||
users_self_group = "/api/users/self/group"
|
||||
"""`/api/users/self/group`"""
|
||||
utils_download = "/api/utils/download"
|
||||
"""`/api/utils/download`"""
|
||||
validators_group = "/api/validators/group"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue