Skip to content

Commit a960b57

Browse files
author
Nick Koutroumpinis
authored
add case with no form and only User object.
added this case because some django backends are not supporting native forms and could be used only as REST API's. My change does not change anything in the current functionality of the project, just extends it.
1 parent e9a8056 commit a960b57

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

verify_email/email_handler.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,17 @@ def __send_email(self, msg, useremail):
2828
)
2929

3030
# Public :
31-
def send_verification_link(self, request, form):
32-
inactive_user = form.save(commit=False)
31+
def send_verification_link(self, request, inactive_user=None, form=None):
32+
33+
if form:
34+
inactive_user = form.save(commit=False)
35+
3336
inactive_user.is_active = False
3437
inactive_user.save()
3538

3639
try:
37-
useremail = form.cleaned_data.get(self.settings.get('email_field_name'))
40+
41+
useremail = form.cleaned_data.get(self.settings.get('email_field_name')) if form else user.email
3842
if not useremail:
3943
raise KeyError(
4044
'No key named "email" in your form. Your field should be named as email in form OR set a variable'

0 commit comments

Comments
 (0)