prevent account spam
This commit is contained in:
@ -1,6 +1,11 @@
|
||||
import datetime
|
||||
|
||||
from django.conf import settings
|
||||
|
||||
from allauth.account.adapter import DefaultAccountAdapter
|
||||
from django.contrib import messages
|
||||
from django.core.cache import caches
|
||||
from gettext import gettext as _
|
||||
|
||||
|
||||
class AllAuthCustomAdapter(DefaultAccountAdapter):
|
||||
@ -17,6 +22,11 @@ class AllAuthCustomAdapter(DefaultAccountAdapter):
|
||||
# disable password reset for now
|
||||
def send_mail(self, template_prefix, email, context):
|
||||
if settings.EMAIL_HOST != '':
|
||||
super(AllAuthCustomAdapter, self).send_mail(template_prefix, email, context)
|
||||
default = datetime.datetime.now()
|
||||
c = caches['default'].get_or_set(email, default, timeout=360)
|
||||
if c == default:
|
||||
super(AllAuthCustomAdapter, self).send_mail(template_prefix, email, context)
|
||||
else:
|
||||
messages.add_message(self.request, messages.ERROR, _('In order to prevent spam, the requested email was not send. Please wait a few minutes and try again.'))
|
||||
else:
|
||||
pass
|
||||
|
Reference in New Issue
Block a user