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
feat: add comprehensive admin impersonation system
Database enhancements:
- Add impersonation fields to user_sessions table (impersonated_by, timestamps)
- Automatic schema migration for existing databases
Impersonation core functionality:
- start_impersonation() and end_impersonation() functions in candidates.py
- Admin-only access with comprehensive validation
- Secure session token generation and management
- Full audit trail of impersonation start/end events
API endpoints:
- POST /api/admin/impersonate/<user_id> - Start impersonation
- POST /api/admin/end-impersonation - End impersonation session
- Proper error handling and admin authentication required
Session management:
- Updated require_candidate_auth decorator to handle impersonation
- Seamless switching between normal and impersonated sessions
- Proper session cleanup when ending impersonation
UI enhancements:
- Impersonate button in admin candidates list
- Prominent impersonation banner when active
- End Impersonation button always visible during impersonation
- Confirmation dialogs for all impersonation actions
Activity logging:
- All impersonated activity logged with admin context
- Appears in candidate's activity log with impersonation indicators
- Comprehensive audit trail for compliance and debugging
Security features:
- Admin-only access (requires session.admin_user)
- Impersonation sessions tracked separately from regular sessions
- Cannot impersonate other admins
- All actions logged with admin identity and target user
This allows admins to safely test the candidate experience while
maintaining full audit trails and security boundaries.
if(!confirm(`Are you sure you want to impersonate candidate "${username}"?\n\nThis will:\n• Log you in as the candidate\n• Track all activity as impersonation\n• Allow you to see their exact experience\n\nClick OK to start impersonation.`)){
303
+
return;
304
+
}
305
+
306
+
fetch(`/api/admin/impersonate/${userId}`,{
307
+
method: 'POST',
308
+
headers: {
309
+
'Content-Type': 'application/json',
310
+
}
311
+
})
312
+
.then(response=>response.json())
313
+
.then(data=>{
314
+
if(data.success){
315
+
// Show success message and redirect
316
+
alert(`Successfully started impersonating "${username}".\n\nYou will now see the candidate experience. Use the "End Impersonation" button to return to admin mode.`);
317
+
window.location.href=data.redirect_url;
318
+
}else{
319
+
alert(`Failed to start impersonation: ${data.error}`);
0 commit comments