Skip to content

Commit ce966f0

Browse files
committed
add login check for /home
1 parent 7e21468 commit ce966f0

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/shared/components/buttons/themed/tc.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@
9999
border-radius: 25px !important;
100100
min-height: auto !important;
101101
padding: 0 30px !important;
102+
letter-spacing: 0.8px !important;
102103
}
103104

104105
@mixin secondary {

src/shared/containers/Dashboard/index.jsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
/* eslint-disable react/no-unused-prop-types */
22
/* eslint-disable no-unused-vars */
3+
/* eslint-disable no-restricted-globals */
4+
/* eslint-disable react/destructuring-assignment */
35
/**
46
* SlashTC index container
57
*/
6-
import React from 'react';
8+
import React, { useEffect } from 'react';
79
import PT from 'prop-types';
810
import { connect } from 'react-redux';
911
import { useMediaQuery } from 'react-responsive';
12+
import { isTokenExpired } from '@topcoder-platform/tc-auth-lib';
13+
import { config } from 'topcoder-react-utils';
1014
import Viewport from 'components/Contentful/Viewport';
1115
import TopcoderTime from 'components/Dashboard/TCTime';
1216
import ThriveArticlesFeedContainer from 'containers/Dashboard/ThriveArticlesFeed';
@@ -28,6 +32,14 @@ function SlashTCContainer(props) {
2832
const theme = THEMES.dark; // for v1 only dark theme
2933
const isTabletOrMobile = useMediaQuery({ maxWidth: 768 });
3034
const title = 'Home | Topcoder';
35+
36+
useEffect(() => {
37+
if (props.tokenV3 && !isTokenExpired(props.tokenV3)) return;
38+
let url = `retUrl=${encodeURIComponent(location.href)}`;
39+
url = `${config.URL.AUTH}/member?${url}&utm_source=community-app-home-page`;
40+
location.href = url;
41+
}, [props.tokenV3]);
42+
3143
return (
3244
<div className={theme.container}>
3345
<MetaTags
@@ -110,16 +122,19 @@ function SlashTCContainer(props) {
110122

111123
SlashTCContainer.defaultProps = {
112124
profile: null,
125+
tokenV3: null,
113126
};
114127

115128
SlashTCContainer.propTypes = {
116129
profile: PT.shape(),
130+
tokenV3: PT.string,
117131
};
118132

119133
function mapStateToProps(state) {
120134
const profile = state.auth && state.auth.profile ? { ...state.auth.profile } : {};
121135
return {
122136
profile,
137+
tokenV3: state.auth.tokenV3,
123138
};
124139
}
125140

0 commit comments

Comments
 (0)