2424 role_project_member ,
2525 role_org_member ,
2626 role_org_member_attr ,
27- check_user_id ,
2827 access_toggled_notification ,
2928 log_event ,
3029 get_minio_client ,
@@ -683,7 +682,7 @@ def post(self):
683682 return keycloak_response
684683
685684
686- @user_ns .route ('/<string:user_id>' )
685+ @user_ns .route ('/<string:user_id>' )
687686class User (Resource ):
688687
689688 ### GET /users/<user_id> ###
@@ -692,7 +691,7 @@ class User(Resource):
692691 @require_auth (keycloak_auth )
693692 def get (self , user_id ):
694693 """Get user details by ID
695-
694+
696695 Users can view their own profile.
697696 Admins can view any user's profile.
698697 """
@@ -701,18 +700,19 @@ def get(self, user_id):
701700 # Get current user info
702701 user_info = extract_user_info (request .user )
703702 current_user_id = user_info .get ('user_id' )
704-
703+
705704 # Check if user is trying to view their own profile
706705 is_self_view = current_user_id == user_id
707-
706+
708707 # Check permissions - allow self-view or admin access
709708 if not is_self_view :
710709 has_perm , details = user_has_permission (user_info , 'manage_users' )
710+ user_info = keycloak_auth .get_user (user_id )
711711 if not has_perm :
712712 return {'error' : 'Permission denied. You can only view your own profile or need admin permissions.' , 'details' : details }, 403
713-
713+
714714 return user_info
715-
715+
716716 except Exception as e :
717717 logger .exception (f"Error retrieving user { user_id } : { str (e )} " )
718718 return {'error' : f'Failed to retrieve user: { str (e )} ' }, 500
0 commit comments