-
Notifications
You must be signed in to change notification settings - Fork 42
feat: Add and use email verification claim #215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…word recipe in favour of EV claims
…ess recipe in favour of EV claims
…avour of ev claims
…nd fix tests failures
…ecipeEmailVerificationConfig
# | ||
# class InputEmailVerificationConfig: | ||
# def __init__( | ||
# self, | ||
# get_email_verification_url: Union[ | ||
# Callable[[User, Dict[str, Any]], Awaitable[str]], None | ||
# ] = None, | ||
# create_and_send_custom_email: Union[ | ||
# Callable[[User, str, Dict[str, Any]], Awaitable[None]], None | ||
# ] = None, | ||
# ): | ||
# self.get_email_verification_url = get_email_verification_url | ||
# self.create_and_send_custom_email = create_and_send_custom_email | ||
# | ||
# if create_and_send_custom_email: | ||
# deprecated_warn( | ||
# "create_and_send_custom_email is deprecated. Please use email delivery config instead" | ||
# ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this. Why commented?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
@@ -371,7 +313,7 @@ def __init__( | |||
sign_up_feature: SignUpFeature, | |||
sign_in_feature: SignInFeature, | |||
reset_password_using_token_feature: ResetPasswordUsingTokenFeature, | |||
email_verification_feature: ParentRecipeEmailVerificationConfig, | |||
# email_verification_feature: ParentRecipeEmailVerificationConfig, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this - why commented?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
@@ -380,19 +322,18 @@ def __init__( | |||
self.sign_up_feature = sign_up_feature | |||
self.sign_in_feature = sign_in_feature | |||
self.reset_password_using_token_feature = reset_password_using_token_feature | |||
self.email_verification_feature = email_verification_feature | |||
# self.email_verification_feature = email_verification_feature |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this - why commented?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
# if email_verification_feature is not None and not isinstance(email_verification_feature, InputEmailVerificationConfig): # type: ignore | ||
# raise ValueError( | ||
# "email_verification_feature must be of type InputEmailVerificationConfig or None" | ||
# ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove all things that are commented like this.. not sure why you did this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed this. Looked for more using Ctrl+F. Didn't find any others.
user, user_context | ||
) | ||
api_options.app_info.website_domain.get_as_string_dangerous() | ||
+ api_options.app_info.website_base_path.get_as_string_dangerous() | ||
+ "?token=" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+ "?token=" | |
+ "/reset-password?token=" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
EmailVerificationClaim = EmailVerificationClaimClass() | ||
|
||
|
||
class APIImplementation(APIInterface): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this moved into this file and not kept in the other file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a cyclic import error that kept me stuck for hours. I still don't know how to fix it. Generally, this happens because of types so we just use from _future__ import annotations
and from typing import TYPE_CHECKING
.
But here we are using using the class (not just its type) so the error is really hard to get rid of. I have already struggled with it for hours. The only feasible solution for now was to move the conflicting classes in the same file.
Need some help to fix it.
self.get_email_for_user_id_funcs_from_other_recipes.append(f) | ||
|
||
|
||
class EmailVerificationClaimClass(BooleanClaim): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this class in this file and not in the ev_claim.py file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to move the content to avoid cyclic import errors. It's really troublesome this time. Have already wasted hours. Need help to fix it.
|
||
return UnknownUserIdError() | ||
|
||
def add_get_email_for_user_id_func(self, f: Callable[[str, Dict[str, Any]], Any]): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is the f
argument so badly typed? Why is the return of it Any
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
self.validators = EmailVerificationClaimValidators(claim=self) | ||
|
||
|
||
EmailVerificationClaim = EmailVerificationClaimClass() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how will the end user import this in their code (if they want to)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from supertokens_python.recipe.emailverification import EmailVerificationClaim
I know EmailVerificationClaim
and EmailVerificationClaimClass()
shouldn't be in recipe.py
. But a nasty cyclic import error comes up if I seperate them. Need help in fixing it.
is_verified = await session.get_claim_value( | ||
EmailVerificationClaim, user_context | ||
) | ||
# TODO: Type of is_verified should be bool. It's any for now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO
Summary of change
Add and use email verification claim
Test Plan
(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work. Bonus points for screenshots and videos!)
Documentation changes
(If relevant, please create a PR in our docs repo, or create a checklist here highlighting the necessary changes)
Checklist for important updates
coreDriverInterfaceSupported.json
file has been updated (if needed)supertokens_python/constants.py
frontendDriverInterfaceSupported.json
file has been updated (if needed)setup.py
supertokens_python/constants.py
git tag
) in the formatvX.Y.Z
, and then find the latest branch (git branch --all
) whoseX.Y
is greater than the latest released tag.supertokens_python/utils.py
file to include that in theFRAMEWORKS
variable