This commit is contained in:
parent
2d5b991812
commit
1261529101
|
@ -144,11 +144,13 @@ func VerifyPassword(storedHashedPassword, userProvidedPassword string) error {
|
||||||
|
|
||||||
// EncryptPassword is used for encrypting password
|
// EncryptPassword is used for encrypting password
|
||||||
func EncryptPassword(password string) (string, error) {
|
func EncryptPassword(password string) (string, error) {
|
||||||
// Try to generate bcrypt hash
|
pw, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)
|
||||||
passwordSHA256 := getSHA256(password)
|
|
||||||
pw, err := bcrypt.GenerateFromPassword([]byte(passwordSHA256), bcrypt.DefaultCost)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
password = getSHA256(password)
|
||||||
|
pw, err = bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return string(pw), nil
|
return string(pw), nil
|
||||||
|
|
Loading…
Reference in New Issue
Block a user