chore: bump version to 2.21.6 in package.json and enhance captcha integration across auth components (#418)
- Updated application version from 2.21.4 to 2.21.6 in package.json. - Added "verifyingCaptcha" message to auth.json for improved user feedback during captcha verification. - Enhanced captcha handling in various authentication components, including MagicLinkAuthContainer, PasswordResetRequestContainer, and SignUpContainer, to reflect loading states and improve user experience.
This commit is contained in:
committed by
GitHub
parent
a78da16790
commit
f6c635aac3
@@ -67,15 +67,20 @@ export function useCaptcha(
|
||||
[siteKey, nonce, handleTokenChange, handleInstanceChange],
|
||||
);
|
||||
|
||||
// Ready when captcha is not configured (no siteKey) or token is available
|
||||
const isReady = !siteKey || token !== '';
|
||||
|
||||
return useMemo(
|
||||
() => ({
|
||||
/** The current captcha token */
|
||||
token,
|
||||
/** Whether the captcha is ready (not configured or token available) */
|
||||
isReady,
|
||||
/** Reset the captcha (clears token and resets widget) */
|
||||
reset,
|
||||
/** The captcha field component to render */
|
||||
field,
|
||||
}),
|
||||
[token, reset, field],
|
||||
[token, isReady, reset, field],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -49,6 +49,8 @@ export function MagicLinkAuthContainer({
|
||||
const appEvents = useAppEvents();
|
||||
const { recordAuthMethod } = useLastAuthMethod();
|
||||
|
||||
const captchaLoading = !captcha.isReady;
|
||||
|
||||
const form = useForm({
|
||||
resolver: zodResolver(
|
||||
z.object({
|
||||
@@ -131,13 +133,18 @@ export function MagicLinkAuthContainer({
|
||||
<TermsAndConditionsFormField />
|
||||
</If>
|
||||
|
||||
<Button disabled={signInWithOtpMutation.isPending}>
|
||||
<If
|
||||
condition={signInWithOtpMutation.isPending}
|
||||
fallback={<Trans i18nKey={'auth:sendEmailLink'} />}
|
||||
>
|
||||
<Button disabled={signInWithOtpMutation.isPending || captchaLoading}>
|
||||
<If condition={captchaLoading}>
|
||||
<Trans i18nKey={'auth:verifyingCaptcha'} />
|
||||
</If>
|
||||
|
||||
<If condition={signInWithOtpMutation.isPending && !captchaLoading}>
|
||||
<Trans i18nKey={'auth:sendingEmailLink'} />
|
||||
</If>
|
||||
|
||||
<If condition={!signInWithOtpMutation.isPending && !captchaLoading}>
|
||||
<Trans i18nKey={'auth:sendEmailLink'} />
|
||||
</If>
|
||||
</Button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@@ -34,6 +34,7 @@ export function PasswordResetRequestContainer(params: {
|
||||
const { t } = useTranslation('auth');
|
||||
const resetPasswordMutation = useRequestResetPassword();
|
||||
const captcha = useCaptcha({ siteKey: params.captchaSiteKey });
|
||||
const captchaLoading = !captcha.isReady;
|
||||
|
||||
const error = resetPasswordMutation.error;
|
||||
const success = resetPasswordMutation.data;
|
||||
@@ -101,8 +102,16 @@ export function PasswordResetRequestContainer(params: {
|
||||
)}
|
||||
/>
|
||||
|
||||
<Button disabled={resetPasswordMutation.isPending} type="submit">
|
||||
<Trans i18nKey={'auth:passwordResetLabel'} />
|
||||
<Button
|
||||
disabled={resetPasswordMutation.isPending || captchaLoading}
|
||||
type="submit"
|
||||
>
|
||||
<If
|
||||
condition={captchaLoading}
|
||||
fallback={<Trans i18nKey={'auth:passwordResetLabel'} />}
|
||||
>
|
||||
<Trans i18nKey={'auth:verifyingCaptcha'} />
|
||||
</If>
|
||||
</Button>
|
||||
</div>
|
||||
{captcha.field}
|
||||
|
||||
@@ -24,6 +24,7 @@ export function PasswordSignInContainer({
|
||||
const { recordAuthMethod } = useLastAuthMethod();
|
||||
const isLoading = signInMutation.isPending;
|
||||
const isRedirecting = signInMutation.isSuccess;
|
||||
const captchaLoading = !captcha.isReady;
|
||||
|
||||
const onSubmit = useCallback(
|
||||
async (credentials: z.infer<typeof PasswordSignInSchema>) => {
|
||||
@@ -59,6 +60,7 @@ export function PasswordSignInContainer({
|
||||
onSubmit={onSubmit}
|
||||
loading={isLoading}
|
||||
redirecting={isRedirecting}
|
||||
captchaLoading={captchaLoading}
|
||||
/>
|
||||
|
||||
{captcha.field}
|
||||
|
||||
@@ -29,10 +29,12 @@ import { PasswordInput } from './password-input';
|
||||
|
||||
export function PasswordSignInForm({
|
||||
onSubmit,
|
||||
captchaLoading = false,
|
||||
loading = false,
|
||||
redirecting = false,
|
||||
}: {
|
||||
onSubmit: (params: z.infer<typeof PasswordSignInSchema>) => unknown;
|
||||
captchaLoading: boolean;
|
||||
loading: boolean;
|
||||
redirecting: boolean;
|
||||
}) {
|
||||
@@ -126,6 +128,12 @@ export function PasswordSignInForm({
|
||||
</span>
|
||||
</If>
|
||||
|
||||
<If condition={captchaLoading}>
|
||||
<span className={'animate-in fade-in slide-in-from-bottom-24'}>
|
||||
<Trans i18nKey={'auth:verifyingCaptcha'} />
|
||||
</span>
|
||||
</If>
|
||||
|
||||
<If condition={!redirecting && !loading}>
|
||||
<span className={'animate-out fade-out flex items-center'}>
|
||||
<Trans i18nKey={'auth:signInWithEmail'} />
|
||||
|
||||
@@ -29,6 +29,7 @@ export function EmailPasswordSignUpContainer({
|
||||
captchaSiteKey,
|
||||
}: EmailPasswordSignUpContainerProps) {
|
||||
const captcha = useCaptcha({ siteKey: captchaSiteKey });
|
||||
const captchaLoading = !captcha.isReady;
|
||||
|
||||
const {
|
||||
signUp: onSignupRequested,
|
||||
@@ -57,6 +58,7 @@ export function EmailPasswordSignUpContainer({
|
||||
loading={loading}
|
||||
defaultValues={defaultValues}
|
||||
displayTermsCheckbox={displayTermsCheckbox}
|
||||
captchaLoading={captchaLoading}
|
||||
/>
|
||||
|
||||
{captcha.field}
|
||||
|
||||
@@ -33,7 +33,9 @@ interface PasswordSignUpFormProps {
|
||||
password: string;
|
||||
repeatPassword: string;
|
||||
}) => unknown;
|
||||
|
||||
loading: boolean;
|
||||
captchaLoading: boolean;
|
||||
}
|
||||
|
||||
export function PasswordSignUpForm({
|
||||
@@ -41,6 +43,7 @@ export function PasswordSignUpForm({
|
||||
displayTermsCheckbox,
|
||||
onSubmit,
|
||||
loading,
|
||||
captchaLoading,
|
||||
}: PasswordSignUpFormProps) {
|
||||
const form = useForm({
|
||||
resolver: zodResolver(PasswordSignUpSchema),
|
||||
@@ -116,24 +119,27 @@ export function PasswordSignUpForm({
|
||||
data-test={'auth-submit-button'}
|
||||
className={'w-full'}
|
||||
type="submit"
|
||||
disabled={loading}
|
||||
disabled={loading || captchaLoading}
|
||||
>
|
||||
<If
|
||||
condition={loading}
|
||||
fallback={
|
||||
<>
|
||||
<Trans i18nKey={'auth:signUpWithEmail'} />
|
||||
<If condition={captchaLoading}>
|
||||
<Trans i18nKey={'auth:verifyingCaptcha'} />
|
||||
</If>
|
||||
|
||||
<ArrowRight
|
||||
className={
|
||||
'zoom-in animate-in slide-in-from-left-2 fill-mode-both h-4 delay-500 duration-500'
|
||||
}
|
||||
/>
|
||||
</>
|
||||
}
|
||||
>
|
||||
<If condition={loading && !captchaLoading}>
|
||||
<Trans i18nKey={'auth:signingUp'} />
|
||||
</If>
|
||||
|
||||
<If condition={!loading && !captchaLoading}>
|
||||
<>
|
||||
<Trans i18nKey={'auth:signUpWithEmail'} />
|
||||
|
||||
<ArrowRight
|
||||
className={
|
||||
'zoom-in animate-in slide-in-from-left-2 fill-mode-both h-4 delay-500 duration-500'
|
||||
}
|
||||
/>
|
||||
</>
|
||||
</If>
|
||||
</Button>
|
||||
</form>
|
||||
</Form>
|
||||
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
FormItem,
|
||||
FormMessage,
|
||||
} from '@kit/ui/form';
|
||||
import { If } from '@kit/ui/if';
|
||||
import { Trans } from '@kit/ui/trans';
|
||||
|
||||
import { useCaptcha } from '../captcha/client';
|
||||
@@ -26,6 +27,7 @@ export function ResendAuthLinkForm(props: {
|
||||
}) {
|
||||
const captcha = useCaptcha({ siteKey: props.captchaSiteKey });
|
||||
const resendLink = useResendLink(captcha.token);
|
||||
const captchaLoading = !captcha.isReady;
|
||||
|
||||
const form = useForm({
|
||||
resolver: zodResolver(z.object({ email: z.string().email() })),
|
||||
@@ -83,7 +85,15 @@ export function ResendAuthLinkForm(props: {
|
||||
}}
|
||||
/>
|
||||
|
||||
<Button disabled={resendLink.isPending}>
|
||||
<Button disabled={resendLink.isPending || captchaLoading}>
|
||||
<If condition={captchaLoading}>
|
||||
<Trans i18nKey={'auth:verifyingCaptcha'} />
|
||||
</If>
|
||||
|
||||
<If condition={resendLink.isPending && !captchaLoading}>
|
||||
<Trans i18nKey={'auth:resendingLink'} />
|
||||
</If>
|
||||
|
||||
<Trans i18nKey={'auth:resendLink'} defaults={'Resend Link'} />
|
||||
</Button>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user