@@ -448,12 +448,25 @@ <h1 class="title">Module <code>supertokens_python.recipe.emailverification.recip
448448 if isinstance(
449449 response, CreateEmailVerificationTokenEmailAlreadyVerifiedError
450450 ):
451+ if await session.get_claim_value(EmailVerificationClaim) is not True:
452+ # this can happen if the email was "verified" in another browser
453+ # and this session is still outdated - and the user has not
454+ # called the get email verification API yet.
455+ await session.fetch_and_set_claim(
456+ EmailVerificationClaim, user_context
457+ )
451458 log_debug_message(
452459 "Email verification email not sent to %s because it is already verified.",
453460 email_info.email,
454461 )
455462 return GenerateEmailVerifyTokenPostEmailAlreadyVerifiedError()
456463
464+ if await session.get_claim_value(EmailVerificationClaim) is not False:
465+ # this can happen if the email was "unverified" in another browser
466+ # and this session is still outdated - and the user has not
467+ # called the get email verification API yet.
468+ await session.fetch_and_set_claim(EmailVerificationClaim, user_context)
469+
457470 email_verify_link = (
458471 api_options.app_info.website_domain.get_as_string_dangerous()
459472 + api_options.app_info.website_base_path.get_as_string_dangerous()
@@ -626,12 +639,25 @@ <h2 class="section-title" id="header-classes">Classes</h2>
626639 if isinstance(
627640 response, CreateEmailVerificationTokenEmailAlreadyVerifiedError
628641 ):
642+ if await session.get_claim_value(EmailVerificationClaim) is not True:
643+ # this can happen if the email was "verified" in another browser
644+ # and this session is still outdated - and the user has not
645+ # called the get email verification API yet.
646+ await session.fetch_and_set_claim(
647+ EmailVerificationClaim, user_context
648+ )
629649 log_debug_message(
630650 "Email verification email not sent to %s because it is already verified.",
631651 email_info.email,
632652 )
633653 return GenerateEmailVerifyTokenPostEmailAlreadyVerifiedError()
634654
655+ if await session.get_claim_value(EmailVerificationClaim) is not False:
656+ # this can happen if the email was "unverified" in another browser
657+ # and this session is still outdated - and the user has not
658+ # called the get email verification API yet.
659+ await session.fetch_and_set_claim(EmailVerificationClaim, user_context)
660+
635661 email_verify_link = (
636662 api_options.app_info.website_domain.get_as_string_dangerous()
637663 + api_options.app_info.website_base_path.get_as_string_dangerous()
@@ -740,12 +766,25 @@ <h3>Methods</h3>
740766 if isinstance(
741767 response, CreateEmailVerificationTokenEmailAlreadyVerifiedError
742768 ):
769+ if await session.get_claim_value(EmailVerificationClaim) is not True:
770+ # this can happen if the email was "verified" in another browser
771+ # and this session is still outdated - and the user has not
772+ # called the get email verification API yet.
773+ await session.fetch_and_set_claim(
774+ EmailVerificationClaim, user_context
775+ )
743776 log_debug_message(
744777 "Email verification email not sent to %s because it is already verified.",
745778 email_info.email,
746779 )
747780 return GenerateEmailVerifyTokenPostEmailAlreadyVerifiedError()
748781
782+ if await session.get_claim_value(EmailVerificationClaim) is not False:
783+ # this can happen if the email was "unverified" in another browser
784+ # and this session is still outdated - and the user has not
785+ # called the get email verification API yet.
786+ await session.fetch_and_set_claim(EmailVerificationClaim, user_context)
787+
749788 email_verify_link = (
750789 api_options.app_info.website_domain.get_as_string_dangerous()
751790 + api_options.app_info.website_base_path.get_as_string_dangerous()
0 commit comments