fix(auth): Fix auth flow for the client app
This commit is contained in:
committed by
mrugesh mohapatra
parent
a656cbf98a
commit
c08bb95ea8
@@ -9,7 +9,11 @@ import Helmet from 'react-helmet';
|
||||
|
||||
import { Loader, Spacer } from '../components/helpers';
|
||||
import Layout from '../components/layouts/Default';
|
||||
import { userSelector, userFetchStateSelector } from '../redux';
|
||||
import {
|
||||
userSelector,
|
||||
userFetchStateSelector,
|
||||
isSignedInSelector
|
||||
} from '../redux';
|
||||
import { randomQuote } from '../utils/get-words';
|
||||
|
||||
import './welcome.css';
|
||||
@@ -20,6 +24,7 @@ const propTypes = {
|
||||
complete: PropTypes.bool,
|
||||
errored: PropTypes.bool
|
||||
}),
|
||||
isSignedIn: PropTypes.bool,
|
||||
user: PropTypes.shape({
|
||||
acceptedPrivacyTerms: PropTypes.bool,
|
||||
username: PropTypes.string,
|
||||
@@ -32,20 +37,22 @@ const propTypes = {
|
||||
|
||||
const mapStateToProps = createSelector(
|
||||
userFetchStateSelector,
|
||||
isSignedInSelector,
|
||||
userSelector,
|
||||
(fetchState, user) => ({ fetchState, user })
|
||||
(fetchState, isSignedIn, user) => ({ fetchState, isSignedIn, user })
|
||||
);
|
||||
const mapDispatchToProps = dispatch => bindActionCreators({}, dispatch);
|
||||
|
||||
function Welcome({
|
||||
fetchState: { pending, complete },
|
||||
isSignedIn,
|
||||
user: {
|
||||
acceptedPrivacyTerms,
|
||||
name = '',
|
||||
completedChallengeCount = 0,
|
||||
completedChallengeCount: completedChallenges = 0,
|
||||
completedProjectCount = 0,
|
||||
completedCertCount = 0,
|
||||
completedLegacyCertCount = 0
|
||||
completedLegacyCertCount: completedLegacyCerts = 0
|
||||
}
|
||||
}) {
|
||||
if (pending && !complete) {
|
||||
@@ -58,7 +65,12 @@ function Welcome({
|
||||
);
|
||||
}
|
||||
|
||||
if (!acceptedPrivacyTerms) {
|
||||
if (!isSignedIn) {
|
||||
navigate('/');
|
||||
return null;
|
||||
}
|
||||
|
||||
if (isSignedIn && !acceptedPrivacyTerms) {
|
||||
navigate('/accept-privacy-terms');
|
||||
return null;
|
||||
}
|
||||
@@ -70,72 +82,72 @@ function Welcome({
|
||||
<title>Welcome {name ? name : 'Camper'} | freeCodeCamp.org</title>
|
||||
</Helmet>
|
||||
<main>
|
||||
<Grid className='text-center'>
|
||||
<Row>
|
||||
<Col xs={12}>
|
||||
<Spacer />
|
||||
<h1 className='big-heading'>Welcome {name ? name : 'Camper'}!</h1>
|
||||
</Col>
|
||||
</Row>
|
||||
<Spacer />
|
||||
<Row>
|
||||
<Col sm={8} smOffset={2} xs={12}>
|
||||
<a
|
||||
className='update-link'
|
||||
href='/n/7gR5pBM-K?refsource=userhome'
|
||||
target='_blank'
|
||||
>
|
||||
We're building a massive open dataset about new coders. Take the
|
||||
2018 New Coder Survey. It only takes 5 minutes.
|
||||
</a>
|
||||
</Col>
|
||||
</Row>
|
||||
<Spacer />
|
||||
<Row className='quote-partial'>
|
||||
<Col sm={10} smOffset={1} xs={12}>
|
||||
<blockquote className='blockquote'>
|
||||
<span>
|
||||
<q>{quote}</q>
|
||||
<footer className='quote-author blockquote-footer'>
|
||||
<cite>{author}</cite>
|
||||
</footer>
|
||||
</span>
|
||||
</blockquote>
|
||||
</Col>
|
||||
</Row>
|
||||
<Spacer />
|
||||
<Row>
|
||||
<Col sm={8} smOffset={2} xs={12}>
|
||||
<p className='stats'>
|
||||
You have completed <span>{completedChallengeCount}</span> of{' '}
|
||||
<span>1408</span> coding challenges.
|
||||
</p>
|
||||
<p className='stats'>
|
||||
You have built <span>{completedProjectCount}</span> of{' '}
|
||||
<span>30</span> projects.
|
||||
</p>
|
||||
{completedLegacyCertCount ? (
|
||||
<Grid className='text-center'>
|
||||
<Row>
|
||||
<Col xs={12}>
|
||||
<Spacer />
|
||||
<h1 className='big-heading'>Welcome {name ? name : 'Camper'}!</h1>
|
||||
</Col>
|
||||
</Row>
|
||||
<Spacer />
|
||||
<Row>
|
||||
<Col sm={8} smOffset={2} xs={12}>
|
||||
<a
|
||||
className='update-link'
|
||||
href='/n/7gR5pBM-K?refsource=userhome'
|
||||
target='_blank'
|
||||
>
|
||||
We're building a massive open dataset about new coders. Take the
|
||||
2018 New Coder Survey. It only takes 5 minutes.
|
||||
</a>
|
||||
</Col>
|
||||
</Row>
|
||||
<Spacer />
|
||||
<Row className='quote-partial'>
|
||||
<Col sm={10} smOffset={1} xs={12}>
|
||||
<blockquote className='blockquote'>
|
||||
<span>
|
||||
<q>{quote}</q>
|
||||
<footer className='quote-author blockquote-footer'>
|
||||
<cite>{author}</cite>
|
||||
</footer>
|
||||
</span>
|
||||
</blockquote>
|
||||
</Col>
|
||||
</Row>
|
||||
<Spacer />
|
||||
<Row>
|
||||
<Col sm={8} smOffset={2} xs={12}>
|
||||
<p className='stats'>
|
||||
You have earned <span>{completedLegacyCertCount}</span> of{' '}
|
||||
<span>4</span> legacy certifications.
|
||||
You have completed <span>{completedChallenges}</span> of{' '}
|
||||
<span>1408</span> coding challenges.
|
||||
</p>
|
||||
) : null}
|
||||
<p className='stats'>
|
||||
You have earned <span>{completedCertCount}</span> of{' '}
|
||||
<span>6</span> certifications.
|
||||
</p>
|
||||
</Col>
|
||||
</Row>
|
||||
<Spacer />
|
||||
<Row>
|
||||
<Col sm={8} smOffset={2} xs={12}>
|
||||
<Button block={true} bsStyle='primary' className='btn-cta-big'>
|
||||
Go to my next challenge
|
||||
</Button>
|
||||
</Col>
|
||||
</Row>
|
||||
<Spacer size={4} />
|
||||
</Grid>
|
||||
<p className='stats'>
|
||||
You have built <span>{completedProjectCount}</span> of{' '}
|
||||
<span>30</span> projects.
|
||||
</p>
|
||||
{completedLegacyCerts ? (
|
||||
<p className='stats'>
|
||||
You have earned <span>{completedLegacyCerts}</span> of{' '}
|
||||
<span>4</span> legacy certifications.
|
||||
</p>
|
||||
) : null}
|
||||
<p className='stats'>
|
||||
You have earned <span>{completedCertCount}</span> of{' '}
|
||||
<span>6</span> certifications.
|
||||
</p>
|
||||
</Col>
|
||||
</Row>
|
||||
<Spacer />
|
||||
<Row>
|
||||
<Col sm={8} smOffset={2} xs={12}>
|
||||
<Button block={true} bsStyle='primary' className='btn-cta-big'>
|
||||
Go to my next challenge
|
||||
</Button>
|
||||
</Col>
|
||||
</Row>
|
||||
<Spacer size={4} />
|
||||
</Grid>
|
||||
</main>
|
||||
</Layout>
|
||||
);
|
||||
|
Reference in New Issue
Block a user