Skip to content

Commit 79a7e3b

Browse files
authored
Replace All Otp Emails with Null (#5209)
Replace all otp emails with NULL so that they use the current email (rather than a potentially stale one) instead
1 parent d309e8e commit 79a7e3b

4 files changed

Lines changed: 20 additions & 3 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from django.db import migrations
2+
3+
4+
def null_otp_email(apps, schema_editor):
5+
EmailDevice = apps.get_model("otp_email", "EmailDevice")
6+
EmailDevice.objects.exclude(email__isnull=True).update(email=None)
7+
8+
9+
class Migration(migrations.Migration):
10+
dependencies = [
11+
("otp_email", "0006_add_timestamps"),
12+
("seed", "0250_remove_goal_current_cycle_goal_partner_note_and_more"),
13+
]
14+
15+
operations = [
16+
migrations.RunPython(null_otp_email, migrations.RunPython.noop),
17+
]

seed/utils/organizations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,4 +196,4 @@ def set_default_2fa_method(org):
196196
for user in org.users.iterator():
197197
devices = list(devices_for_user(user))
198198
if not devices:
199-
EmailDevice.objects.create(user=user, name="default", email=user.username)
199+
EmailDevice.objects.create(user=user, name="default")

seed/views/v3/two_factor_views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def set_method(self, request):
7676

7777
# token_active = type(devices[0]) == Token?
7878
if methods.get("email") is True and not email_active:
79-
email_device = EmailDevice.objects.create(user=user, name="default", email=user.username)
79+
email_device = EmailDevice.objects.create(user=user, name="default")
8080
if email_device:
8181
[device.delete() for device in devices]
8282
# just for user confirmation

seed/views/v3/users.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ def create(self, request):
210210
user.first_name = first_name
211211
user.last_name = last_name
212212
if org.require_2fa:
213-
EmailDevice.objects.create(user=user, name="default", email=user.email)
213+
EmailDevice.objects.create(user=user, name="default")
214214
user.save()
215215

216216
try:

0 commit comments

Comments
 (0)