예제 #1
0
    def send_verification_email(self, request, *args, **kwargs):
        verified_key_text = getattr(settings, "VERIFIED_KEY_TEXT", None)
        if not verified_key_text:
            return Response(status=status.HTTP_204_NO_CONTENT)

        username = request.data.get('username')
        redirect_url = request.data.get('redirect_url')
        response_message = _("Verification email has NOT been sent")

        if username:
            try:
                rp = RegistrationProfile.objects.get(user__username=username)
            except RegistrationProfile.DoesNotExist:
                pass
            else:
                set_is_email_verified(rp.user.profile, False)

                verification_key = rp.activation_key
                if verification_key == verified_key_text:
                    verification_key = (rp.user.registrationprofile.
                                        create_new_activation_key())

                verification_url = get_verification_url(
                    redirect_url, request, verification_key)

                email_data = get_verification_email_data(
                    rp.user.email, rp.user.username, verification_url, request)

                send_verification_email.delay(**email_data)
                response_message = _("Verification email has been sent")

                return Response(response_message)

        return HttpResponseBadRequest(response_message)
예제 #2
0
    def send_verification_email(self, request, *args, **kwargs):
        verified_key_text = getattr(settings, "VERIFIED_KEY_TEXT", None)
        if not verified_key_text:
            return Response(status=status.HTTP_204_NO_CONTENT)

        username = request.data.get('username')
        redirect_url = request.data.get('redirect_url')
        response_message = _("Verification email has NOT been sent")

        if username:
            try:
                rp = RegistrationProfile.objects.get(user__username=username)
            except RegistrationProfile.DoesNotExist:
                pass
            else:
                set_is_email_verified(rp.user.profile, False)

                verification_key = rp.activation_key
                if verification_key == verified_key_text:
                    verification_key = (rp.user.registrationprofile.
                                        create_new_activation_key())

                verification_url = get_verification_url(
                    redirect_url, request, verification_key)

                email_data = get_verification_email_data(
                    rp.user.email, rp.user.username, verification_url, request)

                send_verification_email.delay(**email_data)
                response_message = _("Verification email has been sent")

                return Response(response_message)

        return HttpResponseBadRequest(response_message)
예제 #3
0
def _send_verification_email(redirect_url, user, request):
    verification_key = (user.registrationprofile.create_new_activation_key())
    verification_url = get_verification_url(redirect_url, request,
                                            verification_key)

    email_data = get_verification_email_data(user.email, user.username,
                                             verification_url, request)

    send_verification_email.delay(**email_data)
예제 #4
0
def _send_verification_email(redirect_url, user, request):
    verification_key = (user.registrationprofile
                            .create_new_activation_key())
    verification_url = get_verification_url(
        redirect_url, request, verification_key
    )

    email_data = get_verification_email_data(
        user.email, user.username, verification_url, request
    )

    send_verification_email.delay(**email_data)
예제 #5
0
파일: test_email.py 프로젝트: onaio/onadata
    def _get_email_data(self, include_redirect_url=False):
        verification_url = get_verification_url(**{
            "redirect_url": include_redirect_url and self.redirect_url,
            "request": self.custom_request,
            "verification_key": self.verification_key
        })

        email_data = get_verification_email_data(**{
            "email": self.email,
            "username": self.username,
            "verification_url": verification_url,
            "request": self.custom_request
        })

        self.assertIn('email', email_data)
        self.assertIn(self.email, email_data.get('email'))
        self.assertIn('subject', email_data)
        self.assertIn('message_txt', email_data)

        return email_data
예제 #6
0
    def _get_email_data(self, include_redirect_url=False):
        verification_url = get_verification_url(
            **{
                "redirect_url": include_redirect_url and self.redirect_url,
                "request": self.custom_request,
                "verification_key": self.verification_key
            })

        email_data = get_verification_email_data(
            **{
                "email": self.email,
                "username": self.username,
                "verification_url": verification_url,
                "request": self.custom_request
            })

        self.assertIn('email', email_data)
        self.assertIn(self.email, email_data.get('email'))
        self.assertIn('subject', email_data)
        self.assertIn('message_txt', email_data)

        return email_data