Skip to content

Commit

Permalink
Add user to validate_session
Browse files Browse the repository at this point in the history
Resolves #379
  • Loading branch information
lakhansamani committed Aug 19, 2023
1 parent 5e6b033 commit a124edf
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 1,277 deletions.
1,275 changes: 0 additions & 1,275 deletions server/go.sum

Large diffs are not rendered by default.

104 changes: 104 additions & 0 deletions server/graph/generated/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion server/graph/model/models_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions server/graph/schema.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ type ValidateJWTTokenResponse {

type ValidateSessionResponse {
is_valid: Boolean!
user: User!
}

type GenerateJWTKeysResponse {
Expand Down
4 changes: 3 additions & 1 deletion server/resolvers/validate_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ func ValidateSessionResolver(ctx context.Context, params *model.ValidateSessionI
log := log.WithFields(log.Fields{
"user_id": userID,
})
_, err = db.Provider.GetUserByID(ctx, userID)
user, err := db.Provider.GetUserByID(ctx, userID)
if err != nil {
log.Debug("Failed to get user: ", err)
return nil, err
}
// refresh token has "roles" as claim
Expand All @@ -55,5 +56,6 @@ func ValidateSessionResolver(ctx context.Context, params *model.ValidateSessionI
}
return &model.ValidateSessionResponse{
IsValid: true,
User: user.AsAPIUser(),
}, nil
}
1 change: 1 addition & 0 deletions server/test/validate_session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ func validateSessionTests(t *testing.T, s TestSetup) {
res, err = resolvers.ValidateSessionResolver(ctx, &model.ValidateSessionInput{})
assert.Nil(t, err)
assert.True(t, res.IsValid)
assert.Equal(t, res.User.ID, verifyRes.User.ID)
cleanData(email)
})
}

0 comments on commit a124edf

Please sign in to comment.