Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove passage client initialization from sign-up screen #4642

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions __tests__/SignUp.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('Signup', () => {
await findByText(/create your giant swarm account/i);
});

it('checks invite token on route load', async () => {
it.skip('checks invite token on route load', async () => {
nock(global.config.passageEndpoint)
.get(tokenTestPath)
.reply(StatusCodes.Ok, {
Expand All @@ -52,7 +52,7 @@ describe('Signup', () => {
});
});

it('displays a warning if the invite token is no longer valid', async () => {
it.skip('displays a warning if the invite token is no longer valid', async () => {
nock(global.config.passageEndpoint)
.get(tokenTestPath)
.reply(StatusCodes.Ok, {
Expand All @@ -73,7 +73,7 @@ describe('Signup', () => {
});
});

it('registers a new user if the token is valid', async () => {
it.skip('registers a new user if the token is valid', async () => {
getMockCall('/v4/user/', userResponse);
getMockCall('/v4/organizations/');
getMockCall('/v4/clusters/');
Expand Down Expand Up @@ -212,7 +212,7 @@ describe('Signup', () => {
await findByText(/there are no organizations yet in your installation./i);
});

it('displays a warning if the user creation request fails', async () => {
it.skip('displays a warning if the user creation request fails', async () => {
nock(global.config.passageEndpoint)
.get(tokenTestPath)
.reply(StatusCodes.Ok, {
Expand Down
74 changes: 0 additions & 74 deletions src/components/SignUp/SignUp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ import styled from 'styled-components';
import Button from 'UI/Controls/Button';
import CheckBoxInput from 'UI/Inputs/CheckBoxInput';
import TextInput from 'UI/Inputs/TextInput';
import ErrorReporter from 'utils/errors/ErrorReporter';
import { FlashMessage, messageTTL, messageType } from 'utils/flashMessage';
import Passage from 'utils/passageClient';
import { validatePassword } from 'utils/passwordValidation';

import StatusMessage from './StatusMessage';
Expand Down Expand Up @@ -101,8 +99,6 @@ const Wrapper = styled('div')`
}
`;

const passage = new Passage({ endpoint: window.config.passageEndpoint });

interface MatchParams {
token: string;
}
Expand Down Expand Up @@ -176,49 +172,6 @@ class SignUp extends React.Component<ISignUpProps, ISignUpState> {

componentDidMount() {
this.isComponentMounted = true;
const token = this.props.match.params.token;
const statusMessageChangeTimeout = 800;

passage
.checkInvite({ token })
.then((data) => {
this.setState({
email: data.email,
statusMessage: 'verify_completed',
// eslint-disable-next-line react/no-unused-state
checkInviteStatus: 'completed',
});

setTimeout(() => {
if (this.isComponentMounted) {
this.setState({
statusMessage: 'enter_password',
});

this.advanceForm();
}
}, statusMessageChangeTimeout);
})
.catch((error) => {
this.setState({
// eslint-disable-next-line react/no-unused-state
checkInviteStatus: 'failed',
});

let statusMessage = 'verify_failed';

if (error.message === 'InvalidToken') {
statusMessage = 'invalid_token';
}

this.setState({
statusMessage: statusMessage,
});

if (error.message !== 'InvalidToken') {
ErrorReporter.getInstance().notify(error as Error);
}
});
}

componentDidUpdate(prevProps: ISignUpProps) {
Expand Down Expand Up @@ -284,33 +237,6 @@ class SignUp extends React.Component<ISignUpProps, ISignUpState> {
statusMessage: 'create_account_starting',
submitting: true,
});

passage
.createAccount({
inviteToken: this.props.match.params.token,
password: this.state.passwordField.value,
})
.then((data) => {
this.setState({
statusMessage: 'create_account_completed',
});

return this.props.actions.giantswarmLogin(
data.email,
this.state.passwordField.value
);
})
.then(() => {
this.accountCreated();
})
.catch((err) => {
this.setState({
statusMessage: 'create_account_failed',
submitting: false,
});

ErrorReporter.getInstance().notify(err as Error);
});
} else {
this.advanceForm();
}
Expand Down
Loading