Example #1
0
    def get(self, request):
        link = request.GET.get('link', None)
        AES = AESCipher(settings.SECRET_KEY)
        userinfo = JSONDeserializer().deserialize(AES.decrypt(link))
        form = ArchesUserCreationForm(userinfo)
        if datetime.fromtimestamp(userinfo['ts']) + timedelta(
                days=1) >= datetime.fromtimestamp(int(time.time())):
            if form.is_valid():
                user = form.save()
                crowdsource_editor_group = Group.objects.get(
                    name=settings.USER_SIGNUP_GROUP)
                user.groups.add(crowdsource_editor_group)
                return redirect('auth')
            else:
                try:
                    for error in form.errors.as_data()['username']:
                        if error.code == 'unique':
                            return redirect('auth')
                except:
                    pass
        else:
            form.errors['ts'] = [
                _('The signup link has expired, please try signing up again.  Thanks!'
                  )
            ]

        return render(
            request, 'signup.htm', {
                'form': form,
                'showform': True,
                'postdata': userinfo,
                'validation_help': validation.password_validators_help_texts()
            })
Example #2
0
    def get(self, request):
        link = request.GET.get("link", None)
        AES = AESCipher(settings.SECRET_KEY)
        userinfo = JSONDeserializer().deserialize(AES.decrypt(link))
        form = ArchesUserCreationForm(userinfo)
        if datetime.fromtimestamp(userinfo["ts"]) + timedelta(days=1) >= datetime.fromtimestamp(int(time.time())):
            if form.is_valid():
                user = form.save()
                crowdsource_editor_group = Group.objects.get(name=settings.USER_SIGNUP_GROUP)
                user.groups.add(crowdsource_editor_group)
                return redirect("auth")
            else:
                try:
                    for error in form.errors.as_data()["username"]:
                        if error.code == "unique":
                            return redirect("auth")
                except:
                    pass
        else:
            form.errors["ts"] = [_("The signup link has expired, please try signing up again.  Thanks!")]

        return render(
            request,
            "signup.htm",
            {"form": form, "showform": True, "postdata": userinfo, "validation_help": validation.password_validators_help_texts()},
        )
Example #3
0
    def get(self, request):
        link = request.GET.get('link', None)
        AES = AESCipher(settings.SECRET_KEY)
        userinfo = JSONDeserializer().deserialize(AES.decrypt(link))
        form = ArchesUserCreationForm(userinfo)
        if datetime.fromtimestamp(userinfo['ts']) + timedelta(days=1) >= datetime.fromtimestamp(int(time.time())):
            if form.is_valid():
                user = form.save()
                crowdsource_editor_group = Group.objects.get(name=settings.USER_SIGNUP_GROUP)
                user.groups.add(crowdsource_editor_group)
                return redirect('auth')
            else:
                try:
                    for error in form.errors.as_data()['username']:
                        if error.code == 'unique':
                            return redirect('auth')
                except:
                    pass
        else:
            form.errors['ts'] = [_('The signup link has expired, please try signing up again.  Thanks!')]

        return render(request, 'signup.htm', {
            'form': form,
            'showform': True,
            'postdata': userinfo,
            'validation_help': validation.password_validators_help_texts()
        })