MCPcopy
hub / github.com/filebrowser/filebrowser / Delete

Method Delete

users/storage.go:114–139  ·  view source on GitHub ↗

Delete allows you to delete a user by its name or username. The provided id must be a string for username lookup or a uint for id lookup. If id is neither, a ErrInvalidDataType will be returned.

(id interface{})

Source from the content-addressed store, hash-verified

112// id must be a string for username lookup or a uint for id lookup. If id
113// is neither, a ErrInvalidDataType will be returned.
114func (s *Storage) Delete(id interface{}) error {
115 switch id := id.(type) {
116 case string:
117 user, err := s.back.GetBy(id)
118 if err != nil {
119 return err
120 }
121 if s.IsUniqueAdmin(user) {
122 return fberrors.ErrRootUserDeletion
123 }
124
125 return s.back.DeleteByUsername(id)
126 case uint:
127 user, err := s.back.GetBy(id)
128 if err != nil {
129 return err
130 }
131 if s.IsUniqueAdmin(user) {
132 return fberrors.ErrRootUserDeletion
133 }
134
135 return s.back.DeleteByID(id)
136 default:
137 return fberrors.ErrInvalidDataType
138 }
139}
140
141// LastUpdate gets the timestamp for the last update of an user.
142func (s *Storage) LastUpdate(id uint) int64 {

Callers

nothing calls this directly

Calls 4

IsUniqueAdminMethod · 0.95
GetByMethod · 0.65
DeleteByUsernameMethod · 0.65
DeleteByIDMethod · 0.65

Tested by

no test coverage detected