Initial mfa support (for internal users) #93591
@ -284,13 +284,13 @@ def construct_password_changed(user):
|
||||
return email_body_txt, subject
|
||||
|
||||
|
||||
def construct_new_mfa_device(user, device_type):
|
||||
def construct_mfa_new_device(user, device_type):
|
||||
context = {
|
||||
"device_type": device_type,
|
||||
"user": user,
|
||||
}
|
||||
email_body_txt = loader.render_to_string(
|
||||
"bid_main/emails/new_mfa_device.txt", context
|
||||
"bid_main/emails/mfa_new_device.txt", context
|
||||
)
|
||||
subject = "Security alert: a new multi-factor authentication device added"
|
||||
|
||||
|
@ -46,12 +46,12 @@ def send_password_changed_email(user_pk):
|
||||
|
||||
|
||||
@background(schedule={'action': TaskSchedule.RESCHEDULE_EXISTING})
|
||||
def send_new_mfa_device_email(user_pk, device_type):
|
||||
def send_mfa_new_device_email(user_pk, device_type):
|
||||
user = User.objects.get(pk=user_pk)
|
||||
log.info("sending a new mfa device email for account %s", user.pk)
|
||||
|
||||
# sending only a text/plain email to reduce the room for look-alike phishing emails
|
||||
email_body_txt, subject = bid_main.email.construct_new_mfa_device(user, device_type)
|
||||
email_body_txt, subject = bid_main.email.construct_mfa_new_device(user, device_type)
|
||||
|
||||
email = user.email
|
||||
send_mail(
|
||||
|
@ -132,7 +132,7 @@ class TotpRegisterView(mixins.MfaRequiredIfConfiguredMixin, FormView):
|
||||
def form_valid(self, form):
|
||||
form.save()
|
||||
if self.request.user.confirmed_email_at:
|
||||
bid_main.tasks.send_new_mfa_device_email(self.request.user.pk, 'totp')
|
||||
bid_main.tasks.send_mfa_new_device_email(self.request.user.pk, 'totp')
|
||||
return super().form_valid(form)
|
||||
|
||||
|
||||
@ -161,7 +161,7 @@ class U2fRegisterView(mixins.MfaRequiredIfConfiguredMixin, FormView):
|
||||
def form_valid(self, form):
|
||||
form.save()
|
||||
if self.request.user.confirmed_email_at:
|
||||
bid_main.tasks.send_new_mfa_device_email(self.request.user.pk, 'u2f')
|
||||
bid_main.tasks.send_mfa_new_device_email(self.request.user.pk, 'u2f')
|
||||
return super().form_valid(form)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user