Skip to content

Commit

Permalink
Allow if device_id is none
Browse files Browse the repository at this point in the history
Admins can trigger restores from HQ without a device_id
  • Loading branch information
gherceg committed Dec 12, 2024
1 parent 2c30397 commit 2af1f45
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions corehq/apps/ota/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,12 @@ def test_allowed_for_different_user(self):
with patch('corehq.apps.ota.utils.DEVICES_PER_USER', 1):
self.assertTrue(can_login_on_device('def456', 'device-id'))

def test_device_id_is_none_is_allowed(self):
self._create_synclog(self.domain, 'abc123', 'device-id', date=self.within_past_day)

with patch('corehq.apps.ota.utils.DEVICES_PER_USER', 1):
self.assertTrue(can_login_on_device('abc123', 'device-id'))

def _create_synclog(self, domain, user_id, device_id, **kwargs):
SyncLogSQL.objects.create(
domain=domain,
Expand Down
2 changes: 1 addition & 1 deletion corehq/apps/ota/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def _inner(request, domain, *args, **kwargs):


def can_login_on_device(user_id, device_id):
if device_id.startswith("WebAppsLogin"):
if not device_id or device_id.startswith("WebAppsLogin"):
return True

end_time = datetime.now()
Expand Down

0 comments on commit 2af1f45

Please sign in to comment.