Skip to content

Commit 3ce374b

Browse files
committed
fix: PR comments
1 parent 637149a commit 3ce374b

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

recipe/session/recipeImplementation.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -288,18 +288,22 @@ func makeRecipeImplementation(querier supertokens.Querier, config sessmodels.Typ
288288
return (*result.MergeIntoAccessTokenPayload)(sessionHandle, accessTokenPayloadUpdate, userContext)
289289
}
290290

291-
getClaimValue := func(sessionHandle string, claim *claims.TypeSessionClaim, userContext supertokens.UserContext) (interface{}, error) {
291+
getClaimValue := func(sessionHandle string, claim *claims.TypeSessionClaim, userContext supertokens.UserContext) (sessmodels.GetClaimValueResult, error) {
292292
sessionInfo, err := (*result.GetSessionInformation)(sessionHandle, userContext)
293293
if err != nil {
294-
return nil, err
294+
return sessmodels.GetClaimValueResult{}, err
295295
}
296296
if sessionInfo == nil {
297-
return nil, errors.UnauthorizedError{
298-
Msg: "session not found",
299-
}
297+
return sessmodels.GetClaimValueResult{
298+
SessionDoesNotExistError: &struct{}{},
299+
}, nil
300300
}
301301

302-
return claim.GetValueFromPayload(sessionInfo.AccessTokenPayload, userContext), nil
302+
return sessmodels.GetClaimValueResult{
303+
OK: &struct{ Value interface{} }{
304+
Value: claim.GetValueFromPayload(sessionInfo.AccessTokenPayload, userContext),
305+
},
306+
}, nil
303307
}
304308

305309
removeClaim := func(sessionHandle string, claim *claims.TypeSessionClaim, userContext supertokens.UserContext) (bool, error) {

recipe/session/sessmodels/claims.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,10 @@ type ValidateClaimsResponse struct {
1313
}
1414
SessionDoesNotExistError *struct{}
1515
}
16+
17+
type GetClaimValueResult struct {
18+
OK *struct {
19+
Value interface{}
20+
}
21+
SessionDoesNotExistError *struct{}
22+
}

recipe/session/sessmodels/recipeInterface.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@ type RecipeInterface struct {
4343
ValidateClaimsInJWTPayload *func(userId string, jwtPayload map[string]interface{}, claimValidators []claims.SessionClaimValidator, userContext supertokens.UserContext) ([]claims.ClaimValidationError, error) // TODO change return type
4444
FetchAndSetClaim *func(sessionHandle string, claim *claims.TypeSessionClaim, userContext supertokens.UserContext) (bool, error)
4545
SetClaimValue *func(sessionHandle string, claim *claims.TypeSessionClaim, value interface{}, userContext supertokens.UserContext) (bool, error)
46-
GetClaimValue *func(sessionHandle string, claim *claims.TypeSessionClaim, userContext supertokens.UserContext) (interface{}, error)
46+
GetClaimValue *func(sessionHandle string, claim *claims.TypeSessionClaim, userContext supertokens.UserContext) (GetClaimValueResult, error)
4747
RemoveClaim *func(sessionHandle string, claim *claims.TypeSessionClaim, userContext supertokens.UserContext) (bool, error)
4848
}

0 commit comments

Comments
 (0)