bian
06/06/2023, 7:17 PMrp_st
06/06/2023, 7:20 PMrp_st
06/06/2023, 7:21 PMbian
06/06/2023, 7:21 PMbian
06/06/2023, 7:21 PMbian
06/06/2023, 7:21 PMrp_st
06/06/2023, 7:22 PMbian
06/06/2023, 7:23 PMrp_st
06/06/2023, 7:24 PMrp_st
06/06/2023, 7:26 PMbian
06/06/2023, 7:26 PMrp_st
06/06/2023, 7:27 PMrp_st
06/06/2023, 7:27 PMrp_st
06/06/2023, 7:27 PMbian
06/06/2023, 7:28 PMbian
06/06/2023, 7:28 PMrp_st
06/06/2023, 7:28 PMrp_st
06/06/2023, 7:28 PMbian
06/06/2023, 7:29 PMbian
06/06/2023, 7:29 PMrp_st
06/06/2023, 7:29 PMrp_st
06/06/2023, 7:29 PMbian
06/06/2023, 7:30 PMrp_st
06/06/2023, 7:30 PMrp_st
06/06/2023, 7:30 PMrp_st
06/06/2023, 7:31 PMrp_st
06/06/2023, 7:31 PMbian
06/06/2023, 7:33 PMrp_st
06/06/2023, 7:33 PMrp_st
06/06/2023, 7:33 PMrp_st
06/06/2023, 7:34 PMrp_st
06/06/2023, 7:35 PMbian
06/06/2023, 7:35 PMrp_st
06/06/2023, 7:35 PMbian
06/06/2023, 7:36 PMrp_st
06/06/2023, 7:36 PMrp_st
06/06/2023, 7:36 PMrp_st
06/06/2023, 7:36 PMbian
06/06/2023, 7:36 PMrp_st
06/06/2023, 7:36 PMrp_st
06/06/2023, 7:37 PMrp_st
06/06/2023, 7:37 PMrp_st
06/06/2023, 7:38 PMrp_st
06/06/2023, 7:38 PMbian
06/06/2023, 7:39 PMrp_st
06/06/2023, 7:39 PMrp_st
06/06/2023, 7:39 PMrp_st
06/06/2023, 7:40 PMrp_st
06/06/2023, 7:40 PMbian
06/06/2023, 7:41 PMrp_st
06/06/2023, 7:41 PMbian
06/06/2023, 7:41 PMbian
06/06/2023, 7:41 PMrp_st
06/06/2023, 7:41 PMbian
06/06/2023, 7:41 PMrp_st
06/06/2023, 7:42 PMrp_st
06/06/2023, 7:43 PMrp_st
06/06/2023, 7:43 PMbian
06/06/2023, 7:48 PMrp_st
06/07/2023, 6:04 AMtsx
Session.init({
override: {
functions: (oI) => {
return {
...oI,
getGlobalClaimValidators: function (input) {
// we first remove the default email verification validator
input.claimValidatorsAddedByOtherRecipes = input.claimValidatorsAddedByOtherRecipes.filter((validator) => {
return validator.id !== EmailVerification.EmailVerificationClaim.key;
})
// then we add the validator again with the new time values
// with checking for every 15 mins.
input.claimValidatorsAddedByOtherRecipes.push(EmailVerification.EmailVerificationClaim.validators.isVerified(undefined, 15 * 60));
return [...input.claimValidatorsAddedByOtherRecipes];
}
}
}
}
})
bian
06/07/2023, 10:18 AMbian
06/07/2023, 10:42 AMrp_st
06/07/2023, 11:17 AMrp_st
06/07/2023, 11:18 AMbian
06/07/2023, 11:20 AMexport class EmailVerificationClaimClass extends BooleanClaim {
constructor(
getRecipeImpl: () => RecipeInterface,
updateContextOnIsVerifiedFalse?: (userContext: any) => void | Promise<void>
) {
super({
id: "st-ev",
refresh: async (userContext) => {
await getRecipeImpl().isEmailVerified({
userContext,
});
},
});
rp_st
06/07/2023, 11:24 AMbian
06/07/2023, 11:24 AMrp_st
06/07/2023, 11:24 AMbian
06/07/2023, 11:24 AMrp_st
06/07/2023, 11:24 AMbian
06/07/2023, 11:25 AMbian
06/07/2023, 11:32 AMEmailVerification.getInstanceOrThrow()
?rp_st
06/07/2023, 11:32 AMtsx
let myCustomValidator = (refetchTimeOnFalseInSeconds?: number | undefined, maxAgeInSeconds?: number | undefined) => {
let isVerifiedValidator = EmailVerification.EmailVerificationClaim.validators.isVerified(refetchTimeOnFalseInSeconds, maxAgeInSeconds);
return {
...isVerifiedValidator,
shouldRefresh: (accessTokenPayload, userContext) => {
// TODO: custom logic here.
// See our default implementation of this function here:
// https://github.com/supertokens/supertokens-web-js/blob/master/lib/ts/recipe/emailverification/emailVerificationClaim.ts#L26
return false;
},
}
}
And then, iun the previous code snippet i sent (overriding getGlobalClaimValidators), you can add myCustomValidator
to the arrayrp_st
06/07/2023, 11:33 AMtrue
from shouldRefresh
only if you want the API to the called.bian
06/07/2023, 11:41 AMrp_st
06/07/2023, 11:41 AMbian
06/07/2023, 11:49 AM