Files
windmill/frontend/src/lib/user.ts
2023-05-23 12:32:20 +02:00

20 lines
460 B
TypeScript

import { type User, UserService } from '$lib/gen'
import type { UserExt } from './stores.js'
export async function getUserExt(workspace: string): Promise<UserExt | undefined> {
try {
const user = await UserService.whoami({ workspace })
return mapUserToUserExt(user)
} catch (error) {
return undefined
}
}
function mapUserToUserExt(user: User): UserExt {
return {
...user,
groups: user.groups!,
pgroups: user.groups!.map((x) => `g/${x}`)
}
}