Change ValidateSession() to SessionIsActive() which only returns a bool
This commit is contained in:
parent
04283d5917
commit
5b417ef87d
@ -10,7 +10,7 @@ import (
|
||||
|
||||
func ServeImage(c *b.Config, s map[string]*f.Session) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
if _, err := f.ValidateSession(w, r, c, s); err != nil {
|
||||
if !f.SessionIsActive(r, s) {
|
||||
if !tokenIsVerified(w, r, c) {
|
||||
return
|
||||
}
|
||||
|
@ -66,18 +66,14 @@ func StartSessions() (map[string]*Session, chan string) {
|
||||
|
||||
// ValidateSession is used for verifying that the user is logged in and returns
|
||||
// their session and an error.
|
||||
func ValidateSession(w http.ResponseWriter, r *http.Request, c *b.Config, s map[string]*Session) (*Session, error) {
|
||||
func SessionIsActive(r *http.Request, s map[string]*Session) bool {
|
||||
cookie, err := r.Cookie("cpolis_session")
|
||||
if err != nil {
|
||||
return nil, errors.New("no cookie set")
|
||||
return false
|
||||
}
|
||||
|
||||
session, ok := s[cookie.Value]
|
||||
if !ok {
|
||||
return nil, errors.New("session does not exist")
|
||||
}
|
||||
|
||||
return session, nil
|
||||
_, ok := s[cookie.Value]
|
||||
return ok
|
||||
}
|
||||
|
||||
// ManageSession is used for verifying that the user is logged in and returns
|
||||
|
Loading…
x
Reference in New Issue
Block a user