refactor: cleanup package names (#5605)

This commit is contained in:
Henrique Dias 2025-12-06 10:52:11 +01:00 committed by GitHub
parent a6934e40ff
commit f029c3005e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
33 changed files with 78 additions and 78 deletions

View file

@ -6,17 +6,17 @@ import (
"golang.org/x/crypto/bcrypt"
fbErrors "github.com/filebrowser/filebrowser/v2/errors"
fberrors "github.com/filebrowser/filebrowser/v2/errors"
)
// ValidateAndHashPwd validates and hashes a password.
func ValidateAndHashPwd(password string, minimumLength uint) (string, error) {
if uint(len(password)) < minimumLength {
return "", fbErrors.ErrShortPassword{MinimumLength: minimumLength}
return "", fberrors.ErrShortPassword{MinimumLength: minimumLength}
}
if _, ok := commonPasswords[password]; ok {
return "", fbErrors.ErrEasyPassword
return "", fberrors.ErrEasyPassword
}
return HashPwd(password)

View file

@ -4,7 +4,7 @@ import (
"sync"
"time"
"github.com/filebrowser/filebrowser/v2/errors"
fberrors "github.com/filebrowser/filebrowser/v2/errors"
)
// StorageBackend is the interface to implement for a users storage.
@ -109,16 +109,16 @@ func (s *Storage) Delete(id interface{}) error {
return err
}
if user.ID == 1 {
return errors.ErrRootUserDeletion
return fberrors.ErrRootUserDeletion
}
return s.back.DeleteByUsername(id)
case uint:
if id == 1 {
return errors.ErrRootUserDeletion
return fberrors.ErrRootUserDeletion
}
return s.back.DeleteByID(id)
default:
return errors.ErrInvalidDataType
return fberrors.ErrInvalidDataType
}
}

View file

@ -5,7 +5,7 @@ import (
"github.com/spf13/afero"
"github.com/filebrowser/filebrowser/v2/errors"
fberrors "github.com/filebrowser/filebrowser/v2/errors"
"github.com/filebrowser/filebrowser/v2/files"
"github.com/filebrowser/filebrowser/v2/rules"
)
@ -64,11 +64,11 @@ func (u *User) Clean(baseScope string, fields ...string) error {
switch field {
case "Username":
if u.Username == "" {
return errors.ErrEmptyUsername
return fberrors.ErrEmptyUsername
}
case "Password":
if u.Password == "" {
return errors.ErrEmptyPassword
return fberrors.ErrEmptyPassword
}
case "ViewMode":
if u.ViewMode == "" {