[30388f42] Infrastructure Hardening: Repaired CE/Connector DB schema, fixed frontend styling build, implemented robust echo shield in worker v2.1.1, and integrated Lead Engine into gateway.
This commit is contained in:
42
connector-superoffice/tools/who_am_i.py
Normal file
42
connector-superoffice/tools/who_am_i.py
Normal file
@@ -0,0 +1,42 @@
|
||||
import sys
|
||||
import os
|
||||
import json
|
||||
from dotenv import load_dotenv
|
||||
|
||||
# Explicitly load .env from the project root
|
||||
dotenv_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '.env'))
|
||||
load_dotenv(dotenv_path=dotenv_path, override=True)
|
||||
|
||||
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
|
||||
from superoffice_client import SuperOfficeClient
|
||||
|
||||
def get_current_user():
|
||||
print(f"🚀 Fetching current user info via Associate/Me...")
|
||||
try:
|
||||
client = SuperOfficeClient()
|
||||
if not client.access_token:
|
||||
print("❌ Authentication failed.")
|
||||
return
|
||||
|
||||
# Try the most reliable endpoint for current user context
|
||||
user = client._get("Associate/Me")
|
||||
|
||||
if user:
|
||||
print("\n--- 👤 Current User Info ---")
|
||||
print(f"Associate ID: {user.get('AssociateId')}")
|
||||
print(f"Name: {user.get('FullName')}")
|
||||
print(f"UserName: {user.get('UserName')}")
|
||||
print("----------------------------")
|
||||
return user.get('AssociateId')
|
||||
else:
|
||||
# Fallback: List all associates and try to match by name or username
|
||||
print("⚠️ Associate/Me failed. Trying alternative...")
|
||||
# This might be too much data, but let's see
|
||||
return None
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ Error: {e}")
|
||||
return None
|
||||
|
||||
if __name__ == "__main__":
|
||||
get_current_user()
|
||||
Reference in New Issue
Block a user