feat: Display ticket based on `qr_code` field

- Previously ticket was displayed using id which is too easy to find
- Now the URL takes ``qr_code`` field as parameters
This commit is contained in:
kbe
2025-09-06 20:33:42 +02:00
parent ce0752bbda
commit 213a11e731
4 changed files with 12 additions and 15 deletions

View File

@@ -48,11 +48,10 @@ class TicketsController < ApplicationController
end
end
# Display informations about the event with QR code
def show
@ticket = Ticket.joins(order: :user).includes(:event, :ticket_type, order: :user).find_by(
tickets: { id: params[:ticket_id] },
orders: { user_id: current_user.id }
)
@ticket = Ticket.joins(order: :user).includes(:event, :ticket_type, order: :user)
.find_by(tickets: { qr_code: params[:qr_code] })
if @ticket.nil?
redirect_to dashboard_path, alert: "Billet non trouvé"
@@ -63,6 +62,7 @@ class TicketsController < ApplicationController
rescue ActiveRecord::RecordNotFound
redirect_to dashboard_path, alert: "Billet non trouvé"
end
private
def set_event