Satellite password check simplification (#1610)
This commit is contained in:
parent
63737e350f
commit
66a7d6bf3a
@ -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()
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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'
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user