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