Logs out the authenticated user
(self, request)
| 182 | description="Log out the current user", |
| 183 | ) |
| 184 | def logout(self, request): |
| 185 | """Logs out the authenticated user""" |
| 186 | # Log logout event before actually logging out |
| 187 | from core.utils import log_system_event |
| 188 | username = request.user.username if request.user and request.user.is_authenticated else 'unknown' |
| 189 | client_ip = request.META.get('REMOTE_ADDR', 'unknown') |
| 190 | user_agent = request.META.get('HTTP_USER_AGENT', 'unknown') |
| 191 | |
| 192 | log_system_event( |
| 193 | event_type='logout', |
| 194 | user=username, |
| 195 | client_ip=client_ip, |
| 196 | user_agent=user_agent, |
| 197 | ) |
| 198 | logger.info(f"Logout: user={username} ip={client_ip}") |
| 199 | |
| 200 | logout(request) |
| 201 | return Response({"message": "Logout successful"}) |
| 202 | |
| 203 | |
| 204 | # 🔹 2) User Management APIs |
nothing calls this directly
no test coverage detected