fix(accounts): create user if email doesn't exist
Updated the login email view to use get_or_create for retrieving user by email, ensuring a user is created if the email doesn't exist. This prevents errors when attempting to login with an unregistered email, enhancing the user experience and robustness of the login process
This commit is contained in:
parent
e2fddf8052
commit
f291deece2
1 changed files with 1 additions and 1 deletions
|
@ -19,7 +19,7 @@ class SendLoginEmailView(FormView):
|
|||
|
||||
def form_valid(self, form):
|
||||
email = form.cleaned_data["email"]
|
||||
user = User.objects.get(email=email)
|
||||
user, _ = User.objects.get_or_create(email=email)
|
||||
token = default_token_generator.make_token(user)
|
||||
uid = urlsafe_base64_encode(force_bytes(user.pk))
|
||||
login_url = self.request.build_absolute_uri(f"/accounts/login/{uid}/{token}/")
|
||||
|
|
Loading…
Reference in a new issue