Satellite password check simplification (#1610)

This commit is contained in:
Yehor Butko 2019-03-29 19:42:20 +02:00 committed by GitHub
parent 63737e350f
commit 66a7d6bf3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 6 additions and 43 deletions

View File

@ -5,15 +5,12 @@ package console
import (
"strings"
"unicode"
"github.com/zeebo/errs"
)
const (
passMinLength = 6
passMinNumberCount = 1
passMinAZCount = 1
passMinLength = 6
)
// ErrValidation validation related error class
@ -37,30 +34,6 @@ func (validation *validationErrors) Combine() error {
return errs.Combine(*validation...)
}
// countNumerics returns total number of digits in string
func countNumerics(s string) int {
total := 0
for _, r := range s {
if unicode.IsDigit(r) {
total++
}
}
return total
}
// countLetters returns total number of letters in string
func countLetters(s string) int {
total := 0
for _, r := range s {
if unicode.IsLetter(r) {
total++
}
}
return total
}
// validatePassword validates password
func validatePassword(pass string) error {
var errs validationErrors
@ -69,14 +42,6 @@ func validatePassword(pass string) error {
errs.Add("password can't be less than %d characters", passMinLength)
}
if countNumerics(pass) < passMinNumberCount {
errs.Add("password should contain at least %d digits", passMinNumberCount)
}
if countLetters(pass) < passMinAZCount {
errs.Add("password should contain at least %d alphabetic characters", passMinAZCount)
}
return errs.Combine()
}

View File

@ -69,7 +69,7 @@
</svg>
<div>
<h1>Change Password</h1>
<h2>6 or more characters, at least 1 letter and number.</h2>
<h2>6 or more characters.</h2>
</div>
</div>
<HeaderlessInput
@ -273,7 +273,7 @@ import { validateEmail, validatePassword } from '@/utils/validation';
}
if (!validatePassword(this.$data.newPassword)) {
this.$data.newPasswordError = 'Invalid password';
this.$data.newPasswordError = 'Invalid password. Use 6 or more characters';
hasError = true;
}

View File

@ -9,7 +9,7 @@
<div v-html='imageSource'></div>
</div>
<div class='delete-account__form-container'>
<p>Are you sure you want to delete your account? If you do so, all your information, projects and API Keys will be deleted from the Satellite forever.</p>
<p>Are you sure you want to delete your account? If you do so, all your account information will be deleted from the Satellite forever.</p>
<HeaderedInput
label='Enter your password'
placeholder='Your Password'

View File

@ -8,7 +8,5 @@ export function validateEmail(email: string): boolean {
}
export function validatePassword(password: string): boolean {
const rgx = /^(?=.*[0-9])(?=.*[a-zA-Z])([a-zA-Z0-9]+){6,}$/;
return rgx.test(password);
return typeof password != 'undefined' && password.length >= 6;
}

View File

@ -63,7 +63,7 @@
</HeaderlessInput>
<span
v-html="infoImage"
title="Use 6 or more characters with a mix of letters and numbers"></span>
title="Use 6 or more characters"></span>
</div>
<div class="register-input">
<HeaderlessInput