Skip to content

Commit d3ec782

Browse files
committed
bep
1 parent 0b8ae10 commit d3ec782

File tree

3 files changed

+39
-51
lines changed

3 files changed

+39
-51
lines changed

site/src/pages/LoginPage/LoginPageView.stories.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,17 @@ import {
44
MockAuthMethodsExternal,
55
MockAuthMethodsPasswordOnly,
66
MockAuthMethodsPasswordTermsOfService,
7+
MockBuildInfo,
78
mockApiError,
89
} from "testHelpers/entities";
910
import { LoginPageView } from "./LoginPageView";
1011

1112
const meta: Meta<typeof LoginPageView> = {
1213
title: "pages/LoginPage",
1314
component: LoginPageView,
15+
args: {
16+
buildInfo: MockBuildInfo,
17+
},
1418
};
1519

1620
export default meta;

site/src/pages/LoginPage/LoginPageView.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { Interpolation, Theme } from "@emotion/react";
2+
import Link from "@mui/material/Link";
23
import type { FC } from "react";
34
import { useLocation } from "react-router-dom";
45
import type { AuthMethods, BuildInfoResponse } from "api/typesGenerated";
@@ -70,6 +71,20 @@ export const LoginPageView: FC<LoginPageViewProps> = ({
7071
Copyright &copy; {new Date().getFullYear()} Coder Technologies, Inc.
7172
</div>
7273
<div>{buildInfo?.version}</div>
74+
75+
{authMethods?.terms_of_service_link && (
76+
<div css={{ paddingTop: 12, fontSize: 12 }}>
77+
By continuing, you agree to the{" "}
78+
<Link
79+
href={authMethods.terms_of_service_link}
80+
target="_blank"
81+
rel="noreferrer"
82+
>
83+
Terms of Service
84+
</Link>
85+
.
86+
</div>
87+
)}
7388
</footer>
7489
</div>
7590
</div>

site/src/pages/LoginPage/SignInForm.tsx

Lines changed: 20 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import type { Interpolation, Theme } from "@emotion/react";
2-
import Checkbox from "@mui/material/Checkbox";
3-
import { type FC, type ReactNode, useState } from "react";
2+
import type { FC, ReactNode } from "react";
43
import type { AuthMethods } from "api/typesGenerated";
54
import { Alert } from "components/Alert/Alert";
65
import { ErrorAlert } from "components/Alert/ErrorAlert";
76
import { getApplicationName } from "utils/appearance";
87
import { OAuthSignInForm } from "./OAuthSignInForm";
98
import { PasswordSignInForm } from "./PasswordSignInForm";
10-
import { Link } from "@mui/material";
119

1210
export const Language = {
1311
emailLabel: "Email",
@@ -85,10 +83,6 @@ export const SignInForm: FC<SignInFormProps> = ({
8583
const passwordEnabled = authMethods?.password.enabled ?? true;
8684
const applicationName = getApplicationName();
8785

88-
const [tosAccepted, setTosAccepted] = useState(false);
89-
const termsOfServiceAcceptanceRequired =
90-
authMethods?.terms_of_service_link && !tosAccepted;
91-
9286
return (
9387
<div css={styles.root}>
9488
<h1 css={styles.title}>{applicationName}</h1>
@@ -105,55 +99,30 @@ export const SignInForm: FC<SignInFormProps> = ({
10599
</div>
106100
)}
107101

108-
{!termsOfServiceAcceptanceRequired && (
109-
<>
110-
{oAuthEnabled && (
111-
<OAuthSignInForm
112-
isSigningIn={isSigningIn}
113-
redirectTo={redirectTo}
114-
authMethods={authMethods}
115-
/>
116-
)}
117-
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-
)}
125-
126-
{passwordEnabled && (
127-
<PasswordSignInForm
128-
onSubmit={onSubmit}
129-
autoFocus={!oAuthEnabled}
130-
isSigningIn={isSigningIn}
131-
/>
132-
)}
133-
</>
102+
{oAuthEnabled && (
103+
<OAuthSignInForm
104+
isSigningIn={isSigningIn}
105+
redirectTo={redirectTo}
106+
authMethods={authMethods}
107+
/>
134108
)}
135109

136-
{authMethods?.terms_of_service_link && (
137-
<div css={{ paddingTop: 8, fontSize: 14 }}>
138-
<label>
139-
<Checkbox
140-
size="small"
141-
checked={tosAccepted}
142-
onChange={(event) => setTosAccepted(event.target.checked)}
143-
/>
144-
I agree to the{" "}
145-
<Link
146-
href={authMethods.terms_of_service_link}
147-
target="_blank"
148-
rel="noreferrer"
149-
>
150-
Terms of Service
151-
</Link>
152-
.
153-
</label>
110+
{passwordEnabled && oAuthEnabled && (
111+
<div css={styles.divider}>
112+
<div css={styles.dividerLine} />
113+
<div css={styles.dividerLabel}>or</div>
114+
<div css={styles.dividerLine} />
154115
</div>
155116
)}
156117

118+
{passwordEnabled && (
119+
<PasswordSignInForm
120+
onSubmit={onSubmit}
121+
autoFocus={!oAuthEnabled}
122+
isSigningIn={isSigningIn}
123+
/>
124+
)}
125+
157126
{!passwordEnabled && !oAuthEnabled && (
158127
<Alert severity="error">No authentication methods configured!</Alert>
159128
)}

0 commit comments

Comments
 (0)