redirect to homepage after signing in

This commit is contained in:
Sean Yesmunt 2020-08-21 11:24:47 -04:00
parent e0e33eb148
commit cf98e65a3f

View file

@ -1,5 +1,6 @@
// @flow // @flow
import * as PAGES from 'constants/pages'; import * as PAGES from 'constants/pages';
import { SITE_NAME } from 'config';
import React, { useState } from 'react'; 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';
@ -10,13 +11,13 @@ import I18nMessage from 'component/i18nMessage';
import Card from 'component/common/card'; import Card from 'component/common/card';
type Props = { type Props = {
history: { push: string => void, location: { search: string } }, history: { push: string => void, replace: string => void, location: { search: string } },
doToast: ({}) => void, doToast: ({}) => void,
}; };
function SignInVerifyPage(props: Props) { function SignInVerifyPage(props: Props) {
const { const {
history: { push, location }, history: { push, replace, location },
doToast, doToast,
} = props; } = props;
const [isAuthenticationSuccess, setIsAuthenticationSuccess] = useState(false); const [isAuthenticationSuccess, setIsAuthenticationSuccess] = useState(false);
@ -64,6 +65,13 @@ function SignInVerifyPage(props: Props) {
}; };
}, [needsRecaptcha, captchaLoaded]); }, [needsRecaptcha, captchaLoaded]);
React.useEffect(() => {
if (isAuthenticationSuccess) {
doToast({ message: __('You are now signed in.') });
replace('/');
}
}, [isAuthenticationSuccess, replace, doToast]);
function onCaptchaChange(value) { function onCaptchaChange(value) {
verifyUser(value); verifyUser(value);
} }
@ -91,16 +99,10 @@ function SignInVerifyPage(props: Props) {
<Page authPage className="main--auth-page"> <Page authPage className="main--auth-page">
<div className="main__sign-up"> <div className="main__sign-up">
<Card <Card
title={isAuthenticationSuccess ? __('Sign In Success!') : __('Sign In to lbry.tv')} title={__('Sign In to %SITE_NAME%', { SITE_NAME })}
subtitle={ subtitle={
<React.Fragment> <React.Fragment>
<p> <p>{needsRecaptcha ? null : __('Welcome back! You are automatically being signed in.')}</p>
{isAuthenticationSuccess
? __('You can now close this tab.')
: needsRecaptcha
? null
: __('Welcome back! You are automatically being signed in.')}
</p>
{showCaptchaMessage && !isAuthenticationSuccess && ( {showCaptchaMessage && !isAuthenticationSuccess && (
<p> <p>
<I18nMessage <I18nMessage