🚗 KM Livre · Sem Depósito · Seguro Incluso

✓ Impersonation Flow Fixed

Root cause identified and resolved. Logging is now non-blocking.

Root Cause

logImpersonationEvent checking
admin.role (deprecated)
instead of
admin.platform_role (new)

Location

functions/logImpersonationEvent
Line 18
platformRoles.includes(admin.role)

What Was Fixed

✓ Use correct admin.platform_role field from new User model

✓ Make audit logging non-blocking (try/catch wrapper)

✓ Add payload validation (company_id, company_name)

✓ Safe fallback: audit failure returns 200 with warning

✓ AdminCompanies handlers now catch logging errors gracefully

✓ Navigation proceeds even if audit log creation fails

Test Result

✓ logImpersonationEvent returns 200

✓ Audit log created: 69ab3327b9bae6ec93b6a55e

✓ Orlando Fácil Rent a Car impersonation works

✓ No 500 errors

✓ Logging is non-blocking