Files
MatchLiveTv/backend/app/controllers/public/registrations_controller.rb
Emiliano Frascaro 4083bc5dee Club come entità principale, branding e fix infrastruttura streaming.
Introduce clubs con abbonamento, branding Active Storage e flusso registrazione società; corregge healthcheck MediaMTX (immagine distroless) e allinea dominio produzione matchlivetv.it.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-27 09:16:24 +02:00

40 lines
1.4 KiB
Ruby
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
module Public
class RegistrationsController < WebBaseController
def new
redirect_to public_club_path(current_user.primary_club) if logged_in? && current_user.primary_club
@user = User.new
end
def create
unless params[:accept_terms] == "1"
@user = User.new(user_params.merge(role: "coach"))
flash.now[:alert] = "Devi accettare linformativa privacy e i termini di servizio per registrarti."
return render :new, status: :unprocessable_entity
end
@user = User.new(user_params.merge(role: "coach"))
if @user.save
session[:user_id] = @user.id
if session[:pending_invite_token].present?
token = session.delete(:pending_invite_token)
invitation = TeamInvitation.pending.find_by(token_digest: Digest::SHA256.hexdigest(token))
if invitation && invitation.email.downcase == @user.email.downcase
invitation.accept!(@user)
return redirect_to public_team_dashboard_path(invitation.team), notice: "Benvenuto nella squadra!"
end
end
redirect_to public_new_club_path, notice: "Account creato. Ora registra la tua società."
else
flash.now[:alert] = @user.errors.full_messages.join(", ")
render :new, status: :unprocessable_entity
end
end
private
def user_params
params.require(:user).permit(:name, :email, :password, :password_confirmation)
end
end
end