You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: infrastructure/common-images/cloudharness-django/libraries/cloudharness-django/cloudharness_django/middleware.py
+15-15Lines changed: 15 additions & 15 deletions
Original file line number
Diff line number
Diff line change
@@ -17,30 +17,30 @@
17
17
def_get_user(kc_user_id: str) ->User:
18
18
"""
19
19
Get or create a Django user for the given Keycloak user ID.
20
-
20
+
21
21
CRITICAL SAFETY GUARANTEE: This function will NEVER return a User without a valid Member.
22
22
If we cannot ensure a Member exists, we return None (which triggers anonymous user behavior).
23
-
23
+
24
24
Returns:
25
25
User: A Django User with a guaranteed Member relationship, or None for anonymous
26
26
"""
27
27
user=None
28
28
ifkc_user_idisNone:
29
29
returnNone
30
-
30
+
31
31
try:
32
32
# Try to get existing user by member relationship
33
33
try:
34
34
user=User.objects.get(member__kc_id=kc_user_id)
35
-
35
+
36
36
# SAFETY CHECK: Verify member relationship is intact
37
37
try:
38
38
_=user.member# Access to verify it exists
39
39
exceptMember.DoesNotExist:
40
40
# Member was deleted between the query and now - return None for safety
41
41
log.error("User %s found but Member missing. Returning anonymous.", user.id)
Copy file name to clipboardExpand all lines: infrastructure/common-images/cloudharness-django/libraries/cloudharness-django/cloudharness_django/services/user.py
0 commit comments