Esempio n. 1
0
 def get(self, request):
     org = Organization(id=1, slug="organization", name="sentry corp")
     member = OrganizationMember(id=1,
                                 organization=org,
                                 email="*****@*****.**")
     context = {"url": member.get_invite_link(), "organization": org}
     return MailPreview(
         html_template="sentry/emails/setup_2fa.html",
         text_template="sentry/emails/setup_2fa.txt",
         context=context,
     ).render(request)
Esempio n. 2
0
 def call_to_action(self, org: Organization, user: User,
                    member: OrganizationMember):
     # send invite to setup 2fa
     email_context = {"url": member.get_invite_link(), "organization": org}
     subject = "{} {} Mandatory: Enable Two-Factor Authentication".format(
         options.get("mail.subject-prefix"), org.name.capitalize())
     message = MessageBuilder(
         subject=subject,
         template="sentry/emails/setup_2fa.txt",
         html_template="sentry/emails/setup_2fa.html",
         type="user.setup_2fa",
         context=email_context,
     )
     message.send_async([member.email])
Esempio n. 3
0
 def get(self, request):
     org = Organization(
         id=1,
         slug='organization',
         name='sentry corp',
     )
     member = OrganizationMember(
         id=1,
         organization=org,
         email='*****@*****.**')
     context = {
         'url': member.get_invite_link(),
         'organization': org
     }
     return MailPreview(
         html_template='sentry/emails/setup_2fa.html',
         text_template='sentry/emails/setup_2fa.txt',
         context=context,
     ).render(request)
Esempio n. 4
0
    def call_to_action(self, org: Organization, user: User,
                       member: OrganizationMember):
        import django.contrib.auth.models

        if isinstance(user, django.contrib.auth.models.User):
            # TODO(RyanSkonnord): Add test to repro this case (or delete check if unable)
            logger.warning(
                "Could not send verified email compliance notification (non-Sentry User model)"
            )
            return
        elif not isinstance(user, User):
            raise TypeError(user)

        email = UserEmail.objects.get_primary_email(user)
        email_context = {
            "confirm_url":
            absolute_uri(
                reverse("sentry-account-confirm-email",
                        args=[user.id, email.validation_hash])),
            "invite_url":
            member.get_invite_link(),
            "email":
            email.email,
            "organization":
            org,
        }
        subject = "{} {} Mandatory: Verify Email Address".format(
            options.get("mail.subject-prefix"), org.name.capitalize())
        message = MessageBuilder(
            subject=subject,
            template="sentry/emails/setup_email.txt",
            html_template="sentry/emails/setup_email.html",
            type="user.setup_email",
            context=email_context,
        )
        message.send_async([email])