MCPcopy Create free account
hub / github.com/AnswerOverflow/AnswerOverflow / SignInButton

Function SignInButton

packages/ui/src/navbar/sign-in-button.tsx:7–60  ·  view source on GitHub ↗
(
	props: ButtonProps & {
		tenant: ServerPublic | undefined;
		dashboard?: boolean;
	},
)

Source from the content-addressed store, hash-verified

5import { LinkButton } from '../ui/link-button';
6
7export function SignInButton(
8 props: ButtonProps & {
9 tenant: ServerPublic | undefined;
10 dashboard?: boolean;
11 },
12) {
13 const { tenant } = props;
14 if (tenant) {
15 const link = makeMainSiteLink('/api/auth/tenant/signin');
16 const redirect =
17 typeof window !== 'undefined'
18 ? window.location.href
19 : `http://${tenant.customDomain!}`;
20
21 return (
22 <LinkButton
23 variant="outline"
24 href={`${link}?redirect=${encodeURIComponent(redirect)}`}
25 >
26 Login
27 </LinkButton>
28 );
29 }
30 if (props.dashboard) {
31 return (
32 <LinkButton
33 variant="outline"
34 href={
35 // eslint-disable-next-line n/no-process-env
36 (process.env.NEXT_PUBLIC_DEPLOYMENT_ENV === 'local'
37 ? 'http://localhost:3000/'
38 : 'https://www.answeroverflow.com/') + `app-auth`
39 }
40 >
41 Sign In
42 </LinkButton>
43 );
44 }
45 return (
46 // TODO: Swap to href
47 // eslint-disable-next-line @typescript-eslint/no-misused-promises
48 <Button
49 variant="outline"
50 onClick={() => {
51 void import('next-auth/react').then(({ signIn }) => {
52 void signIn('discord');
53 });
54 }}
55 {...props}
56 >
57 Login
58 </Button>
59 );
60}

Callers

nothing calls this directly

Calls 2

makeMainSiteLinkFunction · 0.90
signInFunction · 0.85

Tested by

no test coverage detected