Fixed partial handling and added cookies
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import { type RegularTagNode, type TextNode } from "@melvdouc/xml-parser";
|
||||
|
||||
export interface AppProperties {
|
||||
name: string;
|
||||
icon: string;
|
||||
@@ -6,4 +8,43 @@ export interface AppProperties {
|
||||
hint: string;
|
||||
}
|
||||
|
||||
export interface CasTagNode extends RegularTagNode {
|
||||
children: [TextNode];
|
||||
}
|
||||
|
||||
export interface CasGroupNode extends RegularTagNode {
|
||||
children: CasTagNode[];
|
||||
}
|
||||
|
||||
export interface CasResponse extends RegularTagNode {
|
||||
children: [TextNode, CasGroupNode];
|
||||
}
|
||||
|
||||
export interface CasContent {
|
||||
amuCampus: string;
|
||||
amuComposante: string;
|
||||
amuDateValidation: string;
|
||||
coGroup: string;
|
||||
eduPersonPrimaryAffiliation: string;
|
||||
eduPersonPrincipalName: string;
|
||||
mail: string;
|
||||
displayName: string;
|
||||
givenName: string;
|
||||
memberOf: string[];
|
||||
sn: string;
|
||||
supannCivilite: string;
|
||||
supannEntiteAffectation: string;
|
||||
supannEtuAnneeInscription: string;
|
||||
supannEtuEtape: string;
|
||||
uid: string;
|
||||
}
|
||||
|
||||
export interface LoginJWT {
|
||||
iss: "PolyMPR";
|
||||
iat: number;
|
||||
exp: number;
|
||||
aud: "PolyMPR";
|
||||
user: CasContent;
|
||||
}
|
||||
|
||||
export type EmptyObject = Record<string | number | symbol, never>;
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import { EmptyObject } from "$root/defaults/interfaces.ts";
|
||||
import { FreshContext } from "$fresh/server.ts";
|
||||
import { State } from "$root/routes/_middleware.ts";
|
||||
|
||||
export default function makeIndex<
|
||||
IndexProps = EmptyObject,
|
||||
>(basePath: string) {
|
||||
return async function Index(props: IndexProps) {
|
||||
export default function makeIndex(basePath: string) {
|
||||
return async function Index(
|
||||
request: Request,
|
||||
context: FreshContext<State>,
|
||||
) {
|
||||
const index = (await import(`${basePath}/partials/index.tsx`)).Index;
|
||||
return index(props);
|
||||
return index(request, context);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { JSX } from "preact";
|
||||
import { Partial } from "$fresh/runtime.ts";
|
||||
import { RouteConfig } from "$fresh/server.ts";
|
||||
import { FreshContext, RouteConfig } from "$fresh/server.ts";
|
||||
import { State } from "$root/routes/_middleware.ts";
|
||||
|
||||
export function getPartialsConfig(): RouteConfig {
|
||||
return {
|
||||
@@ -9,14 +10,19 @@ export function getPartialsConfig(): RouteConfig {
|
||||
};
|
||||
}
|
||||
|
||||
// deno-lint-ignore no-explicit-any
|
||||
export function makePartials<Props extends any>(
|
||||
page: (props: Props) => JSX.Element,
|
||||
export function makePartials(
|
||||
page: (
|
||||
request: Request,
|
||||
context: FreshContext<State>,
|
||||
) => Promise<JSX.Element>,
|
||||
) {
|
||||
return function WrappedElements(props: Props): JSX.Element {
|
||||
return async function WrappedElements(
|
||||
request: Request,
|
||||
context: FreshContext<State>,
|
||||
): Promise<JSX.Element> {
|
||||
return (
|
||||
<Partial name="body">
|
||||
{page(props)}
|
||||
{await page(request, context)}
|
||||
</Partial>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user