Repository: goauthentik/authentik

Issue:
UI Elements Overlap (Directory > Users)
**Describe the bug**
UI Elements Overlap Under the Directory > Users Menu when you interact with the "Hide deactivated user toggle switch"

**To Reproduce**
Steps to reproduce the behavior:

1. Log into authentik
2. Click on 'Admin interface'
3. Click on 'Directory' to expand
4. Click on 'Users'
5. Click on 'Hide deactivated user' (in either windowed browser or full screen)
6. See blue ring around 'Hide deactivated user' toggle switch overlap with other UI elements

**Expected behavior**
no UI overlap

**Screenshots**
When browser (Chrome) is fullscreen:
![image](https://github.com/goauthentik/authentik/assets/31871143/a59d7786-ebe9-4e87-97df-328973de21fb)

When browser (Chrome) is windowed:
![image](https://github.com/goauthentik/authentik/assets/31871143/65e9478a-60f7-41f5-95a8-a7a2343a538a)


**Logs**
N/A

**Version and Deployment (please complete the following information):**

-   authentik version: 2023.8.2
-   Deployment: docker-compose

**Additional context**
N/A



Discussion:
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
It's not super important, but the UI glitch is still there with version 2023.10.2

Resolving patch:
diff --git a/authentik/events/api/notification_transports.py b/authentik/events/api/notification_transports.py
--- a/authentik/events/api/notification_transports.py
+++ b/authentik/events/api/notification_transports.py
@@ -86,7 +86,6 @@ def test(self, request: Request, pk=None) -> Response:
         event = Event.new(
             action="notification_test",
             user=get_user(request.user),
-            app=self.__class__.__module__,
             context={"foo": "bar"},
         )
         event.save()
diff --git a/authentik/events/models.py b/authentik/events/models.py
--- a/authentik/events/models.py
+++ b/authentik/events/models.py
@@ -209,8 +209,9 @@ def new(
             app = parent.f_globals["__name__"]
             # Attempt to match the calling module to the django app it belongs to
             # if we can't find a match, keep the module name
-            django_apps = get_close_matches(app, django_app_names(), n=1)
-            if len(django_apps) > 0:
+            django_apps: list[str] = get_close_matches(app, django_app_names(), n=1)
+            # Also ensure that closest django app has the correct prefix
+            if len(django_apps) > 0 and django_apps[0].startswith(app):
                 app = django_apps[0]
         cleaned_kwargs = cleanse_dict(sanitize_dict(kwargs))
         event = Event(action=action, app=app, context=cleaned_kwargs)


Test patch:
diff --git a/authentik/tenants/tests/test_recovery.py b/authentik/tenants/tests/test_recovery.py
--- a/authentik/tenants/tests/test_recovery.py
+++ b/authentik/tenants/tests/test_recovery.py
@@ -70,7 +70,7 @@ def test_create_key(self):
         body = loads(response.content.decode())
         token = Token.objects.get(intent=TokenIntents.INTENT_RECOVERY, user=self.user)
         self.assertIn(token.key, body["url"])
-        self.assertEqual(len(Token.objects.all()), 1)
+        self.assertEqual(len(Token.objects.filter(intent=TokenIntents.INTENT_RECOVERY)), 1)
 
     @CONFIG.patch("outposts.disable_embedded_outpost", True)
     @CONFIG.patch("tenants.enabled", True)
@@ -86,4 +86,4 @@ def test_create_key_invalid(self):
             headers=HEADERS,
         )
         self.assertEqual(response.status_code, 404)
-        self.assertEqual(len(Token.objects.all()), 0)
+        self.assertEqual(len(Token.objects.filter(intent=TokenIntents.INTENT_RECOVERY)), 0)