Satellite password check simplification (#1610)
This commit is contained in:
parent
63737e350f
commit
66a7d6bf3a
@ -5,15 +5,12 @@ package console
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
"unicode"
|
|
||||||
|
|
||||||
"github.com/zeebo/errs"
|
"github.com/zeebo/errs"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
passMinLength = 6
|
passMinLength = 6
|
||||||
passMinNumberCount = 1
|
|
||||||
passMinAZCount = 1
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// ErrValidation validation related error class
|
// ErrValidation validation related error class
|
||||||
@ -37,30 +34,6 @@ func (validation *validationErrors) Combine() error {
|
|||||||
return errs.Combine(*validation...)
|
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
|
// validatePassword validates password
|
||||||
func validatePassword(pass string) error {
|
func validatePassword(pass string) error {
|
||||||
var errs validationErrors
|
var errs validationErrors
|
||||||
@ -69,14 +42,6 @@ func validatePassword(pass string) error {
|
|||||||
errs.Add("password can't be less than %d characters", passMinLength)
|
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()
|
return errs.Combine()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@
|
|||||||
</svg>
|
</svg>
|
||||||
<div>
|
<div>
|
||||||
<h1>Change Password</h1>
|
<h1>Change Password</h1>
|
||||||
<h2>6 or more characters, at least 1 letter and number.</h2>
|
<h2>6 or more characters.</h2>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<HeaderlessInput
|
<HeaderlessInput
|
||||||
@ -273,7 +273,7 @@ import { validateEmail, validatePassword } from '@/utils/validation';
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!validatePassword(this.$data.newPassword)) {
|
if (!validatePassword(this.$data.newPassword)) {
|
||||||
this.$data.newPasswordError = 'Invalid password';
|
this.$data.newPasswordError = 'Invalid password. Use 6 or more characters';
|
||||||
hasError = true;
|
hasError = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
<div v-html='imageSource'></div>
|
<div v-html='imageSource'></div>
|
||||||
</div>
|
</div>
|
||||||
<div class='delete-account__form-container'>
|
<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
|
<HeaderedInput
|
||||||
label='Enter your password'
|
label='Enter your password'
|
||||||
placeholder='Your Password'
|
placeholder='Your Password'
|
||||||
|
@ -8,7 +8,5 @@ export function validateEmail(email: string): boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function validatePassword(password: string): boolean {
|
export function validatePassword(password: string): boolean {
|
||||||
const rgx = /^(?=.*[0-9])(?=.*[a-zA-Z])([a-zA-Z0-9]+){6,}$/;
|
return typeof password != 'undefined' && password.length >= 6;
|
||||||
|
|
||||||
return rgx.test(password);
|
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@
|
|||||||
</HeaderlessInput>
|
</HeaderlessInput>
|
||||||
<span
|
<span
|
||||||
v-html="infoImage"
|
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>
|
||||||
<div class="register-input">
|
<div class="register-input">
|
||||||
<HeaderlessInput
|
<HeaderlessInput
|
||||||
|
Loading…
Reference in New Issue
Block a user