Skip to content

Commit 1de68dd

Browse files
author
Kerwin
committed
chore: show user role (Close #302)
1 parent d1f1844 commit 1de68dd

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

service/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ router.post('/session', async (req, res) => {
575575
key: string
576576
value: string
577577
}[] = []
578-
let userInfo: { name: string; description: string; avatar: string; userId: string; root: boolean; config: UserConfig }
578+
let userInfo: { name: string; description: string; avatar: string; userId: string; root: boolean; roles: UserRole[]; config: UserConfig }
579579
if (userId != null) {
580580
const user = await getUserById(userId)
581581
userInfo = {
@@ -584,6 +584,7 @@ router.post('/session', async (req, res) => {
584584
avatar: user.avatar,
585585
userId: user._id.toString(),
586586
root: user.roles.includes(UserRole.Admin),
587+
roles: user.roles,
587588
config: user.config,
588589
}
589590

src/components/common/UserAvatar/index.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script setup lang='ts'>
22
import { computed, onMounted, ref } from 'vue'
3-
import { NAvatar, NButton } from 'naive-ui'
3+
import { NAvatar, NButton, NTag } from 'naive-ui'
44
import { useRoute } from 'vue-router'
55
import { useAuthStore, useUserStore } from '@/store'
66
import defaultAvatar from '@/assets/avatar.jpg'
@@ -41,8 +41,11 @@ onMounted(async () => {
4141
</template>
4242
</div>
4343
<div class="flex-1 min-w-0 ml-2">
44-
<h2 v-if="userInfo.name" class="overflow-hidden font-bold text-md text-ellipsis whitespace-nowrap">
44+
<h2 v-if="userInfo.name" class="">
4545
{{ userInfo.name }}
46+
<NTag size="small" :bordered="false" type="success">
47+
Admin
48+
</NTag>
4649
</h2>
4750
<p v-if="userInfo.name" class="overflow-hidden text-xs text-gray-500 text-ellipsis whitespace-nowrap">
4851
<span

0 commit comments

Comments
 (0)