Skip to content

Commit

Permalink
Added email confirmation page (#3573)
Browse files Browse the repository at this point in the history
* Added email confirmation page
  • Loading branch information
Spectre-ak authored Sep 23, 2021
1 parent f3e09cd commit a162a65
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 2 deletions.
4 changes: 4 additions & 0 deletions cvat-ui/src/components/cvat-app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import showPlatformNotification, {
showUnsupportedNotification,
} from 'utils/platform-checker';
import '../styles.scss';
import EmailConfirmationPage from './email-confirmation-page/email-confirmed';

interface CVATAppProps {
loadFormats: () => void;
Expand Down Expand Up @@ -381,6 +382,9 @@ class CVATApplication extends React.PureComponent<CVATAppProps & RouteComponentP
path='/auth/password/reset/confirm'
component={ResetPasswordPageConfirmComponent}
/>

<Route exact path='/auth/email-confirmation' component={EmailConfirmationPage} />

<Redirect
to={location.pathname.length > 1 ? `/auth/login/?next=${location.pathname}` : '/auth/login'}
/>
Expand Down
39 changes: 39 additions & 0 deletions cvat-ui/src/components/email-confirmation-page/email-confirmed.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright (C) 2021 Intel Corporation
//
// SPDX-License-Identifier: MIT

import React, { useRef } from 'react';
import { Link } from 'react-router-dom';
import { Col, Row } from 'antd/lib/grid';
import Layout from 'antd/lib/layout';
import Statistic from 'antd/lib/statistic';
import './styles.scss';

const { Content } = Layout;
const { Countdown } = Statistic;

/**
* Component for displaying email confirmation message and then redirecting to the login page
*/

function EmailConfirmationPage(): JSX.Element {
const linkRef = useRef();
const onFinish = () => {
linkRef.current.click();
};
return (
<Layout>
<Content>
<Row justify='center' align='middle' id='email-confirmation-page-container'>
<Col>
<h1>Your email is confirmed</h1>
<Countdown format='ss' title='Redirecting to login page after...' value={Date.now() + 1000 * 6} onFinish={onFinish} />
<Link to='/auth/login' ref={linkRef}>Or click this link</Link>
</Col>
</Row>
</Content>
</Layout>
);
}

export default EmailConfirmationPage;
8 changes: 8 additions & 0 deletions cvat-ui/src/components/email-confirmation-page/styles.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright (C) 2021 Intel Corporation
//
// SPDX-License-Identifier: MIT

#email-confirmation-page-container {
height: 100%;
text-align: center;
}
4 changes: 3 additions & 1 deletion cvat/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,9 @@ def add_ssh_keys():
# https://github.com/pennersr/django-allauth
ACCOUNT_EMAIL_VERIFICATION = 'none'
# set UI url to redirect after a successful e-mail confirmation
ACCOUNT_EMAIL_CONFIRMATION_ANONYMOUS_REDIRECT_URL = '/auth/login'
#changed from '/auth/login' to '/auth/email-confirmation' for email confirmation message
ACCOUNT_EMAIL_CONFIRMATION_ANONYMOUS_REDIRECT_URL = '/auth/email-confirmation'

OLD_PASSWORD_FIELD_ENABLED = True

# Django-RQ
Expand Down
2 changes: 1 addition & 1 deletion cvat/settings/development.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
if UI_PORT and UI_PORT != '80':
UI_URL += ':{}'.format(UI_PORT)
# set UI url to redirect to after successful e-mail confirmation
ACCOUNT_EMAIL_CONFIRMATION_ANONYMOUS_REDIRECT_URL = '{}/auth/login'.format(UI_URL)
ACCOUNT_EMAIL_CONFIRMATION_ANONYMOUS_REDIRECT_URL = '{}/auth/email-confirmation'.format(UI_URL)

CORS_ORIGIN_WHITELIST = [UI_URL]
CORS_REPLACE_HTTPS_REFERER = True

0 comments on commit a162a65

Please sign in to comment.