chore: code adjustment (#512)

This commit is contained in:
Khanh Ngo 2023-12-29 10:56:37 +01:00 committed by GitHub
parent 8cfe9a3d5b
commit 45849a2aee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 79 additions and 69 deletions

View file

@ -2,6 +2,7 @@ package util
import (
"encoding/base64"
"errors"
"fmt"
"golang.org/x/crypto/bcrypt"
)
@ -20,7 +21,7 @@ func VerifyHash(base64Hash string, plaintext string) (bool, error) {
return false, fmt.Errorf("cannot decode base64 hash: %w", err)
}
err = bcrypt.CompareHashAndPassword(hash, []byte(plaintext))
if err == bcrypt.ErrMismatchedHashAndPassword {
if errors.Is(err, bcrypt.ErrMismatchedHashAndPassword) {
return false, nil
}
if err != nil {