towerops/lib/towerops_web/controllers
Graham McIntire 9ff9c4ddc8
fix: address UserSudoController critical issues
Critical fixes:
- Renamed controller actions to follow Phoenix conventions (verify→new, create→verify)
- Added sudo mode check in GET action using last_sudo_at timestamp
- Added TOTP enrollment check in GET action with redirect
- Changed default return path from /orgs to /users/settings
- Updated route paths from /users/sudo/verify to /users/sudo-verify (dash separator)
- Added success flash message "Identity verified."

Implementation details:
- new/2 (GET): Checks recently_verified_sudo?/1 helper that examines last_sudo_at
  instead of authenticated_at to distinguish sudo verification from regular login
- verify/2 (POST): Adds info flash and defaults to /users/settings
- recently_verified_sudo?/1: Private helper checking last_sudo_at within 10 minutes
- Updated all routes, templates, and tests to use new paths and action names

Tests:
- Added tests for already-in-sudo-mode redirect behavior
- Added test for TOTP enrollment requirement
- Updated all test assertions for new route paths and success messages
- All 15 controller tests passing
- Full test suite passing (4076 tests, 0 failures)
2026-02-01 14:45:05 -06:00
..
api live device polling 2026-02-01 13:19:32 -06:00
api_docs_html impersonate fixes 2026-01-28 14:41:27 -06:00
error_html add error pages 2026-01-06 14:37:48 -06:00
page_html enhance user auditing 2026-01-30 17:38:07 -06:00
user_registration_html gdpr consent tracking 2026-01-29 11:12:35 -06:00
user_reset_password_html forgot password flow 2026-01-31 17:03:22 -06:00
user_session_html forgot password flow 2026-01-31 17:03:22 -06:00
user_settings_html paginate discovered devices 2026-01-31 10:31:37 -06:00
user_sudo_html fix: address UserSudoController critical issues 2026-02-01 14:45:05 -06:00
admin_controller.ex Add superuser system with user impersonation for admin support 2026-01-06 12:50:10 -06:00
api_docs_controller.ex updates 2026-01-17 17:49:53 -06:00
api_docs_html.ex updates 2026-01-17 17:49:53 -06:00
debug_controller.ex add headers debug in prod 2026-02-01 10:54:13 -06:00
error_html.ex add error pages 2026-01-06 14:37:48 -06:00
error_json.ex init 2025-12-21 11:10:43 -06:00
health_controller.ex security fixes 2026-01-28 17:02:36 -06:00
page_controller.ex cookie improvements 2026-01-28 12:30:28 -06:00
page_html.ex init 2025-12-21 11:10:43 -06:00
user_registration_controller.ex impersonate fixes 2026-01-28 14:41:27 -06:00
user_registration_html.ex credo cleanup 2026-01-17 15:00:52 -06:00
user_reset_password_controller.ex forgot password flow 2026-01-31 17:03:22 -06:00
user_reset_password_html.ex forgot password flow 2026-01-31 17:03:22 -06:00
user_session_controller.ex fix TOTP enrollment with recovery codes 2026-01-31 14:54:44 -06:00
user_session_html.ex credo cleanup 2026-01-17 15:00:52 -06:00
user_settings_controller.ex Convert User Settings from controller to LiveView 2026-01-15 16:29:50 -06:00
user_settings_html.ex credo cleanup 2026-01-17 15:00:52 -06:00
user_sudo_controller.ex fix: address UserSudoController critical issues 2026-02-01 14:45:05 -06:00
user_sudo_html.ex feat: implement sudo mode MFA-only verification controller 2026-02-01 14:34:17 -06:00