feat(auth): integrate captcha validation and component for sign-in/up… (#15054)
… process Added captcha token validation to the sign-in/up flow. Introduced `StyledLoaderContainer` for better UI feedback during loading. Enhanced error handling within `useSignInUp` to handle GraphQL errors effectively. --------- Co-authored-by: Félix Malfait <felix.malfait@gmail.com> Co-authored-by: Félix Malfait <felix@twenty.com>
This commit is contained in:
@@ -6,7 +6,7 @@ import { isDefined } from 'twenty-shared/utils';
|
||||
export const useReadCaptchaToken = () => {
|
||||
const readCaptchaToken = useRecoilCallback(
|
||||
({ snapshot }) =>
|
||||
async () => {
|
||||
() => {
|
||||
const existingCaptchaToken = snapshot
|
||||
.getLoadable(captchaTokenState)
|
||||
.getValue();
|
||||
|
||||
@@ -4,8 +4,8 @@ import { captchaTokenState } from '@/captcha/states/captchaTokenState';
|
||||
import { isRequestingCaptchaTokenState } from '@/captcha/states/isRequestingCaptchaTokenState';
|
||||
import { isCaptchaRequiredForPath } from '@/captcha/utils/isCaptchaRequiredForPath';
|
||||
import { captchaState } from '@/client-config/states/captchaState';
|
||||
import { assertIsDefinedOrThrow, isDefined } from 'twenty-shared/utils';
|
||||
import { CaptchaDriverType } from '~/generated-metadata/graphql';
|
||||
import { isUndefinedOrNull } from '~/utils/isUndefinedOrNull';
|
||||
|
||||
export const useRequestFreshCaptchaToken = () => {
|
||||
const setCaptchaToken = useSetRecoilState(captchaTokenState);
|
||||
@@ -22,14 +22,15 @@ export const useRequestFreshCaptchaToken = () => {
|
||||
|
||||
const captcha = snapshot.getLoadable(captchaState).getValue();
|
||||
|
||||
if (isUndefinedOrNull(captcha?.provider)) {
|
||||
if (!isDefined(captcha)) {
|
||||
return;
|
||||
}
|
||||
|
||||
assertIsDefinedOrThrow(captcha);
|
||||
|
||||
setIsRequestingCaptchaToken(true);
|
||||
|
||||
let captchaWidget: any;
|
||||
|
||||
switch (captcha.provider) {
|
||||
case CaptchaDriverType.GOOGLE_RECAPTCHA:
|
||||
window.grecaptcha
|
||||
|
||||
Reference in New Issue
Block a user