accepted_terms field required in register

remotes/origin/3.4.0rc
Daniel García 2018-05-18 14:57:52 +02:00 committed by Alex Hermida
parent ebb6dfc3c3
commit 648a1f1dbb
2 changed files with 6 additions and 4 deletions

View File

@ -17,13 +17,10 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
from functools import partial from functools import partial
from enum import Enum
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from django.conf import settings from django.conf import settings
from taiga.base.api import validators
from taiga.base.api import serializers
from taiga.base.api import viewsets from taiga.base.api import viewsets
from taiga.base.decorators import list_route from taiga.base.decorators import list_route
from taiga.base import exceptions as exc from taiga.base import exceptions as exc
@ -91,6 +88,10 @@ class AuthViewSet(viewsets.ViewSet):
@list_route(methods=["POST"]) @list_route(methods=["POST"])
def register(self, request, **kwargs): def register(self, request, **kwargs):
accepted_terms = request.DATA.get("accepted_terms", None)
if accepted_terms in (None, False):
raise exc.BadRequest(_("You must accept our terms of service and privacy policy"))
self.check_permissions(request, 'register', None) self.check_permissions(request, 'register', None)
type = request.DATA.get("type", None) type = request.DATA.get("type", None)

View File

@ -115,7 +115,8 @@ def public_register(username:str, password:str, email:str, full_name:str):
user_model = get_user_model() user_model = get_user_model()
user = user_model(username=username, user = user_model(username=username,
email=email, email=email,
full_name=full_name) full_name=full_name,
read_new_terms=True)
user.set_password(password) user.set_password(password)
try: try:
user.save() user.save()