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) { 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 { if err != nil {
return nil, err return nil, err
} }

View File

@ -32,7 +32,7 @@ func addConfigFlags(flags *pflag.FlagSet) {
addUserFlags(flags) addUserFlags(flags)
flags.BoolP("signup", "s", false, "allow users to signup") flags.BoolP("signup", "s", false, "allow users to signup")
flags.Bool("create-user-dir", false, "generate user's home directory automatically") 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("shell", "", "shell command to which other commands should be appended")
flags.String("auth.method", string(auth.MethodJSONAuth), "authentication type") flags.String("auth.method", string(auth.MethodJSONAuth), "authentication type")

View File

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