Skip to content

Commit

Permalink
also check cookie to find user session
Browse files Browse the repository at this point in the history
  • Loading branch information
niclone committed Jun 21, 2017
1 parent 2854c57 commit 968751f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions webserver/routes/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,17 @@ func decodeParams(myroute *Route, rw http.ResponseWriter, r *http.Request) inter
func LoadSessionFromRequest(tx *sqlx.Tx, r *http.Request) *session.Session {
// session
token := r.Header.Get("Authorization")
log.Println("token ", token)
if len(token) == 0 {
cook, err := r.Cookie("arkeogis_session_token")
if err != nil {
token = cook.Value
}
}
//log.Println("token ", token)
s := session.GetSession(token)

log.Print("user id from session : ", s.GetIntDef("user_id", -1))
//fmt.Println("session: ", s)
//log.Print("user id from session : ", s.GetIntDef("user_id", -1))

// Retrieve user id from session
user := model.User{}
Expand Down

0 comments on commit 968751f

Please sign in to comment.