Skip to content

Commit 98498ca

Browse files
committed
Fix search user UI
1 parent 2c2dcc9 commit 98498ca

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

src/server/control/admin-users.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,24 @@
11
import { UserModel, DataModel, TokenModel } from '../models/db'
22
import { User } from '../models/user-model'
33

4+
function formatUser (user: User): Object {
5+
return {
6+
id: user.id,
7+
name: user.name,
8+
tokenLimit: user.tokenLimit,
9+
tokensCount: user.tokenIds.split(',').length,
10+
email: user.email,
11+
githubLogin: user.githubLogin,
12+
avatarUrl: user.avatarUrl,
13+
status: user.status
14+
}
15+
}
16+
417
export async function listUsers (start: string, limit: number, id: string): Promise<Object> {
518
if (id !== '') {
619
const user = await UserModel.get(id)
720
return {
8-
user
21+
user: formatUser(user)
922
}
1023
}
1124
const users = start === ''
@@ -22,16 +35,7 @@ export async function listUsers (start: string, limit: number, id: string): Prom
2235
.exec()
2336
return {
2437
users: users.map((user: User) => {
25-
return {
26-
id: user.id,
27-
name: user.name,
28-
tokenLimit: user.tokenLimit,
29-
tokensCount: user.tokenIds.split(',').length,
30-
email: user.email,
31-
githubLogin: user.githubLogin,
32-
avatarUrl: user.avatarUrl,
33-
status: user.status
34-
}
38+
return formatUser(user)
3539
}),
3640
count: users.count,
3741
lastKey: users.lastKey

0 commit comments

Comments
 (0)