Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions app/views/users/_edit_sofia_account_modal.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@
<%= f.input :name, label: 'Naam', placeholder: 'Naam', required: true %>
<% end %>
<%= f.input :email, label: 'E-mailadres', placeholder: 'E-mailadres', required: true %>
<% if Rails.application.config.x.subprovider_label.present? %>
<%= f.input :sub_provider, label: 'SubProvider', placeholder: Rails.application.config.x.subprovider_label, required: true, input_html: { style: 'text-transform: uppercase;', onkeyup: 'this.value = this.value.toUpperCase();' } %>
<% end %>
<% if current_user.treasurer? %>
<div class="row">
<div class="col-lg-3">
Expand Down
3 changes: 3 additions & 0 deletions app/views/users/_new_sofia_account_user_modal.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
<div class="modal-body" id="activities_modal">
<%= f.input :name, label: 'Naam', placeholder: 'Naam', required: true %>
<%= f.input :email, label: 'E-mailadres', placeholder: 'E-mailadres', required: true %>
<% if Rails.application.config.x.subprovider_label.present? %>
<%= f.input :sub_provider, label: 'Subprovider', placeholder: Rails.application.config.x.subprovider_label, required: true, input_html: { style: 'text-transform: uppercase;', onkeyup: 'this.value = this.value.toUpperCase();' } %>
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The label for the sub_provider field uses 'Subprovider', but in the code that was removed from the edit modal, it was 'SubProvider' (with capital P). This inconsistency should be corrected to match the original capitalization for consistency.

Suggested change
<%= f.input :sub_provider, label: 'Subprovider', placeholder: Rails.application.config.x.subprovider_label, required: true, input_html: { style: 'text-transform: uppercase;', onkeyup: 'this.value = this.value.toUpperCase();' } %>
<%= f.input :sub_provider, label: 'SubProvider', placeholder: Rails.application.config.x.subprovider_label, required: true, input_html: { style: 'text-transform: uppercase;', onkeyup: 'this.value = this.value.toUpperCase();' } %>

Copilot uses AI. Check for mistakes.
<% end %>
Comment on lines +16 to +18
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check User model for sub_provider validations
echo "=== Searching for sub_provider validations in User model ==="
rg -n 'validates.*sub_provider|presence.*sub_provider' app/models/ || echo "No validates directive found"

# Check for sub_provider in entire models directory
echo "=== All sub_provider references in models ==="
rg -n -B 2 -A 2 'sub_provider' app/models/ || echo "No sub_provider references found"

# Check for uppercase/upcase handling for sub_provider
echo "=== Checking for uppercase normalization ==="
rg -n -B 2 -A 2 'upcase|uppercase' app/models/ app/controllers/ | grep -A 2 -B 2 'sub_provider\|provider' || echo "No uppercase handling found"

# List the edit modal file to verify it exists
echo "=== Checking edit modal file ==="
fd '_edit_sofia_account_modal' app/views/users/

# Check sub_provider in edit modal
echo "=== Checking if sub_provider exists in edit modal ==="
if [ -f "app/views/users/_edit_sofia_account_modal.html.erb" ]; then
  rg -n 'sub_provider' app/views/users/_edit_sofia_account_modal.html.erb || echo "No sub_provider found in edit modal"
else
  echo "Edit modal file not found"
fi

# Get context of the new modal around the sub_provider field
echo "=== Context of new modal (lines 14-20) ==="
sed -n '14,20p' app/views/users/_new_sofia_account_user_modal.html.erb

Repository: csvalpha/sofia

Length of output: 1048


🏁 Script executed:

#!/bin/bash
# Check User model file to see full structure
echo "=== User model existence ==="
fd 'user.rb' app/models/ | head -5

# Check if sub_provider is an accessor or attribute
echo "=== Checking User model for sub_provider attribute/accessor ==="
rg -n 'attr_|sub_provider' app/models/user.rb

# Check strong parameters/permit list in controller
echo "=== Checking controller for sub_provider in params permit ==="
rg -n -B 3 -A 3 'permit.*sub_provider|params\[:user\]' app/controllers/ | grep -B 3 -A 3 'sub_provider\|user_params' || echo "Checking for user controller..."

# Find user-related controllers
echo "=== Finding user-related controllers ==="
fd 'users_controller' app/controllers/

Repository: csvalpha/sofia

Length of output: 1300


🏁 Script executed:

#!/bin/bash
# Read the entire User model
echo "=== Full User model ==="
head -80 app/models/user.rb

# Check for database schema/migrations
echo "=== Checking schema for sub_provider column ==="
rg -n 'sub_provider' db/schema.rb || echo "Not in schema.rb"

# Check recent migrations for sub_provider
echo "=== Checking migrations for sub_provider ==="
fd 'migrate' db/migrate | xargs rg -l 'sub_provider' | head -5

# If migrations found, show content
echo "=== Migration content ==="
fd 'migrate' db/migrate | xargs rg -B 2 -A 2 'sub_provider' || echo "No sub_provider in migrations"

Repository: csvalpha/sofia

Length of output: 6123


Add presence validation and backend normalization for sub_provider field

The sub_provider field is now in the new modal with required: true, but the User model lacks critical backend safeguards:

  1. Missing presence validation: No validates :sub_provider, presence: true in the User model, despite the form marking it as required.
  2. Missing backend normalization: No backend uppercasing logic exists—only client-side onkeyup handler enforcement, which users can bypass.
  3. Data integrity risk: Without backend validation and normalization, submitted data may be lowercase, contradicting the UI intent.

Add to the User model:

validates :sub_provider, presence: true, if: -> { Rails.application.config.x.subprovider_label.present? }
before_save { self.sub_provider = sub_provider.upcase if sub_provider.present? }

Remove the onkeyup handler from the form if backend normalization is added, or keep it for UX consistency but ensure the backend is the source of truth.

🤖 Prompt for AI Agents
In app/views/users/_new_sofia_account_user_modal.html.erb around lines 16-18,
the form marks :sub_provider as required but the User model lacks backend
presence validation and normalization; add a conditional presence validation
(only when Rails.application.config.x.subprovider_label.present?) and a
before_save callback to upcase sub_provider if present so the database always
stores uppercase values; after adding backend normalization you may remove the
client-side onkeyup handler from the form (or keep it for UX) since the backend
will be the source of truth.

</div>

<div class="modal-footer">
Expand Down