Skip to content

Commit 888578d

Browse files
committed
make email confirmation fully optional #38
1 parent e6c103c commit 888578d

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

Diff for: rest_auth_toolkit/views.py

+12-5
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,23 @@ def post(self, request):
4343
email confirmation instance using the ID and call the confirm
4444
method. To use a field that's not named 'id', define the setting
4545
email_confirmation_lookup_param (this will change the URL pattern).
46+
47+
If the setting is false, the user will be active immediately.
4648
"""
4749
deserializer = self.get_serializer(data=request.data)
4850
deserializer.is_valid(raise_exception=True)
49-
user = deserializer.save()
5051

51-
if self.email_confirmation_class is None:
52-
raise MissingSetting('email_confirmation_string')
52+
confirm_email = get_setting('email_confirmation_send_email', True)
53+
54+
if not confirm_email:
55+
deserializer.save(is_active=True)
56+
else:
57+
user = deserializer.save()
58+
59+
if self.email_confirmation_class is None:
60+
raise MissingSetting('email_confirmation_class')
5361

54-
confirmation = self.email_confirmation_class.objects.create(user=user)
55-
if get_setting('email_confirmation_send_email', True):
62+
confirmation = self.email_confirmation_class.objects.create(user=user)
5663
email_field = user.get_email_field_name()
5764
send_email(request, user, getattr(user, email_field), confirmation)
5865

0 commit comments

Comments
 (0)