MCPcopy Create free account
hub / github.com/bewcloud/bewcloud / get

Function get

pages/oidc/callback.ts:8–37  ·  view source on GitHub ↗
({ request, user, match, session, isRunningLocally }: RequestHandlerParams)

Source from the content-addressed store, hash-verified

6import { escapeHtml, html } from '/public/ts/utils/misc.ts';
7
8async function get({ request, user, match, session, isRunningLocally }: RequestHandlerParams) {
9 const isSingleSignOnEnabled = await AppConfig.isSingleSignOnEnabled();
10
11 if (user || !isSingleSignOnEnabled) {
12 return new Response('Redirect', { status: 303, headers: { 'Location': `/` } });
13 }
14
15 let error = '';
16
17 try {
18 const { response } = await OidcModel.validateAndCreateSession(request);
19
20 return response;
21 } catch (validationError) {
22 console.error(validationError);
23 error = (validationError as Error).message;
24 }
25
26 const htmlContent = defaultHtmlContent({ error });
27
28 return basicLayoutResponse(htmlContent, {
29 currentPath: match.pathname.input,
30 titlePrefix: 'Login with SSO',
31 match,
32 request,
33 user,
34 session,
35 isRunningLocally,
36 });
37}
38
39function defaultHtmlContent({ error }: { error: string }) {
40 return html`

Callers

nothing calls this directly

Calls 4

basicLayoutResponseFunction · 0.90
isSingleSignOnEnabledMethod · 0.80
defaultHtmlContentFunction · 0.70

Tested by

no test coverage detected