Sha256: 1dc2748496b1e137e62858acd7ac58c99d9d2e528df90bfed8bf0b1e15597e57

Contents?: true

Size: 1.5 KB

Versions: 1

Compression:

Stored size: 1.5 KB

Contents

# frozen_string_literal: true

module Auth
  class ConfirmationsController < Auth::BaseController
    before_action :reset_cache
    before_action :authenticate_account!
    before_action :set_account

    # GET /resource/confirmation?confirmation_token=abcdef
    def show
      self.resource = resource_class.confirm_by_token(params[:confirmation_token])

      if resource&.errors&.empty?
        set_flash_message(:notice, :confirmed) if is_navigational_format?
        # sign_in(resource_name, resource)
        respond_with_navigational(resource) do
          redirect_to after_confirmation_path_for(resource_name, resource)
        end
      else
        respond_with_navigational(resource ? resource.errors : nil, status: :unprocessable_entity) do
          render :failure
        end
      end
    end

    private

    def authenticate_account!
      # store_location_for(:account, request.fullpath) if request.format.html?
      # we don't have new session path :(
      redirect_to(root_path(anchor: 'login-required')) unless account_signed_in?
    end

    def set_account
      @account = current_account
    end

    # The path used after resending confirmation instructions.
    def after_resending_confirmation_instructions_path_for(_resource_name)
      root_path(anchor: 'login-required') if is_navigational_format?
    end

    # The path used after confirmation.
    def after_confirmation_path_for(_resource_name, _resource)
      # after_sign_in_path_for(resource)
      edit_account_profile_path
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
translation_cms-0.1.5 app/controllers/auth/confirmations_controller.rb