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()
        })
Example #4
0
    def post(self, request):
        showform = True
        confirmation_message = ''
        postdata = request.POST.copy()
        postdata['ts'] = int(time.time())
        form = ArchesUserCreationForm(postdata,
                                      enable_captcha=settings.ENABLE_CAPTCHA)

        if form.is_valid():
            AES = AESCipher(settings.SECRET_KEY)
            userinfo = JSONSerializer().serialize(form.cleaned_data)
            encrypted_userinfo = AES.encrypt(userinfo)
            url_encrypted_userinfo = urlencode({'link': encrypted_userinfo})

            admin_email = settings.ADMINS[0][1] if settings.ADMINS else ''
            email_context = {
                'button_text':
                _('Signup for Arches'),
                'link':
                request.build_absolute_uri(
                    reverse('confirm_signup') + '?' +
                    url_encrypted_userinfo, ),
                'greeting':
                _('Thanks for your interest in Arches. Click on link below to confirm your email address! Use your email address to login.'
                  ),
                'closing':
                _('This link expires in 24 hours.  If you can\'t get to it before then, don\'t worry, you can always try again with the same email address.'
                  ),
            }

            html_content = render_to_string('email/general_notification.htm',
                                            email_context)  # ...
            text_content = strip_tags(
                html_content
            )  # this strips the html, so people will have the text as well.

            # create the email, and attach the HTML version as well.
            msg = EmailMultiAlternatives(_('Welcome to Arches!'), text_content,
                                         admin_email,
                                         [form.cleaned_data['email']])
            msg.attach_alternative(html_content, "text/html")
            msg.send()

            confirmation_message = _(
                'An email has been sent to <br><strong>%s</strong><br> with a link to activate your account'
                % form.cleaned_data['email'])
            showform = False

        return render(
            request, 'signup.htm', {
                'enable_captcha': settings.ENABLE_CAPTCHA,
                'form': form,
                'postdata': postdata,
                'showform': showform,
                'confirmation_message': confirmation_message,
                'validation_help': validation.password_validators_help_texts()
            })
Example #5
0
    def post(self, request):
        showform = True
        confirmation_message = ""
        postdata = request.POST.copy()
        postdata["ts"] = int(time.time())
        form = ArchesUserCreationForm(postdata, enable_captcha=settings.ENABLE_CAPTCHA)

        if form.is_valid():
            AES = AESCipher(settings.SECRET_KEY)
            userinfo = JSONSerializer().serialize(form.cleaned_data)
            encrypted_userinfo = AES.encrypt(userinfo)
            url_encrypted_userinfo = urlencode({"link": encrypted_userinfo})

            admin_email = settings.ADMINS[0][1] if settings.ADMINS else ""
            email_context = {
                "button_text": _("Signup for Arches"),
                "link": request.build_absolute_uri(reverse("confirm_signup") + "?" + url_encrypted_userinfo),
                "greeting": _(
                    "Thanks for your interest in Arches. Click on link below \
                    to confirm your email address! Use your email address to login."
                ),
                "closing": _(
                    "This link expires in 24 hours.  If you can't get to it before then, \
                    don't worry, you can always try again with the same email address."
                ),
            }

            html_content = render_to_string("email/general_notification.htm", email_context)  # ...
            text_content = strip_tags(html_content)  # this strips the html, so people will have the text as well.

            # create the email, and attach the HTML version as well.
            msg = EmailMultiAlternatives(_("Welcome to Arches!"), text_content, admin_email, [form.cleaned_data["email"]])
            msg.attach_alternative(html_content, "text/html")
            msg.send()

            confirmation_message = _(
                "An email has been sent to <br><strong>%s</strong><br> with a link to activate your account" % form.cleaned_data["email"]
            )
            showform = False

        return render(
            request,
            "signup.htm",
            {
                "enable_captcha": settings.ENABLE_CAPTCHA,
                "form": form,
                "postdata": postdata,
                "showform": showform,
                "confirmation_message": confirmation_message,
                "validation_help": validation.password_validators_help_texts(),
            },
        )
Example #6
0
    def post(self, request):
        showform = True
        confirmation_message = ''
        postdata = request.POST.copy()
        postdata['ts'] = int(time.time())
        form = ArchesUserCreationForm(postdata, enable_captcha=settings.ENABLE_CAPTCHA)
        
        if form.is_valid():
            AES = AESCipher(settings.SECRET_KEY)
            userinfo = JSONSerializer().serialize(form.cleaned_data)
            encrypted_userinfo = AES.encrypt(userinfo)
            url_encrypted_userinfo = urlencode({'link':encrypted_userinfo})

            admin_email = settings.ADMINS[0][1] if settings.ADMINS else ''
            email_context = {
                'button_text': _('Signup for Arches'),
                'link':request.build_absolute_uri(reverse('confirm_signup') + '?' + url_encrypted_userinfo,),
                'greeting': _('Thanks for your interest in Arches. Click on link below to confirm your email address! Use your email address to login.'),
                'closing': _('This link expires in 24 hours.  If you can\'t get to it before then, don\'t worry, you can always try again with the same email address.'),
            }

            html_content = render_to_string('email/general_notification.htm', email_context) # ...
            text_content = strip_tags(html_content) # this strips the html, so people will have the text as well.

            # create the email, and attach the HTML version as well.
            msg = EmailMultiAlternatives(_('Welcome to Arches!'), text_content, admin_email, [form.cleaned_data['email']])
            msg.attach_alternative(html_content, "text/html")
            msg.send()

            confirmation_message = _('An email has been sent to <br><strong>%s</strong><br> with a link to activate your account' % form.cleaned_data['email'])
            showform = False

        return render(request, 'signup.htm', {
            'enable_captcha': settings.ENABLE_CAPTCHA,
            'form': form,
            'postdata': postdata,
            'showform': showform,
            'confirmation_message': confirmation_message,
            'validation_help': validation.password_validators_help_texts()
        })
Example #7
0
    def get(self, request):
        form = ArchesUserCreationForm(enable_captcha=settings.ENABLE_CAPTCHA)
        postdata = {'first_name': '', 'last_name': '', 'email': ''}
        showform = True
        confirmation_message = ''

        return render(
            request, 'signup.htm', {
                'enable_captcha': settings.ENABLE_CAPTCHA,
                'form': form,
                'postdata': postdata,
                'showform': showform,
                'confirmation_message': confirmation_message,
                'validation_help': validation.password_validators_help_texts()
            })
Example #8
0
    def get(self, request):
        form = ArchesUserCreationForm(enable_captcha=settings.ENABLE_CAPTCHA)
        postdata = {"first_name": "", "last_name": "", "email": ""}
        showform = True
        confirmation_message = ""

        return render(
            request,
            "signup.htm",
            {
                "enable_captcha": settings.ENABLE_CAPTCHA,
                "form": form,
                "postdata": postdata,
                "showform": showform,
                "confirmation_message": confirmation_message,
                "validation_help": validation.password_validators_help_texts(),
            },
        )