Fix global self response type
This commit is contained in:
parent
bffdc95305
commit
97970043f1
|
@ -84,15 +84,15 @@ export async function fetchAPIKey(ctx: UserCtx<void, FetchAPIKeyResponse>) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the attributes that are session based to the current user.
|
*
|
||||||
*/
|
*/
|
||||||
const addSessionAttributesToUser = (ctx: any) => {
|
const getUserSessionAttributes = (ctx: any) => ({
|
||||||
ctx.body.account = ctx.user.account
|
account: ctx.user.account,
|
||||||
ctx.body.license = ctx.user.license
|
license: ctx.user.license,
|
||||||
ctx.body.budibaseAccess = !!ctx.user.budibaseAccess
|
budibaseAccess: !!ctx.user.budibaseAccess,
|
||||||
ctx.body.accountPortalAccess = !!ctx.user.accountPortalAccess
|
accountPortalAccess: !!ctx.user.accountPortalAccess,
|
||||||
ctx.body.csrfToken = ctx.user.csrfToken
|
csrfToken: ctx.user.csrfToken,
|
||||||
}
|
})
|
||||||
|
|
||||||
export async function getSelf(ctx: UserCtx<void, GetGlobalSelfResponse>) {
|
export async function getSelf(ctx: UserCtx<void, GetGlobalSelfResponse>) {
|
||||||
if (!ctx.user) {
|
if (!ctx.user) {
|
||||||
|
@ -108,13 +108,19 @@ export async function getSelf(ctx: UserCtx<void, GetGlobalSelfResponse>) {
|
||||||
|
|
||||||
// get the main body of the user
|
// get the main body of the user
|
||||||
const user = await userSdk.db.getUser(userId)
|
const user = await userSdk.db.getUser(userId)
|
||||||
ctx.body = await groups.enrichUserRolesFromGroups(user)
|
const enrichedUser = await groups.enrichUserRolesFromGroups(user)
|
||||||
|
|
||||||
|
// add the attributes that are session based to the current user
|
||||||
|
const sessionAttributes = getUserSessionAttributes(ctx)
|
||||||
|
|
||||||
// add the feature flags for this tenant
|
// add the feature flags for this tenant
|
||||||
const flags = await features.flags.fetch()
|
const flags = await features.flags.fetch()
|
||||||
ctx.body.flags = flags
|
|
||||||
|
|
||||||
addSessionAttributesToUser(ctx)
|
ctx.body = {
|
||||||
|
...enrichedUser,
|
||||||
|
...sessionAttributes,
|
||||||
|
flags,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const syncAppFavourites = async (processedAppIds: string[]) => {
|
export const syncAppFavourites = async (processedAppIds: string[]) => {
|
||||||
|
|
Loading…
Reference in New Issue