Skip to content

Commit

Permalink
nit
Browse files Browse the repository at this point in the history
  • Loading branch information
pablonyx committed Dec 30, 2024
1 parent 8d6e826 commit 97a03e7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
9 changes: 0 additions & 9 deletions backend/onyx/auth/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,6 @@ class UserCreate(schemas.BaseUserCreate):
tenant_id: str | None = None


class UserUpdateWithRoleForManager(schemas.BaseUserUpdate):
"""
This schema is used internally by the UserManager class when creating or updating users
that require role updates. It allows passing the role without exposing it in all default endpoints.
"""

role: UserRole


class UserUpdate(schemas.BaseUserUpdate):
"""
Role updates are not allowed through the user update endpoint for security reasons
Expand Down
5 changes: 2 additions & 3 deletions backend/onyx/auth/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
from onyx.auth.invited_users import get_invited_users
from onyx.auth.schemas import UserCreate
from onyx.auth.schemas import UserRole
from onyx.auth.schemas import UserUpdateWithRoleForManager
from onyx.auth.schemas import UserUpdate
from onyx.configs.app_configs import AUTH_TYPE
from onyx.configs.app_configs import DISABLE_AUTH
from onyx.configs.app_configs import EMAIL_CONFIGURED
Expand Down Expand Up @@ -250,9 +250,8 @@ async def create(
user = await self.get_by_email(user_create.email)
# Handle case where user has used product outside of web and is now creating an account through web
if not user.role.is_web_login() and user_create.role.is_web_login():
user_update = UserUpdateWithRoleForManager(
user_update = UserUpdate(
password=user_create.password,
role=user_create.role,
is_verified=user_create.is_verified,
)
user = await self.update(user_update, user)
Expand Down

0 comments on commit 97a03e7

Please sign in to comment.