66 "github.com/supertokens/supertokens-golang/supertokens"
77)
88
9- func PrimitiveArrayClaim (key string , fetchValue FetchValueFunc , defaultMaxAgeInSeconds * int64 ) * TypePrimitiveArrayClaim {
9+ func PrimitiveArrayClaim (key string , fetchValue FetchValueFunc , defaultMaxAgeInSeconds * int64 ) ( * TypeSessionClaim , * PrimitiveArrayClaimValidators ) {
1010 if defaultMaxAgeInSeconds == nil {
1111 val := int64 (300 )
1212 defaultMaxAgeInSeconds = & val
@@ -47,11 +47,7 @@ func PrimitiveArrayClaim(key string, fetchValue FetchValueFunc, defaultMaxAgeInS
4747 return nil
4848 }
4949
50- primitiveArrayClaim := & TypePrimitiveArrayClaim {
51- TypeSessionClaim : sessionClaim ,
52- }
53-
54- primitiveArrayClaim .Validators = & PrimitiveArrayClaimValidators {
50+ validators := & PrimitiveArrayClaimValidators {
5551 Includes : func (val interface {}, maxAgeInSeconds * int64 , id * string ) * SessionClaimValidator {
5652 if maxAgeInSeconds == nil {
5753 maxAgeInSeconds = defaultMaxAgeInSeconds
@@ -64,17 +60,17 @@ func PrimitiveArrayClaim(key string, fetchValue FetchValueFunc, defaultMaxAgeInS
6460 ID : claimId ,
6561 Claim : sessionClaim ,
6662 ShouldRefetch : func (payload map [string ]interface {}, userContext supertokens.UserContext ) bool {
67- claimVal , ok := primitiveArrayClaim .GetValueFromPayload (payload , userContext ).([]interface {})
63+ claimVal , ok := sessionClaim .GetValueFromPayload (payload , userContext ).([]interface {})
6864 if ! ok || claimVal == nil {
6965 return true
7066 }
7167 if maxAgeInSeconds != nil {
72- return * primitiveArrayClaim .GetLastRefetchTime (payload , userContext ) < time .Now ().UnixMilli ()- * maxAgeInSeconds * 1000
68+ return * sessionClaim .GetLastRefetchTime (payload , userContext ) < time .Now ().UnixMilli ()- * maxAgeInSeconds * 1000
7369 }
7470 return false
7571 },
7672 Validate : func (payload map [string ]interface {}, userContext supertokens.UserContext ) ClaimValidationResult {
77- claimVal := primitiveArrayClaim .GetValueFromPayload (payload , userContext ).([]interface {})
73+ claimVal := sessionClaim .GetValueFromPayload (payload , userContext ).([]interface {})
7874
7975 if claimVal == nil {
8076 return ClaimValidationResult {
@@ -86,7 +82,7 @@ func PrimitiveArrayClaim(key string, fetchValue FetchValueFunc, defaultMaxAgeInS
8682 },
8783 }
8884 }
89- ageInSeconds := (time .Now ().UnixMilli () - * primitiveArrayClaim .GetLastRefetchTime (payload , userContext )) / 1000
85+ ageInSeconds := (time .Now ().UnixMilli () - * sessionClaim .GetLastRefetchTime (payload , userContext )) / 1000
9086 if maxAgeInSeconds != nil && ageInSeconds > * maxAgeInSeconds {
9187 return ClaimValidationResult {
9288 IsValid : false ,
@@ -125,17 +121,17 @@ func PrimitiveArrayClaim(key string, fetchValue FetchValueFunc, defaultMaxAgeInS
125121 ID : claimId ,
126122 Claim : sessionClaim ,
127123 ShouldRefetch : func (payload map [string ]interface {}, userContext supertokens.UserContext ) bool {
128- val , ok := primitiveArrayClaim .GetValueFromPayload (payload , userContext ).([]interface {})
124+ val , ok := sessionClaim .GetValueFromPayload (payload , userContext ).([]interface {})
129125 if ! ok || val == nil {
130126 return true
131127 }
132128 if maxAgeInSeconds != nil {
133- return * primitiveArrayClaim .GetLastRefetchTime (payload , userContext ) < time .Now ().UnixMilli ()- * maxAgeInSeconds * 1000
129+ return * sessionClaim .GetLastRefetchTime (payload , userContext ) < time .Now ().UnixMilli ()- * maxAgeInSeconds * 1000
134130 }
135131 return false
136132 },
137133 Validate : func (payload map [string ]interface {}, userContext supertokens.UserContext ) ClaimValidationResult {
138- claimVal := primitiveArrayClaim .GetValueFromPayload (payload , userContext ).([]interface {})
134+ claimVal := sessionClaim .GetValueFromPayload (payload , userContext ).([]interface {})
139135
140136 if claimVal == nil {
141137 return ClaimValidationResult {
@@ -147,7 +143,7 @@ func PrimitiveArrayClaim(key string, fetchValue FetchValueFunc, defaultMaxAgeInS
147143 },
148144 }
149145 }
150- ageInSeconds := (time .Now ().UnixMilli () - * primitiveArrayClaim .GetLastRefetchTime (payload , userContext )) / 1000
146+ ageInSeconds := (time .Now ().UnixMilli () - * sessionClaim .GetLastRefetchTime (payload , userContext )) / 1000
151147 if maxAgeInSeconds != nil && ageInSeconds > * maxAgeInSeconds {
152148 return ClaimValidationResult {
153149 IsValid : false ,
@@ -186,17 +182,17 @@ func PrimitiveArrayClaim(key string, fetchValue FetchValueFunc, defaultMaxAgeInS
186182 ID : claimId ,
187183 Claim : sessionClaim ,
188184 ShouldRefetch : func (payload map [string ]interface {}, userContext supertokens.UserContext ) bool {
189- val , ok := primitiveArrayClaim .GetValueFromPayload (payload , userContext ).([]interface {})
185+ val , ok := sessionClaim .GetValueFromPayload (payload , userContext ).([]interface {})
190186 if ! ok || val == nil {
191187 return true
192188 }
193189 if maxAgeInSeconds != nil {
194- return * primitiveArrayClaim .GetLastRefetchTime (payload , userContext ) < time .Now ().UnixMilli ()- * maxAgeInSeconds * 1000
190+ return * sessionClaim .GetLastRefetchTime (payload , userContext ) < time .Now ().UnixMilli ()- * maxAgeInSeconds * 1000
195191 }
196192 return false
197193 },
198194 Validate : func (payload map [string ]interface {}, userContext supertokens.UserContext ) ClaimValidationResult {
199- claimVal := primitiveArrayClaim .GetValueFromPayload (payload , userContext ).([]interface {})
195+ claimVal := sessionClaim .GetValueFromPayload (payload , userContext ).([]interface {})
200196
201197 if claimVal == nil {
202198 return ClaimValidationResult {
@@ -208,7 +204,7 @@ func PrimitiveArrayClaim(key string, fetchValue FetchValueFunc, defaultMaxAgeInS
208204 },
209205 }
210206 }
211- ageInSeconds := (time .Now ().UnixMilli () - * primitiveArrayClaim .GetLastRefetchTime (payload , userContext )) / 1000
207+ ageInSeconds := (time .Now ().UnixMilli () - * sessionClaim .GetLastRefetchTime (payload , userContext )) / 1000
212208 if maxAgeInSeconds != nil && ageInSeconds > * maxAgeInSeconds {
213209 return ClaimValidationResult {
214210 IsValid : false ,
@@ -248,17 +244,17 @@ func PrimitiveArrayClaim(key string, fetchValue FetchValueFunc, defaultMaxAgeInS
248244 ID : claimId ,
249245 Claim : sessionClaim ,
250246 ShouldRefetch : func (payload map [string ]interface {}, userContext supertokens.UserContext ) bool {
251- val , ok := primitiveArrayClaim .GetValueFromPayload (payload , userContext ).([]interface {})
247+ val , ok := sessionClaim .GetValueFromPayload (payload , userContext ).([]interface {})
252248 if ! ok || val == nil {
253249 return true
254250 }
255251 if maxAgeInSeconds != nil {
256- return * primitiveArrayClaim .GetLastRefetchTime (payload , userContext ) < time .Now ().UnixMilli ()- * maxAgeInSeconds * 1000
252+ return * sessionClaim .GetLastRefetchTime (payload , userContext ) < time .Now ().UnixMilli ()- * maxAgeInSeconds * 1000
257253 }
258254 return false
259255 },
260256 Validate : func (payload map [string ]interface {}, userContext supertokens.UserContext ) ClaimValidationResult {
261- claimVal := primitiveArrayClaim .GetValueFromPayload (payload , userContext ).([]interface {})
257+ claimVal := sessionClaim .GetValueFromPayload (payload , userContext ).([]interface {})
262258
263259 if claimVal == nil {
264260 return ClaimValidationResult {
@@ -270,7 +266,7 @@ func PrimitiveArrayClaim(key string, fetchValue FetchValueFunc, defaultMaxAgeInS
270266 },
271267 }
272268 }
273- ageInSeconds := (time .Now ().UnixMilli () - * primitiveArrayClaim .GetLastRefetchTime (payload , userContext )) / 1000
269+ ageInSeconds := (time .Now ().UnixMilli () - * sessionClaim .GetLastRefetchTime (payload , userContext )) / 1000
274270 if maxAgeInSeconds != nil && ageInSeconds > * maxAgeInSeconds {
275271 return ClaimValidationResult {
276272 IsValid : false ,
@@ -300,12 +296,7 @@ func PrimitiveArrayClaim(key string, fetchValue FetchValueFunc, defaultMaxAgeInS
300296 },
301297 }
302298
303- return primitiveArrayClaim
304- }
305-
306- type TypePrimitiveArrayClaim struct {
307- * TypeSessionClaim
308- Validators * PrimitiveArrayClaimValidators
299+ return sessionClaim , validators
309300}
310301
311302type PrimitiveArrayClaimValidators struct {
0 commit comments