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

Function get

pages/login.tsx:19–72  ·  view source on GitHub ↗
({ request, match, user, session, isRunningLocally }: RequestHandlerParams)

Source from the content-addressed store, hash-verified

17const description = 'Login to your account';
18
19async function get({ request, match, user, session, isRunningLocally }: RequestHandlerParams) {
20 if (user) {
21 return new Response('Redirect', { status: 303, headers: { 'Location': `/` } });
22 }
23
24 const isEmailVerificationEnabled = await AppConfig.isEmailVerificationEnabled();
25 const isMultiFactorAuthEnabled = await AppConfig.isMultiFactorAuthEnabled() && await UserModel.isThereAnAdmin();
26 const isSingleSignOnEnabled = await AppConfig.isSingleSignOnEnabled();
27 const config = await AppConfig.getConfig();
28 const helpEmail = config.visuals.helpEmail;
29
30 const singleSignOnUrl = isSingleSignOnEnabled
31 ? (await OidcModel.getSignInUrl({ requestPermissions: config.auth.singleSignOnScopes }))
32 : undefined;
33
34 const searchParams = new URL(request.url).searchParams;
35
36 const formData = new FormData();
37 let notice = '';
38 let email = '';
39
40 if (searchParams.get('success') === 'signup') {
41 email = searchParams.get('email') || '';
42 formData.set('email', email);
43
44 if (await AppConfig.isEmailVerificationEnabled()) {
45 notice = `You have received a code in your email. Use it to verify your email and login.`;
46 } else {
47 notice = `Your account was created successfully. Login below.`;
48 }
49 }
50
51 const htmlContent = defaultHtmlContent({
52 notice,
53 email,
54 formData,
55 isEmailVerificationEnabled,
56 isMultiFactorAuthEnabled,
57 isSingleSignOnEnabled,
58 helpEmail,
59 singleSignOnUrl,
60 });
61
62 return basicLayoutResponse(htmlContent, {
63 currentPath: match.pathname.input,
64 titlePrefix,
65 description,
66 match,
67 request,
68 user,
69 session,
70 isRunningLocally,
71 });
72}
73
74async function post({ request, match, user, session, isRunningLocally }: RequestHandlerParams) {
75 if (user) {

Callers

nothing calls this directly

Calls 10

basicLayoutResponseFunction · 0.90
isThereAnAdminMethod · 0.80
isSingleSignOnEnabledMethod · 0.80
getConfigMethod · 0.80
getSignInUrlMethod · 0.80
setMethod · 0.80
defaultHtmlContentFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected