コード例 #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
ファイル: user_profile_viewset.py プロジェクト: onaio/onadata
    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)