refactor(server): relocate user.getPasswordHashAlgorithm (#4101)

Trivial code movement, no effective code changes.
This commit is contained in:
Julio López
2024-09-09 17:00:07 -07:00
committed by GitHub
parent 72dcd65fb6
commit bdbdd404d9
2 changed files with 15 additions and 14 deletions

View File

@@ -1,18 +1,4 @@
package user
import "github.com/pkg/errors"
// defaultPasswordHashVersion is the default scheme used for user password hashing.
const defaultPasswordHashVersion = ScryptHashVersion
// getPasswordHashAlgorithm returns the password hash algorithm given a version.
func getPasswordHashAlgorithm(passwordHashVersion int) (string, error) {
switch passwordHashVersion {
case ScryptHashVersion:
return scryptHashAlgorithm, nil
case Pbkdf2HashVersion:
return pbkdf2HashAlgorithm, nil
default:
return "", errors.Errorf("unsupported hash version (%d)", passwordHashVersion)
}
}

View File

@@ -0,0 +1,15 @@
package user
import "github.com/pkg/errors"
// getPasswordHashAlgorithm returns the password hash algorithm given a version.
func getPasswordHashAlgorithm(passwordHashVersion int) (string, error) {
switch passwordHashVersion {
case ScryptHashVersion:
return scryptHashAlgorithm, nil
case Pbkdf2HashVersion:
return pbkdf2HashAlgorithm, nil
default:
return "", errors.Errorf("unsupported hash version (%d)", passwordHashVersion)
}
}