Skip to content

Commit

Permalink
fix: username should be optional for user creation (#4595)
Browse files Browse the repository at this point in the history
RogerHYang authored Sep 12, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 5fff787 commit d73ca0c
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions integration_tests/auth/test_auth.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from collections import defaultdict
from dataclasses import replace
from datetime import datetime, timedelta, timezone
from functools import partial
from typing import (
@@ -259,6 +260,18 @@ def test_only_admin_can_create_user(
if not e:
new_user.log_in()

@pytest.mark.parametrize("role_or_user", [_ADMIN, _DEFAULT_ADMIN])
@pytest.mark.parametrize("role", list(UserRoleInput))
def test_username_is_optional(
self,
role_or_user: _RoleOrUser,
role: UserRoleInput,
_get_user: _GetUser,
_profiles: Iterator[_Profile],
) -> None:
profile = replace(next(_profiles), username=None)
_get_user(role_or_user).create_user(role, profile=profile)


class TestPatchViewer:
@pytest.mark.parametrize("role_or_user", [_MEMBER, _ADMIN, _DEFAULT_ADMIN])
2 changes: 1 addition & 1 deletion src/phoenix/server/api/mutations/user_mutations.py
Original file line number Diff line number Diff line change
@@ -91,7 +91,7 @@ async def create_user(
password_hash = await info.context.hash_password(password, salt)
user = models.User(
reset_password=True,
username=input.username,
username=input.username or None,
email=email,
auth_method=enums.AuthMethod.LOCAL.value,
password_hash=password_hash,

0 comments on commit d73ca0c

Please sign in to comment.