disable captcha for returning users
This commit is contained in:
parent
6f572420f9
commit
8e89a144cf
2 changed files with 21 additions and 6 deletions
|
@ -3,7 +3,6 @@ import React, { useState } from 'react';
|
||||||
import { withRouter } from 'react-router';
|
import { withRouter } from 'react-router';
|
||||||
import Page from 'component/page';
|
import Page from 'component/page';
|
||||||
import ReCAPTCHA from 'react-google-recaptcha';
|
import ReCAPTCHA from 'react-google-recaptcha';
|
||||||
import Button from 'component/button';
|
|
||||||
import { Lbryio } from 'lbryinc';
|
import { Lbryio } from 'lbryinc';
|
||||||
import * as PAGES from 'constants/pages';
|
import * as PAGES from 'constants/pages';
|
||||||
|
|
||||||
|
@ -17,12 +16,12 @@ function SignInVerifyPage(props: Props) {
|
||||||
history: { push, location },
|
history: { push, location },
|
||||||
doToast,
|
doToast,
|
||||||
} = props;
|
} = props;
|
||||||
|
const [isAuthenticationSuccess, setIsAuthenticationSuccess] = useState(false);
|
||||||
const urlParams = new URLSearchParams(location.search);
|
const urlParams = new URLSearchParams(location.search);
|
||||||
const authToken = urlParams.get('auth_token');
|
const authToken = urlParams.get('auth_token');
|
||||||
const userSubmittedEmail = urlParams.get('email');
|
const userSubmittedEmail = urlParams.get('email');
|
||||||
const verificationToken = urlParams.get('verification_token');
|
const verificationToken = urlParams.get('verification_token');
|
||||||
|
const needsRecaptcha = urlParams.get('needs_recaptcha') === 'true';
|
||||||
const [isAuthenticationSuccess, setIsAuthenticationSuccess] = useState(false);
|
|
||||||
|
|
||||||
function onAuthError(message) {
|
function onAuthError(message) {
|
||||||
doToast({
|
doToast({
|
||||||
|
@ -38,12 +37,22 @@ function SignInVerifyPage(props: Props) {
|
||||||
}
|
}
|
||||||
}, [authToken, userSubmittedEmail, verificationToken, doToast, push]);
|
}, [authToken, userSubmittedEmail, verificationToken, doToast, push]);
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
if (!needsRecaptcha) {
|
||||||
|
verifyUser();
|
||||||
|
}
|
||||||
|
}, [needsRecaptcha]);
|
||||||
|
|
||||||
function onCaptchaChange(value) {
|
function onCaptchaChange(value) {
|
||||||
|
verifyUser(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
function verifyUser(captchaValue) {
|
||||||
Lbryio.call('user_email', 'confirm', {
|
Lbryio.call('user_email', 'confirm', {
|
||||||
auth_token: authToken,
|
auth_token: authToken,
|
||||||
email: userSubmittedEmail,
|
email: userSubmittedEmail,
|
||||||
verification_token: verificationToken,
|
verification_token: verificationToken,
|
||||||
recaptcha: value,
|
...(captchaValue ? { recaptcha: captchaValue } : {}),
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
setIsAuthenticationSuccess(true);
|
setIsAuthenticationSuccess(true);
|
||||||
|
@ -60,9 +69,13 @@ function SignInVerifyPage(props: Props) {
|
||||||
{isAuthenticationSuccess ? __('Sign In Success!') : __('Sign In to lbry.tv')}
|
{isAuthenticationSuccess ? __('Sign In Success!') : __('Sign In to lbry.tv')}
|
||||||
</h1>
|
</h1>
|
||||||
<p className="section__subtitle">
|
<p className="section__subtitle">
|
||||||
{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.')}
|
||||||
</p>
|
</p>
|
||||||
{!isAuthenticationSuccess && (
|
{!isAuthenticationSuccess && needsRecaptcha && (
|
||||||
<div className="section__actions">
|
<div className="section__actions">
|
||||||
<ReCAPTCHA
|
<ReCAPTCHA
|
||||||
sitekey="6LePsJgUAAAAAFTuWOKRLnyoNKhm0HA4C3elrFMG"
|
sitekey="6LePsJgUAAAAAFTuWOKRLnyoNKhm0HA4C3elrFMG"
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
|
// @if TARGET='app'
|
||||||
const AutoLaunch = require('auto-launch');
|
const AutoLaunch = require('auto-launch');
|
||||||
|
|
||||||
export const launcher = new AutoLaunch({
|
export const launcher = new AutoLaunch({
|
||||||
name: 'LBRY',
|
name: 'LBRY',
|
||||||
isHidden: true,
|
isHidden: true,
|
||||||
});
|
});
|
||||||
|
// @endif
|
||||||
|
|
Loading…
Reference in a new issue