mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-15 19:37:47 +01:00
enh: display user groups in user preview
This commit is contained in:
@@ -391,6 +391,7 @@ async def update_user_info_by_session_user(
|
||||
class UserActiveResponse(UserStatus):
|
||||
name: str
|
||||
profile_image_url: Optional[str] = None
|
||||
groups: Optional[list] = []
|
||||
|
||||
is_active: bool
|
||||
model_config = ConfigDict(extra="allow")
|
||||
@@ -412,11 +413,12 @@ async def get_user_by_id(user_id: str, user=Depends(get_verified_user)):
|
||||
)
|
||||
|
||||
user = Users.get_user_by_id(user_id)
|
||||
|
||||
if user:
|
||||
groups = Groups.get_groups_by_member_id(user_id)
|
||||
return UserActiveResponse(
|
||||
**{
|
||||
**user.model_dump(),
|
||||
"groups": [{"id": group.id, "name": group.name} for group in groups],
|
||||
"is_active": Users.is_user_active(user_id),
|
||||
}
|
||||
)
|
||||
|
||||
@@ -102,6 +102,18 @@
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if (user?.groups ?? []).length > 0}
|
||||
<div class="mx-3.5 mt-2 flex gap-0.5">
|
||||
{#each user.groups as group}
|
||||
<div
|
||||
class="px-1.5 py-0.5 rounded-lg bg-gray-50 dark:text-white dark:bg-gray-900/50 text-black transition text-xs"
|
||||
>
|
||||
{group.name}
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if $_user?.id !== user.id}
|
||||
<hr class="border-gray-100/50 dark:border-gray-800/50 my-2.5" />
|
||||
|
||||
|
||||
Reference in New Issue
Block a user