Files
windmill/frontend/src/lib/user.ts
T
Ruben Fiszel 57ed0f77e1 fix(frontend): hide the fork workspace banner from operators (#10575)
* fix(frontend): hide the fork workspace banner from operators

* fix(frontend): scope the operator gate to the workspace its role was fetched for

* fix(frontend): drop superseded whoami responses instead of writing a stale role

* fix(frontend): guard the remaining workspace-switch userStore writers
2026-08-06 19:04:41 +02:00

25 lines
721 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, workspace)
} catch (error) {
return undefined
}
}
function mapUserToUserExt(user: User, workspace: string): UserExt {
const ext: UserExt = {
...user,
workspace_id: workspace,
groups: user.groups!,
pgroups: user.groups!.map((x) => `g/${x}`)
}
if (ext.is_service_account && sessionStorage.getItem('pre_impersonation_token')) {
ext.impersonating_email = sessionStorage.getItem('pre_impersonation_email') ?? undefined
}
return ext
}