Skip to content

Commit

Permalink
api: (auth) Include Account UUID with ContextValues
Browse files Browse the repository at this point in the history
  • Loading branch information
5HT2 committed Mar 20, 2023
1 parent 6555c27 commit c9573e5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 1 addition & 2 deletions api/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ func AuthMiddleware() func(next http.Handler) http.Handler {

// Set SessionClaims as the context value
rCtx := r.Context()
values := &models.ContextValues{SessionClaims: sessionClaims}
rCtx = context.WithValue(rCtx, models.ContextValuesKey, values)
rCtx = context.WithValue(rCtx, models.ContextValuesKey, &models.ContextValues{Account: sessionClaims.Account.UUID, SessionClaims: sessionClaims})
r = r.WithContext(rCtx)

ctx.Logger.Debugw("Successfully authenticated user", "account", sessionClaims.Account.UUID, "path", r.URL.Path)
Expand Down
5 changes: 5 additions & 0 deletions models/auth.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package models

import (
"github.com/google/uuid"
)

type ContextValues struct {
Account uuid.UUID
SessionClaims *SessionClaims
}

Expand Down

0 comments on commit c9573e5

Please sign in to comment.