Commit Graph

27 Commits

Author SHA1 Message Date
Ken Johnson 7b77d8281c Add styling to admin user management page and fix form submission
This commit improves the admin user management interface while preserving
the intentional mass assignment vulnerability for educational purposes.

Changes:
1. Removed layout false from admin controller to enable full styling
2. Modernized admin users table view with Bootstrap components:
   - Added page header with icon and description
   - Wrapped table in card component for better visual hierarchy
   - Updated admin indicator to use Bootstrap icons
   - Modernized Edit button styling

3. Fixed admin update_user action form submission error:
   - Previous code caused ForbiddenAttributesError in Rails
   - Used to_unsafe_h to explicitly bypass strong parameters
   - VULNERABILITY PRESERVED: This intentionally allows mass assignment
   - See wiki: Extras:-Mass-Assignment-Admin-Role.md
   - Fixed password field filtering to handle blank passwords correctly

The mass assignment vulnerability is maintained as a teaching example per
the OWASP RailsGoat mission. Students can learn about privilege escalation
attacks through the admin parameter.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-10 13:43:39 +00:00
Ken Johnson decf82962d Simplify admin user editing - remove modal, use regular CRUD pages
Remove complex modal implementation and replace with simple page navigation:
- Convert get_user view from modal partial to full edit page
- Add proper form with Bootstrap 5 styling
- Link directly from users list to edit page
- Update controller actions to redirect instead of returning JSON
- Add flash messages for success/error feedback
- Remove all modal JavaScript and markup
- Remove modal CSS and backdrop handling

Benefits:
- Much simpler and more maintainable
- No JavaScript errors or complexity
- Standard Rails CRUD pattern
- Better user experience with proper navigation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-07 22:26:17 +00:00
Ken Johnson 844acfc8e6 Use proper Bootstrap 5 native modal API with initialization
Bootstrap 5 removed jQuery plugin support, so .modal('show') doesn't work.
Switch back to native Bootstrap 5 Modal API with proper initialization:

- Dispose of any existing modal instance before creating new one
- Create modal with explicit options (backdrop, keyboard, focus)
- Add detailed console logging for each step

This ensures the modal is properly initialized before showing.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-07 22:16:24 +00:00
Ken Johnson b3b1b0d01d Use jQuery modal API instead of Bootstrap 5 native API
Switch from bootstrap.Modal class to jQuery .modal('show') method.
Bootstrap 5 still supports the jQuery plugin API for backwards
compatibility, and this method handles initialization automatically.

This should fix the issue where modal.show() was called but the
modal wasn't appearing visually.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-07 22:14:00 +00:00
Ken Johnson dff2e150a2 Add more detailed modal debugging
- Log modal element to verify it exists
- Check for existing modal instance before creating new one
- Log each step of modal creation and show process

This helps identify why modal.show() isn't displaying the modal.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-07 22:12:59 +00:00
Ken Johnson b4c6f93f68 Add debugging and fix form field attributes in admin modal
- Add console logging to openEditModal function to debug AJAX load
- Add explicit id and name attributes to admin select field
- Only show modal after content successfully loads
- Log errors if modal content fails to load

This helps diagnose the modal loading issue and fixes the Chrome
warning about form fields lacking id/name attributes.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-07 21:54:46 +00:00
Ken Johnson 779bece728 Prevent default link navigation in admin user edit button
Add 'return false;' to onClick handler to prevent the # href
from causing page navigation/redirect to dashboard.

This fixes the issue where clicking Edit would redirect to
/admin/1/dashboard# instead of opening the modal.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-07 21:28:55 +00:00
Ken Johnson 1316e75171 Modernize admin user edit modal to Bootstrap 5
Update modal content to Bootstrap 5 styling and API:
- Replace Bootstrap 2 modal-header structure with Bootstrap 5
- Update close button from 'close' class to 'btn-close'
- Replace 'data-dismiss' with 'data-bs-dismiss'
- Modernize form classes: control-group → mb-3, span12 → form-control
- Update form labels to use 'form-label' class
- Add 'form-select' class to select dropdown
- Update JavaScript to use Bootstrap 5 Modal.getInstance() API
- Add preventDefault() to button click handlers

The modal now properly loads and displays in Bootstrap 5 with
modern form styling and correct modal dismissal behavior.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-07 21:24:55 +00:00
Ken Johnson 334bc34cbe Fix Bootstrap 5 modal compatibility in admin user editor
Fix "Illegal invocation" JavaScript error when opening edit modal:
- Remove Bootstrap 2 'hide' class from modal markup
- Add proper Bootstrap 5 modal structure (modal-dialog/modal-content)
- Update JavaScript to use Bootstrap 5 Modal API
- Load dynamic content into .modal-content instead of root modal
- Remove legacy data-toggle attribute from button

The modal now uses the correct Bootstrap 5.3 structure and API,
resolving selector-engine.js errors.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-07 21:10:39 +00:00
Ken Johnson fdee945c5d Modernize password reset and admin dashboard pages
**Password Reset Pages**:

Forgot Password (password_resets/forgot_password.html.erb):
- Complete rewrite with modern card-based layout
- Icon-enhanced form with email validation
- Helpful info box with reset instructions
- "Back to Login" link for easy navigation
- Gradient background matching login page style

Reset Password (password_resets/reset_password.html.erb):
- Modern shield-lock icon header
- Password strength guidance with form text
- Confirmation field with proper validation
- Security tips info box with gradient styling
- Consistent with overall auth page design

**Admin Dashboard (admin/dashboard.html.erb)**:
- Replaced Bootstrap 2 classes with Bootstrap 5
- Modern alert design with icons and close buttons
- Card-based layout with subtle shadow
- Loading spinner state for user table
- Icon-enhanced header (people icon)
- Turbolinks compatibility
- Improved accessibility with ARIA labels

All pages now feature:
- Bootstrap 5 modern components
- Bootstrap Icons integration
- Rounded corners and gradient accents
- Smooth transitions and hover states
- Proper loading states and feedback
- Consistent design language across the app

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-07 02:25:02 -05:00
Tada, Tadashi 27f02c2dc9 improve accessibility
* add 'aria-label' into some elements without the label
* add 'aris-label' into some visual elements
* replace some 'a' elements have a button action to 'button'
2021-04-30 17:23:48 +09:00
Joseph Mastey b6c2259b88 removes user_id column from User model to use idiomatic Rails automatic IDs 2017-12-12 15:19:22 -06:00
Joseph Mastey f5a8e0c6a8 upgrade jQuery dataTable library, with minified version 2017-10-23 20:53:55 -05:00
cktricky f5cfec3bf4 Merge branch 'add-test-case-for-a1-field-injection' of https://github.com/jmmastey/railsgoat into jmmastey-add-test-case-for-a1-field-injection 2017-10-02 19:06:11 -04:00
Joseph Mastey d3fce41e60 change to idiomatic use of layouts versus regular views
no functional change here, but familiar Rails users will see view files in the
locations they expect. this also slightly simplifies controller code

there is one attendant change in the wiki at `rails_3/A1-SQL-Injection-Interpolation.md`
that I'm happy to make after the PR is merged.
2017-09-27 19:22:44 -05:00
cktricky 3d76988741 interesting bug. The piechart code was calling nonexistent code (given the view) which conflated the bug hunting and was irrelevant. The real problem was having datatables paginate twice due to the way the table is loaded. So, unnecessary code removed and resolves #216 2016-01-07 15:19:58 -05:00
James Espinosa 7e4fad462b Convert file indentation to spaces 2014-07-05 20:17:27 -05:00
James Espinosa 68e6a01743 Clean up trailing and leading whitespace 2014-07-05 19:15:32 -05:00
Mike McCabe aeabbcf8c6 A7 - switching the var used in the view so that non-admins can view the admin panel 2013-11-13 19:14:12 -05:00
Ken Johnson 0d841124f5 assigned a user id, does not "appear" to have screwed anything up 2013-05-24 15:25:06 -04:00
Ken Johnson 31ce6ab1b5 test 2013-05-24 13:19:44 -04:00
Ken Johnson bd95958f17 added delete button 2013-05-20 22:21:00 -04:00
Ken Johnson 4337cb9a46 made sure the table refreshes after an update 2013-05-20 17:35:24 -04:00
Ken Johnson 2ec81eb0de removed the button x because it caused some finnicky garbage where the alerts stayed closed 2013-05-20 16:56:44 -04:00
Ken Johnson 5fd72fcd6f update users info via ajax is working, yay. Next thing is we need to move the datatables into an ajax call and so that we can refresh the table upon any changes occuring 2013-05-20 16:31:59 -04:00
Ken Johnson 168c19bdc5 fixed broken js, it was due to a typo in an html comment 2013-05-19 12:16:34 -04:00
Ken Johnson f7dbc482bb added a table to manage users 2013-05-17 14:08:18 -04:00