Sha256: a4f5a9190161e731b33bc3401dbdb27cc4d3a4c19a2c9641a4c273c16936e7ff

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

class Tramway::Auth::Web::SignUpsController < Tramway::Auth::Web::ApplicationController
  before_action :check_authenticable_models

  def create
    @form = "#{model_class}SignUpForm".constantize.new model_class.new
    if @form.submit params[:record]
      additional_params = { flash: :success }
      url = if params[:redirect].present?
              [params[:redirect], '?', additional_params.to_query].join
            else
              Rails.application.routes.url_helpers.root_path(flash: :success)
            end
      redirect_to url
    else
      additional_params = { flash: :error, errors: @form.errors.messages, record: @form.attributes }
      url = if params[:redirect].present?
              [params[:redirect], '?', additional_params.to_query].join
            else
              Rails.application.routes.url_helpers.root_path(**additional_params)
            end
      redirect_to url
    end
  end

  private

  def check_authenticable_models
    return unless params[:model].in? Tramway::Auth.authenticable_models
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tramway-auth-1.2.1.1 app/controllers/tramway/auth/web/sign_ups_controller.rb