MCPcopy Index your code
hub / github.com/filebrowser/filebrowser / Clean

Method Clean

users/users.go:58–99  ·  view source on GitHub ↗

Clean cleans up a user and verifies if all its fields are alright to be saved.

(baseScope string, followExternalSymlinks bool, fields ...string)

Source from the content-addressed store, hash-verified

56// Clean cleans up a user and verifies if all its fields
57// are alright to be saved.
58func (u *User) Clean(baseScope string, followExternalSymlinks bool, fields ...string) error {
59 if len(fields) == 0 {
60 fields = checkableFields
61 }
62
63 for _, field := range fields {
64 switch field {
65 case "Username":
66 if u.Username == "" {
67 return fberrors.ErrEmptyUsername
68 }
69 case "Password":
70 if u.Password == "" {
71 return fberrors.ErrEmptyPassword
72 }
73 case "ViewMode":
74 if u.ViewMode == "" {
75 u.ViewMode = ListViewMode
76 }
77 case "Commands":
78 if u.Commands == nil {
79 u.Commands = []string{}
80 }
81 case "Sorting":
82 if u.Sorting.By == "" {
83 u.Sorting.By = "name"
84 }
85 case "Rules":
86 if u.Rules == nil {
87 u.Rules = []rules.Rule{}
88 }
89 }
90 }
91
92 if u.Fs == nil {
93 scope := u.Scope
94 scope = filepath.Join(baseScope, filepath.Join("/", scope))
95 u.Fs = files.NewFs(afero.NewOsFs(), scope, followExternalSymlinks)
96 }
97
98 return nil
99}
100
101// FullPath gets the full path for a user's relative path.
102func (u *User) FullPath(path string) string {

Callers 15

TestUserCleanFsFunction · 0.95
GetMethod · 0.45
GetsMethod · 0.45
UpdateMethod · 0.45
SaveMethod · 0.45
OpenMethod · 0.45
StatMethod · 0.45
LstatIfPossibleMethod · 0.45
withinMethod · 0.45
NewHandlerFunction · 0.45
getSharesForAdminPathFunction · 0.45
public.goFile · 0.45

Calls 1

NewFsFunction · 0.92

Tested by 5

TestUserCleanFsFunction · 0.76
OpenMethod · 0.36
StatMethod · 0.36
LstatIfPossibleMethod · 0.36