accounts-frontend/packages/app/components/auth/recoverPassword/RecoverPasswordBody.tsx

90 lines
3.0 KiB
TypeScript
Raw Normal View History

import React from 'react';
import { defineMessages, FormattedMessage as Message } from 'react-intl';
import { Input } from 'app/components/ui/form';
import BaseAuthBody from 'app/components/auth/BaseAuthBody';
import styles from './recoverPassword.scss';
// TODO: activation code field may be decoupled into common component and reused here and in activation panel
const placeholders = defineMessages({
newPassword: 'Enter new password',
newRePassword: 'Repeat new password',
enterTheCode: 'Enter confirmation code',
});
export default class RecoverPasswordBody extends BaseAuthBody {
2020-05-24 04:38:24 +05:30
static displayName = 'RecoverPasswordBody';
static panelId = 'recoverPassword';
static hasGoBack = true;
2020-05-24 04:38:24 +05:30
autoFocusField = this.props.match.params && this.props.match.params.key ? 'newPassword' : 'key';
2020-05-24 04:38:24 +05:30
render() {
const { user } = this.context;
const { key } = this.props.match.params;
2020-05-24 04:38:24 +05:30
return (
<div>
{this.renderErrors()}
2020-05-24 04:38:24 +05:30
<p className={styles.descriptionText}>
{user.maskedEmail ? (
<Message
key="messageWasSentTo"
defaultMessage="The recovery code was sent to your Email {email}."
2020-05-24 04:38:24 +05:30
values={{
email: <b>{user.maskedEmail}</b>,
}}
/>
) : (
<Message
key="messageWasSent"
defaultMessage="The recovery code was sent to your account Email."
/>
2020-05-24 04:38:24 +05:30
)}{' '}
<Message
key="enterCodeBelow"
defaultMessage="Please enter the code received into the field below:"
/>
2020-05-24 04:38:24 +05:30
</p>
2020-05-24 04:38:24 +05:30
<Input
{...this.bindField('key')}
color="lightViolet"
center
required
value={key}
readOnly={!!key}
autoComplete="off"
placeholder={placeholders.enterTheCode}
2020-05-24 04:38:24 +05:30
/>
2020-05-24 04:38:24 +05:30
<p className={styles.descriptionText}>
<Message key="enterNewPasswordBelow" defaultMessage="Enter and repeat new password below:" />
2020-05-24 04:38:24 +05:30
</p>
2020-05-24 04:38:24 +05:30
<Input
{...this.bindField('newPassword')}
icon="key"
color="lightViolet"
type="password"
required
placeholder={placeholders.newPassword}
2020-05-24 04:38:24 +05:30
/>
2020-05-24 04:38:24 +05:30
<Input
{...this.bindField('newRePassword')}
icon="key"
color="lightViolet"
type="password"
required
placeholder={placeholders.newRePassword}
2020-05-24 04:38:24 +05:30
/>
</div>
);
}
}