Select Git revision
-
Chloé Lallemand authoredChloé Lallemand authored
hooks.ts 1.37 KiB
import type { GetSession } from "@sveltejs/kit"
import config from "$lib/server/config"
import { oauth2Authenticator } from "$lib/server/oauth2"
const { githubPersonalAccessToken, openfiscaRepository } = config
export const getSession: GetSession = async (event): Promise<App.Session> => {
const oauth2Session = await oauth2Authenticator?.getSession(event)
const user = oauth2Session?.user
return {
advanced: config.advanced,
apiBaseUrls: config.apiBaseUrls,
apiWebSocketBaseUrls: config.apiWebSocketBaseUrls,
authenticationEnabled: oauth2Authenticator !== undefined,
baseUrl: config.baseUrl,
childrenKey: config.childrenKey,
familyEntityKey: config.familyEntityKey,
hasGithubPersonalAccessToken: githubPersonalAccessToken !== undefined,
hiddenEntitiesKeyPlural: config.hiddenEntitiesKeyPlural,
householdEntityKey: config.householdEntityKey,
matomo: config.matomo,
openfiscaRepository: {
branch: openfiscaRepository.branch,
group: openfiscaRepository.group,
project: openfiscaRepository.project,
rawUrlTemplate: openfiscaRepository.rawUrlTemplate,
urlTemplate: openfiscaRepository.urlTemplate,
},
portalUrl: config.portalUrl,
reformName: config.reformName,
showTutorial: config.showTutorial,
taxableHouseholdEntityKey: config.taxableHouseholdEntityKey,
title: config.title,
user,
}
}