|
| 1 | +# |
| 2 | +# Copyright (C) 2019 Open Source Geospatial Foundation - all rights reserved |
| 3 | +# |
| 4 | +# This program is free software: you can redistribute it and/or modify |
| 5 | +# it under the terms of the GNU General Public License as published by |
| 6 | +# the Free Software Foundation, either version 3 of the License, or |
| 7 | +# (at your option) any later version. |
| 8 | +# |
| 9 | +# This program is distributed in the hope that it will be useful, |
| 10 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | +# GNU General Public License for more details. |
| 13 | +# |
| 14 | +# You should have received a copy of the GNU General Public License |
| 15 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 | +# |
| 17 | +######################################################################### |
| 18 | +from django import forms |
| 19 | +from allauth.account.forms import LoginForm |
| 20 | + |
| 21 | +try: |
| 22 | + from captcha.fields import ReCaptchaField |
| 23 | +except ImportError: |
| 24 | + from django_recaptcha.fields import ReCaptchaField |
| 25 | + |
| 26 | + |
| 27 | +class AllauthReCaptchaSignupForm(forms.Form): |
| 28 | + captcha = ReCaptchaField(label=False) |
| 29 | + |
| 30 | + def signup(self, request, user): |
| 31 | + """Required, or else it thorws deprecation warnings""" |
| 32 | + pass |
| 33 | + |
| 34 | + |
| 35 | +class AllauthRecaptchaLoginForm(LoginForm): |
| 36 | + captcha = ReCaptchaField(label=False) |
| 37 | + |
| 38 | + def login(self, *args, **kwargs): |
| 39 | + return super(AllauthRecaptchaLoginForm, self).login(*args, **kwargs) |
0 commit comments