Add explicit login functionality
This commit is contained in:
@@ -49,19 +49,18 @@ type indexPage struct {
|
||||
MaxExpiry string
|
||||
DefaultExpiry string
|
||||
AbsBase string
|
||||
TokenName string // the remembered token's name, if there is one
|
||||
AllowVanity bool
|
||||
Stale bool // a remembered token that no longer exists
|
||||
MaxSizeBytes int64 // 0 when unlimited; the script checks against it
|
||||
Stale bool // a login whose token no longer exists
|
||||
}
|
||||
|
||||
func (s *Server) handleIndex(w http.ResponseWriter, r *http.Request) {
|
||||
// A remembered token is resolved server-side, so the page can show the real
|
||||
// limits without the cookie ever being readable by a script.
|
||||
remembered := cookieCredential(r)
|
||||
lim, err := s.limitsFor(remembered)
|
||||
lim, err := s.limitsFor(cookieCredential(r))
|
||||
stale := false
|
||||
if err != nil {
|
||||
// The token was revoked or the file was edited; drop the cookie rather
|
||||
// The token was revoked or the file was edited; end the session rather
|
||||
// than leave the caller wondering why uploads fail.
|
||||
s.forget(w, r)
|
||||
lim, stale = auth.Anonymous(s.cfg), true
|
||||
@@ -73,8 +72,8 @@ func (s *Server) handleIndex(w http.ResponseWriter, r *http.Request) {
|
||||
MaxExpiry: config.FormatDuration(lim.MaxExpiry),
|
||||
DefaultExpiry: config.FormatDuration(lim.DefaultExpiry),
|
||||
AbsBase: s.absBase(r),
|
||||
TokenName: lim.Name,
|
||||
AllowVanity: lim.AllowVanity,
|
||||
MaxSizeBytes: lim.MaxSize,
|
||||
Stale: stale,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user