Skip to content

Commit

Permalink
Merge pull request #4128 from thematters/release/4.28.6
Browse files Browse the repository at this point in the history
Release: v4.28.6
  • Loading branch information
gary02 committed Jan 11, 2024
2 parents 3157e91 + 7891b17 commit f0daadd
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "matters-web",
"version": "4.28.5",
"version": "4.28.6",
"description": "codebase of Matters' website",
"author": "Matters <hi@matters.town>",
"engines": {
Expand Down
31 changes: 31 additions & 0 deletions src/components/Forms/EmailLoginForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,15 @@ import {
LanguageContext,
LanguageSwitch,
Media,
ReCaptchaContext,
TextIcon,
Turnstile,
TurnstileInstance,
useCountdown,
// toast,
useMutation,
useRoute,
ViewerContext,
} from '~/components'
import { EMAIL_LOGIN } from '~/components/GQL/mutations/emailLogin'
import SEND_CODE from '~/components/GQL/mutations/sendCode'
Expand Down Expand Up @@ -77,6 +81,7 @@ export const EmailLoginForm: React.FC<FormProps> = ({
setAuthFeedType,
back,
}) => {
const viewer = useContext(ViewerContext)
const [login] = useMutation<EmailLoginMutation>(EMAIL_LOGIN, undefined, {
showToast: false,
})
Expand All @@ -93,6 +98,9 @@ export const EmailLoginForm: React.FC<FormProps> = ({

const isNormal = authFeedType === 'normal'
const isWallet = authFeedType === 'wallet'
const { token: reCaptchaToken, refreshToken } = useContext(ReCaptchaContext)
const turnstileRef = useRef<TurnstileInstance>(null)
const [turnstileToken, setTurnstileToken] = useState<string>()

const [isSelectMethod, setIsSelectMethod] = useState(false)
const [errorCode, setErrorCode] = useState<ERROR_CODES | null>(null)
Expand Down Expand Up @@ -225,6 +233,9 @@ export const EmailLoginForm: React.FC<FormProps> = ({
input: {
email: values.email,
type: 'email_otp',
token: turnstileToken
? `${reCaptchaToken} ${turnstileToken}`
: reCaptchaToken,
redirectUrl,
language: lang,
},
Expand Down Expand Up @@ -255,13 +266,33 @@ export const EmailLoginForm: React.FC<FormProps> = ({
)
}
})
refreshToken?.()
turnstileRef.current?.reset()
}
}

const fieldMsgId = `field-msg-sign-in`

const siteKey = process.env
.NEXT_PUBLIC_CLOUDFLARE_TURNSTILE_SITE_KEY as string
const InnerForm = (
<>
<Turnstile
ref={turnstileRef}
siteKey={siteKey}
options={{
action: 'email_login',
cData: `user-group-${viewer.info.group}`,
size: 'invisible',
}}
scriptOptions={{
compat: 'recaptcha',
appendTo: 'body',
}}
onSuccess={(token) => {
setTurnstileToken(token)
}}
/>
<Form id={formId} onSubmit={handleSubmit}>
<Form.Input
label={<FormattedMessage defaultMessage="Email" id="sy+pv5" />}
Expand Down
9 changes: 3 additions & 6 deletions src/components/Forms/EmailSignUpForm/Init.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,9 @@ const Init: React.FC<FormProps> = ({
input: {
email,
type: 'register',
token:
// (viewer.info.group === UserGroup.A && turnstileToken) ||
// turnstileRef.current?.getResponse() || // fallback to ReCaptchaContext token
turnstileToken
? `${reCaptchaToken} ${turnstileToken}`
: reCaptchaToken,
token: turnstileToken
? `${reCaptchaToken} ${turnstileToken}`
: reCaptchaToken,
redirectUrl,
language: lang,
},
Expand Down
4 changes: 0 additions & 4 deletions src/views/User/UserProfile/DropdownActions/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,6 @@ const DropdownActions = ({ user, isMe, isInAside }: DropdownActionsProps) => {
hasRssFeed: user?.articles.totalCount > 0 && !!user?.info.ipnsKey,
}

if (_isEmpty(_pickBy(controls))) {
return null
}

const WithShare = withDialog<Omit<ShareDialogProps, 'children'>>(
BaseDropdownActions,
ShareDialog,
Expand Down

0 comments on commit f0daadd

Please sign in to comment.