Skip to content
Snippets Groups Projects
Commit fe058899 authored by Quoc Huy Nguyen Dinh's avatar Quoc Huy Nguyen Dinh
Browse files

Multiple dashes in username is valid

parent f578191d
No related branches found
No related tags found
2 merge requests!145Merge branch 'develop' into 'master',!144Multiple dashes in username is valid
import tt from 'counterpart'; import tt from 'counterpart';
import BadActorList from 'app/utils/BadActorList'; import BadActorList from 'app/utils/BadActorList';
import VerifiedExchangeList from 'app/utils/VerifiedExchangeList'; import VerifiedExchangeList from 'app/utils/VerifiedExchangeList';
import { PrivateKey, PublicKey } from '@hiveio/hive-js/lib/auth/ecc'; import { PrivateKey } from '@hiveio/hive-js/lib/auth/ecc';
export function validate_account_name(value) { export function validate_account_name(value) {
let i, label, len, length, ref; let i, label, len;
if (!value) { if (!value) {
return tt('chainvalidation_js.account_name_should_not_be_empty'); return tt('chainvalidation_js.account_name_should_not_be_empty');
} }
length = value.length; const length = value.length;
if (length < 3) { if (length < 3) {
return tt('chainvalidation_js.account_name_should_be_longer'); return tt('chainvalidation_js.account_name_should_be_longer');
} }
...@@ -19,8 +19,8 @@ export function validate_account_name(value) { ...@@ -19,8 +19,8 @@ export function validate_account_name(value) {
if (BadActorList.includes(value)) { if (BadActorList.includes(value)) {
return tt('chainvalidation_js.badactor'); return tt('chainvalidation_js.badactor');
} }
ref = value.split('.'); const ref = value.split('.');
for (i = 0, len = ref.length; i < len; i++) { for (i = 0, len = ref.length; i < len; i += 1) {
label = ref[i]; label = ref[i];
if (!/^[a-z]/.test(label)) { if (!/^[a-z]/.test(label)) {
return tt( return tt(
...@@ -32,17 +32,12 @@ export function validate_account_name(value) { ...@@ -32,17 +32,12 @@ export function validate_account_name(value) {
'chainvalidation_js.each_account_segment_should_have_only_letters_digits_or_dashes' 'chainvalidation_js.each_account_segment_should_have_only_letters_digits_or_dashes'
); );
} }
if (/--/.test(label)) {
return tt(
'chainvalidation_js.each_account_segment_should_have_only_one_dash_in_a_row'
);
}
if (!/[a-z0-9]$/.test(label)) { if (!/[a-z0-9]$/.test(label)) {
return tt( return tt(
'chainvalidation_js.each_account_segment_should_end_with_a_letter_or_digit' 'chainvalidation_js.each_account_segment_should_end_with_a_letter_or_digit'
); );
} }
if (!(label.length >= 3)) { if (label.length < 3) {
return tt( return tt(
'chainvalidation_js.each_account_segment_should_be_longer' 'chainvalidation_js.each_account_segment_should_be_longer'
); );
...@@ -67,7 +62,7 @@ export function validate_account_name_with_memo(name, memo) { ...@@ -67,7 +62,7 @@ export function validate_account_name_with_memo(name, memo) {
} }
export function validate_memo_field(value, username, memokey) { export function validate_memo_field(value, username, memokey) {
value = value.split(' ').filter((v) => v != ''); value = value.split(' ').filter((v) => v !== '');
for (const w in value) { for (const w in value) {
// Only perform key tests if it might be a key, i.e. it is a long string. // Only perform key tests if it might be a key, i.e. it is a long string.
if (value[w].length >= 39) { if (value[w].length >= 39) {
...@@ -77,12 +72,7 @@ export function validate_memo_field(value, username, memokey) { ...@@ -77,12 +72,7 @@ export function validate_memo_field(value, username, memokey) {
if (PrivateKey.isWif(value[w])) { if (PrivateKey.isWif(value[w])) {
return tt('chainvalidation_js.memo_is_privatekey'); return tt('chainvalidation_js.memo_is_privatekey');
} }
if ( if (memokey === PrivateKey.fromSeed(username + 'memo' + value[w]).toPublicKey().toString()) {
memokey ===
PrivateKey.fromSeed(username + 'memo' + value[w])
.toPublicKey()
.toString()
) {
return tt('chainvalidation_js.memo_is_password'); return tt('chainvalidation_js.memo_is_password');
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment