Skip to content

Commit

Permalink
fix(users): confirmation link is not working for logged in users
Browse files Browse the repository at this point in the history
close #2069
  • Loading branch information
batamar committed Jun 19, 2020
1 parent b7600bf commit 6cb66fe
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 13 deletions.
10 changes: 10 additions & 0 deletions ui/src/modules/settings/team/components/UserConfirmation.tsx
@@ -1,4 +1,5 @@
import { AuthBox } from 'modules/auth/styles';
import { IUser } from 'modules/auth/types';
import Button from 'modules/common/components/Button';
import FormControl from 'modules/common/components/form/Control';
import FormGroup from 'modules/common/components/form/Group';
Expand All @@ -21,6 +22,7 @@ class Confirmation extends React.Component<{
username: string;
}
) => void;
currentUser?: IUser;
}> {
onSubmit = e => {
e.preventDefault();
Expand Down Expand Up @@ -76,6 +78,14 @@ class Confirmation extends React.Component<{
}

render() {
if (this.props.currentUser) {
return (
<div style={{ width: '50%', margin: 'auto' }}>
{this.renderContent()}
</div>
);
}

return <AuthLayout content={this.renderContent()} />;
}
}
Expand Down
12 changes: 10 additions & 2 deletions ui/src/modules/settings/team/containers/UserConfirmation.tsx
@@ -1,5 +1,6 @@
import gql from 'graphql-tag';
import * as compose from 'lodash.flowright';
import { IUser } from 'modules/auth/types';
import { Alert, withProps } from 'modules/common/utils';
import React from 'react';
import { graphql } from 'react-apollo';
Expand All @@ -11,13 +12,19 @@ import { ConfirmMutationResponse, ConfirmMutationVariables } from '../types';

type Props = {
queryParams: any;
currentUser?: IUser;
};

type FinalProps = Props & IRouterProps & ConfirmMutationResponse;

class UserConfirmationContainer extends React.Component<FinalProps> {
render() {
const { usersConfirmInvitation, queryParams, history } = this.props;
const {
usersConfirmInvitation,
queryParams,
history,
currentUser
} = this.props;

const confirmUser = ({
password,
Expand Down Expand Up @@ -49,7 +56,8 @@ class UserConfirmationContainer extends React.Component<FinalProps> {
};

const updatedProps = {
confirmUser
confirmUser,
currentUser
};

return <UserConfirmation {...updatedProps} />;
Expand Down
10 changes: 0 additions & 10 deletions ui/src/modules/settings/team/routes.tsx
Expand Up @@ -3,10 +3,6 @@ import queryString from 'query-string';
import React from 'react';
import { Route } from 'react-router-dom';

const UserConfirmation = asyncComponent(() =>
import(/* webpackChunkName: "Settings - UserConfirmation" */ './containers/UserConfirmation')
);

const UserDetail = asyncComponent(() =>
import(/* webpackChunkName: "Settings - UserDetail" */ './containers/UserDetailForm')
);
Expand All @@ -27,12 +23,6 @@ const userDetail = ({ match, location }) => {
return <UserDetail _id={id} queryParams={queryParams} />;
};

export const userConfirmation = ({ location }) => {
const queryParams = queryString.parse(location.search);

return <UserConfirmation queryParams={queryParams} />;
};

const routes = () => (
<React.Fragment>
<Route
Expand Down
20 changes: 19 additions & 1 deletion ui/src/routes.tsx
@@ -1,6 +1,5 @@
import withCurrentUser from 'modules/auth/containers/withCurrentUser';
import asyncComponent from 'modules/common/components/AsyncComponent';
import { userConfirmation } from 'modules/settings/team/routes';
import queryString from 'query-string';
import React from 'react';
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';
Expand Down Expand Up @@ -33,13 +32,25 @@ const Unsubscribe = asyncComponent(() =>
import(/* webpackChunkName: "Unsubscribe" */ 'modules/auth/containers/Unsubscribe')
);

const UserConfirmation = asyncComponent(() =>
import(/* webpackChunkName: "Settings - UserConfirmation" */ 'modules/settings/team/containers/UserConfirmation')
);

export const unsubscribe = ({ location }) => {
const queryParams = queryString.parse(location.search);

return <Unsubscribe queryParams={queryParams} />;
};

const renderRoutes = currentUser => {
const userConfirmation = ({ location }) => {
const queryParams = queryString.parse(location.search);

return (
<UserConfirmation queryParams={queryParams} currentUser={currentUser} />
);
};

if (currentUser) {
return (
<>
Expand All @@ -62,6 +73,13 @@ const renderRoutes = currentUser => {
<VideoCallRoutes />
<TutorialRoutes />
<DashboardRoutes />

<Route
key="/confirmation"
exact={true}
path="/confirmation"
component={userConfirmation}
/>
</MainLayout>
</>
);
Expand Down

0 comments on commit 6cb66fe

Please sign in to comment.