fix: Add route for user to change own password (#1812)

This commit is contained in:
Garrett Delfosse
2022-05-27 17:29:55 +00:00
committed by GitHub
parent 608eb322a8
commit 24d1a6744a
6 changed files with 99 additions and 13 deletions
+16
View File
@@ -121,3 +121,19 @@ func hashWithSaltAndIter(password string, salt []byte, iter int) string {
return fmt.Sprintf("$%s$%d$%s$%s", hashScheme, iter, encSalt, encHash)
}
// Validate checks that the plain text password meets the minimum password requirements.
// It returns properly formatted errors for detailed form validation on the client.
func Validate(password string) error {
const (
minLength = 8
maxLength = 64
)
if len(password) < minLength {
return xerrors.Errorf("Password must be at least %d characters.", minLength)
}
if len(password) > maxLength {
return xerrors.Errorf("Password must be no more than %d characters.", maxLength)
}
return nil
}