Skip to content

Commit 8f03a45

Browse files
committed
require check
1 parent 331f8a4 commit 8f03a45

File tree

1 file changed

+35
-22
lines changed

1 file changed

+35
-22
lines changed

site/src/pages/LoginPage/SignInForm.tsx

Lines changed: 35 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Interpolation, Theme } from "@emotion/react";
22
import Checkbox from "@mui/material/Checkbox";
3-
import type { FC, ReactNode } from "react";
3+
import { type FC, type ReactNode, useState } from "react";
44
import type { AuthMethods } from "api/typesGenerated";
55
import { Alert } from "components/Alert/Alert";
66
import { ErrorAlert } from "components/Alert/ErrorAlert";
@@ -85,6 +85,10 @@ export const SignInForm: FC<SignInFormProps> = ({
8585
const passwordEnabled = authMethods?.password.enabled ?? true;
8686
const applicationName = getApplicationName();
8787

88+
const [tosAccepted, setTosAccepted] = useState(false);
89+
const termsOfServiceAcceptanceRequired =
90+
authMethods?.terms_of_service_link && !tosAccepted;
91+
8892
return (
8993
<div css={styles.root}>
9094
<h1 css={styles.title}>{applicationName}</h1>
@@ -101,34 +105,43 @@ export const SignInForm: FC<SignInFormProps> = ({
101105
</div>
102106
)}
103107

104-
{oAuthEnabled && (
105-
<OAuthSignInForm
106-
isSigningIn={isSigningIn}
107-
redirectTo={redirectTo}
108-
authMethods={authMethods}
109-
/>
110-
)}
108+
{!termsOfServiceAcceptanceRequired && (
109+
<>
110+
{oAuthEnabled && (
111+
<OAuthSignInForm
112+
isSigningIn={isSigningIn}
113+
redirectTo={redirectTo}
114+
authMethods={authMethods}
115+
/>
116+
)}
111117

112-
{passwordEnabled && oAuthEnabled && (
113-
<div css={styles.divider}>
114-
<div css={styles.dividerLine} />
115-
<div css={styles.dividerLabel}>Or</div>
116-
<div css={styles.dividerLine} />
117-
</div>
118-
)}
118+
{passwordEnabled && oAuthEnabled && (
119+
<div css={styles.divider}>
120+
<div css={styles.dividerLine} />
121+
<div css={styles.dividerLabel}>or</div>
122+
<div css={styles.dividerLine} />
123+
</div>
124+
)}
119125

120-
{passwordEnabled && (
121-
<PasswordSignInForm
122-
onSubmit={onSubmit}
123-
autoFocus={!oAuthEnabled}
124-
isSigningIn={isSigningIn}
125-
/>
126+
{passwordEnabled && (
127+
<PasswordSignInForm
128+
onSubmit={onSubmit}
129+
autoFocus={!oAuthEnabled}
130+
isSigningIn={isSigningIn}
131+
/>
132+
)}
133+
</>
126134
)}
127135

128136
{authMethods?.terms_of_service_link && (
129137
<div css={{ paddingTop: 8, fontSize: 14 }}>
130138
<label>
131-
<Checkbox size="small" />I agree to the{" "}
139+
<Checkbox
140+
size="small"
141+
checked={tosAccepted}
142+
onChange={(event) => setTosAccepted(event.target.checked)}
143+
/>
144+
I agree to the{" "}
132145
<Link href={authMethods.terms_of_service_link} target="_blank">
133146
Terms of Service
134147
</Link>

0 commit comments

Comments
 (0)