Skip to content

Commit

Permalink
fix: preload teams on session
Browse files Browse the repository at this point in the history
  • Loading branch information
katallaxie committed Jun 17, 2024
1 parent 33ea3dd commit 3ee7e87
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion adapters/gorm/gorm.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ func (a *gormAdapter) CreateUser(ctx context.Context, user adapters.GothUser) (a
// GetSession is a helper function to retrieve a session by session token.
func (a *gormAdapter) GetSession(ctx context.Context, sessionToken string) (adapters.GothSession, error) {
var session adapters.GothSession
err := a.db.WithContext(ctx).Preload(clause.Associations).Where("session_token = ?", sessionToken).First(&session).Error
err := a.db.WithContext(ctx).
Preload(clause.Associations).
Preload("User.Teams").
Preload("User.Teams.Roles").
Where("session_token = ?", sessionToken).First(&session).Error
if err != nil {
return adapters.GothSession{}, goth.ErrMissingSession
}
Expand Down

0 comments on commit 3ee7e87

Please sign in to comment.