fix: linting errors

pull/5225/head
Henrique Dias 2025-06-28 10:03:17 +02:00
parent ad3bea31fb
commit 7a2573dfb8
No known key found for this signature in database
3 changed files with 7 additions and 5 deletions

View File

@ -28,7 +28,8 @@ func (a ProxyAuth) Auth(r *http.Request, usr users.Store, setting *settings.Sett
}
func (a ProxyAuth) createUser(usr users.Store, setting *settings.Settings, srv *settings.Server, username string) (*users.User, error) {
pwd, err := users.RandomPwd(setting.MinimumPasswordLength + 10)
const randomPasswordLength = settings.DefaultMinimumPasswordLength + 10
pwd, err := users.RandomPwd(randomPasswordLength)
if err != nil {
return nil, err
}

View File

@ -32,7 +32,7 @@ func addConfigFlags(flags *pflag.FlagSet) {
addUserFlags(flags)
flags.BoolP("signup", "s", false, "allow users to signup")
flags.Bool("create-user-dir", false, "generate user's home directory automatically")
flags.Uint("minimum-password-length", 12, "minimum password length for new users")
flags.Uint("minimum-password-length", settings.DefaultMinimumPasswordLength, "minimum password length for new users")
flags.String("shell", "", "shell command to which other commands should be appended")
flags.String("auth.method", string(auth.MethodJSONAuth), "authentication type")

View File

@ -4,14 +4,15 @@ import (
"crypto/rand"
"encoding/base64"
"github.com/filebrowser/filebrowser/v2/errors"
"golang.org/x/crypto/bcrypt"
fbErrors "github.com/filebrowser/filebrowser/v2/errors"
)
// HashPwd hashes a password.
func HashAndValidatePwd(password string, minimumLength uint) (string, error) {
if len(password) < int(minimumLength) {
return "", errors.ErrShortPassword
if uint(len(password)) < minimumLength {
return "", fbErrors.ErrShortPassword
}
return HashPwd(password)