From 8e89a144cf0171919e548d0b01d02c19c5b5d1a8 Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Tue, 19 Nov 2019 11:55:56 -0500 Subject: [PATCH] disable captcha for returning users --- ui/page/signInVerify/view.jsx | 25 +++++++++++++++++++------ ui/util/autoLaunch.js | 2 ++ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/ui/page/signInVerify/view.jsx b/ui/page/signInVerify/view.jsx index 3740d697c..272612fc2 100644 --- a/ui/page/signInVerify/view.jsx +++ b/ui/page/signInVerify/view.jsx @@ -3,7 +3,6 @@ import React, { useState } from 'react'; import { withRouter } from 'react-router'; import Page from 'component/page'; import ReCAPTCHA from 'react-google-recaptcha'; -import Button from 'component/button'; import { Lbryio } from 'lbryinc'; import * as PAGES from 'constants/pages'; @@ -17,12 +16,12 @@ function SignInVerifyPage(props: Props) { history: { push, location }, doToast, } = props; + const [isAuthenticationSuccess, setIsAuthenticationSuccess] = useState(false); const urlParams = new URLSearchParams(location.search); const authToken = urlParams.get('auth_token'); const userSubmittedEmail = urlParams.get('email'); const verificationToken = urlParams.get('verification_token'); - - const [isAuthenticationSuccess, setIsAuthenticationSuccess] = useState(false); + const needsRecaptcha = urlParams.get('needs_recaptcha') === 'true'; function onAuthError(message) { doToast({ @@ -38,12 +37,22 @@ function SignInVerifyPage(props: Props) { } }, [authToken, userSubmittedEmail, verificationToken, doToast, push]); + React.useEffect(() => { + if (!needsRecaptcha) { + verifyUser(); + } + }, [needsRecaptcha]); + function onCaptchaChange(value) { + verifyUser(value); + } + + function verifyUser(captchaValue) { Lbryio.call('user_email', 'confirm', { auth_token: authToken, email: userSubmittedEmail, verification_token: verificationToken, - recaptcha: value, + ...(captchaValue ? { recaptcha: captchaValue } : {}), }) .then(() => { setIsAuthenticationSuccess(true); @@ -60,9 +69,13 @@ function SignInVerifyPage(props: Props) { {isAuthenticationSuccess ? __('Sign In Success!') : __('Sign In to lbry.tv')}

- {isAuthenticationSuccess ? __('You can now close this tab.') : __('Click below to sign in to lbry.tv')} + {isAuthenticationSuccess + ? __('You can now close this tab.') + : needsRecaptcha + ? __('Click below to sign in to lbry.tv') + : __('Welcome back! You are automatically being signed in.')}

- {!isAuthenticationSuccess && ( + {!isAuthenticationSuccess && needsRecaptcha && (