MCPcopy
hub / github.com/filebrowser/filebrowser / loginHandler

Function loginHandler

http/auth.go:123–144  ·  view source on GitHub ↗
(tokenExpireTime time.Duration)

Source from the content-addressed store, hash-verified

121}
122
123func loginHandler(tokenExpireTime time.Duration) handleFunc {
124 return func(w http.ResponseWriter, r *http.Request, d *data) (int, error) {
125 if r.Body != nil {
126 r.Body = http.MaxBytesReader(w, r.Body, maxAuthBodySize)
127 }
128
129 auther, err := d.store.Auth.Get(d.settings.AuthMethod)
130 if err != nil {
131 return http.StatusInternalServerError, err
132 }
133
134 user, err := auther.Auth(r, d.store.Users, d.settings, d.server)
135 switch {
136 case errors.Is(err, os.ErrPermission):
137 return http.StatusForbidden, nil
138 case err != nil:
139 return http.StatusInternalServerError, err
140 }
141
142 return printToken(w, r, d, user, tokenExpireTime)
143 }
144}
145
146type signupBody struct {
147 Username string `json:"username"`

Callers 1

NewHandlerFunction · 0.85

Calls 3

printTokenFunction · 0.85
GetMethod · 0.65
AuthMethod · 0.65

Tested by

no test coverage detected