Skip to content

Commit

Permalink
update session
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanTinianov committed Aug 10, 2023
1 parent 0609e60 commit a232c15
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
5 changes: 0 additions & 5 deletions auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"context"
"fmt"
legacyauth "github.com/dapperlabs/flow-playground-api/auth/legacy"
playgroundErrors "github.com/dapperlabs/flow-playground-api/middleware/errors"
"github.com/dapperlabs/flow-playground-api/middleware/sessions"
"github.com/dapperlabs/flow-playground-api/model"
"github.com/dapperlabs/flow-playground-api/storage"
Expand Down Expand Up @@ -73,8 +72,6 @@ func (a *Authenticator) GetOrCreateUser(ctx context.Context) (*model.User, error
} else {
userLoaded = true
}
} else {
return nil, playgroundErrors.NewAuthorizationError("userID is missing from existing session")
}
}

Expand All @@ -90,7 +87,6 @@ func (a *Authenticator) GetOrCreateUser(ctx context.Context) (*model.User, error

err = sessions.Save(ctx, session)
if err != nil {
fmt.Println("FAILED TO UPDATE SESSION")
return nil, errors.Wrap(err, "failed to update session")
}

Expand All @@ -111,7 +107,6 @@ func (a *Authenticator) CheckProjectAccess(ctx context.Context, proj *model.Proj
fmt.Println("No userIDKey in session")
return errors.New("no userIdKey found in session")
}
fmt.Println("session.Values[userIDKey].(string)", session.Values[userIDKey].(string))

user, err := a.getCurrentUser(session.Values[userIDKey].(string))
if err != nil {
Expand Down
7 changes: 5 additions & 2 deletions middleware/sessions/sessions.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,16 @@ func Middleware(store sessions.Store) func(http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ctx := context.WithValue(r.Context(), sessionCtxKeySession, store)

fmt.Println("Request: ", r.Header)
fmt.Println("Cookies:", r.Cookies())
if len(r.Cookies()) == 0 {
fmt.Println("COOKIES MISSING FROM REQUEST")
}

fmt.Println("Sessions Middleware Handler:")
session, err := store.Get(r, "flow-playground")
if err != nil {
fmt.Println(" error getting flow-playground session:", err.Error())
}

fmt.Println(" Session Values:", session.Values)
r = r.WithContext(ctx)

Expand Down

0 comments on commit a232c15

Please sign in to comment.