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

Function get

pages/mfa-verify.tsx:22–61  ·  view source on GitHub ↗
({ request, match, session, isRunningLocally }: RequestHandlerParams)

Source from the content-addressed store, hash-verified

20const titlePrefix = 'Multi-Factor Authentication Verification';
21
22async function get({ request, match, session, isRunningLocally }: RequestHandlerParams) {
23 const isMultiFactorAuthEnabled = await AppConfig.isMultiFactorAuthEnabled();
24
25 if (!isMultiFactorAuthEnabled) {
26 return new Response('Redirect', { status: 303, headers: { 'Location': '/login' } });
27 }
28
29 const searchParams = new URL(request.url).searchParams;
30 const redirectUrl = searchParams.get('redirect') || '/';
31
32 const { user } = (await MultiFactorAuthModel.getDataFromRequest(request)) || {};
33
34 if (!user) {
35 return new Response('Redirect', { status: 303, headers: { 'Location': '/login' } });
36 }
37
38 const hasMultiFactorAuthEnabled = isMultiFactorAuthEnabledForUser(user);
39
40 if (!hasMultiFactorAuthEnabled) {
41 return new Response('Redirect', { status: 303, headers: { 'Location': '/login' } });
42 }
43
44 const enabledMethods = getEnabledMultiFactorAuthMethodsFromUser(user);
45 const availableMethods = enabledMethods.map((method) => method.type);
46
47 const htmlContent = defaultHtmlContent({
48 email: user.email,
49 redirectUrl,
50 availableMethods,
51 });
52
53 return basicLayoutResponse(htmlContent, {
54 currentPath: match.pathname.input,
55 titlePrefix,
56 match,
57 request,
58 session,
59 isRunningLocally,
60 });
61}
62
63async function post({ request, match, session, isRunningLocally }: RequestHandlerParams) {
64 const isMultiFactorAuthEnabled = await AppConfig.isMultiFactorAuthEnabled();

Callers

nothing calls this directly

Calls 7

basicLayoutResponseFunction · 0.90
defaultHtmlContentFunction · 0.70
getMethod · 0.45
getDataFromRequestMethod · 0.45

Tested by

no test coverage detected