1
1
import type { Interpolation , Theme } from "@emotion/react" ;
2
2
import Checkbox from "@mui/material/Checkbox" ;
3
- import type { FC , ReactNode } from "react" ;
3
+ import { type FC , type ReactNode , useState } from "react" ;
4
4
import type { AuthMethods } from "api/typesGenerated" ;
5
5
import { Alert } from "components/Alert/Alert" ;
6
6
import { ErrorAlert } from "components/Alert/ErrorAlert" ;
@@ -85,6 +85,10 @@ export const SignInForm: FC<SignInFormProps> = ({
85
85
const passwordEnabled = authMethods ?. password . enabled ?? true ;
86
86
const applicationName = getApplicationName ( ) ;
87
87
88
+ const [ tosAccepted , setTosAccepted ] = useState ( false ) ;
89
+ const termsOfServiceAcceptanceRequired =
90
+ authMethods ?. terms_of_service_link && ! tosAccepted ;
91
+
88
92
return (
89
93
< div css = { styles . root } >
90
94
< h1 css = { styles . title } > { applicationName } </ h1 >
@@ -101,34 +105,43 @@ export const SignInForm: FC<SignInFormProps> = ({
101
105
</ div >
102
106
) }
103
107
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
+ ) }
111
117
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
+ ) }
119
125
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
+ </ >
126
134
) }
127
135
128
136
{ authMethods ?. terms_of_service_link && (
129
137
< div css = { { paddingTop : 8 , fontSize : 14 } } >
130
138
< 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{ " " }
132
145
< Link href = { authMethods . terms_of_service_link } target = "_blank" >
133
146
Terms of Service
134
147
</ Link >
0 commit comments