Save session for basic auth
This commit is contained in:
parent
60b4fa773c
commit
ab713f6662
@ -1,6 +1,7 @@
|
||||
package mux
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"github.com/Teajey/rsvp"
|
||||
@ -37,6 +38,12 @@ func (m *Serve) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
username, password, ok := r.BasicAuth()
|
||||
if ok {
|
||||
loggedIn := nil == routing.LoginMiddle(username, password, s, r)
|
||||
if s.WasWritten() {
|
||||
err := s.Save(r, w)
|
||||
if err != nil {
|
||||
log.Printf("Failed to save session: %s", err)
|
||||
}
|
||||
}
|
||||
if loggedIn {
|
||||
m.Private.ServeHTTP(w, r)
|
||||
return
|
||||
|
||||
Loading…
Reference in New Issue
Block a user