Commit fe72f200 authored by Jake Ols's avatar Jake Ols Committed by Amaury Martiny
Browse files

fix duplicate account names (#575)



* remove ability to create accounts with same account name

* add error message

* Update packages/fether-react/src/Accounts/CreateAccount/AccountName/AccountName.js
Co-Authored-By: default avatarThibaut Sardan <33178835+Tbaut@users.noreply.github.com>
parent 4cd2cfcf
Pipeline #56705 passed with stages
in 24 minutes and 9 seconds
......@@ -10,7 +10,9 @@ import { inject, observer } from 'mobx-react';
import i18n, { packageNS } from '../../../i18n';
import loading from '../../../assets/img/icons/loading.svg';
import withAccountsInfo from '../../../utils/withAccountsInfo';
@withAccountsInfo
@inject('createAccountStore')
@observer
class AccountName extends Component {
......@@ -115,9 +117,14 @@ class AccountName extends Component {
createAccountStore: { address, name },
error,
history,
location: { pathname }
location: { pathname },
accountsInfo
} = this.props;
const currentStep = pathname.slice(-1);
const accountNameExists = !!Object.values(accountsInfo).find(
info => info.name.toLowerCase() === name.toLowerCase()
);
return (
<form key='createAccount' noValidate onSubmit={this.handleSubmit}>
......@@ -133,6 +140,11 @@ class AccountName extends Component {
value={name}
/>
{error && <p>{error}</p>}
{accountNameExists && (
<p>
{i18n.t(`${packageNS}:account.create.error_msg_duplicate_name`)}
</p>
)}
<nav className='form-nav -space-around'>
{currentStep > 1 && (
<button
......@@ -143,7 +155,7 @@ class AccountName extends Component {
{i18n.t(`${packageNS}:navigation.back`)}
</button>
)}
{name && address ? (
{name && address && !accountNameExists ? (
<button className='button'>
{i18n.t(`${packageNS}:navigation.next`)}
</button>
......
......@@ -5,6 +5,7 @@
"label_name_msg": "Bitte geben Sie diesem Konto einen Namen:",
"label_name": "Name",
"title": "Ein neues Konto erstellen",
"error_msg_duplicate_name": "Ein Konto mit diesem Namen existiert.",
"copy_phrase": {
"msg1": "Bitte schreibe deinen geheimen Satz auf ein Blatt Papier:",
"msg2": "Behalte es sicher und geheim.",
......
......@@ -5,6 +5,7 @@
"label_name_msg": "Please give this account a name:",
"label_name": "Name",
"title": "Create a new account",
"error_msg_duplicate_name": "An account already exists with this name.",
"copy_phrase": {
"msg1": "Please write your secret phrase on a piece of paper:",
"msg2": "Keep it secure and secret.",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment