Class: Spree::UserConfirmationsController

Inherits:
Devise::ConfirmationsController
  • Object
show all
Includes:
Core::ControllerHelpers::Auth, Core::ControllerHelpers::Common, Core::ControllerHelpers::Order, Core::ControllerHelpers::Store
Defined in:
app/controllers/spree/user_confirmations_controller.rb

Instance Method Summary collapse

Instance Method Details

#show {|resource| ... } ⇒ Object

GET /resource/confirmation?confirmation_token=abcdef

Yields:

  • (resource)


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/controllers/spree/user_confirmations_controller.rb', line 12

def show
  self.resource = resource_class.confirm_by_token(params[:confirmation_token])
  yield resource if block_given?

  if resource.errors.empty?
    set_flash_message!(:notice, :confirmed)
    respond_with_navigational(resource) do
      redirect_to after_confirmation_path_for(resource_name, resource)
    end
  elsif resource.confirmed?
    set_flash_message(:error, :already_confirmed)
    respond_with_navigational(resource) do
      redirect_to after_confirmation_path_for(resource_name, resource)
    end
  else
    respond_with_navigational(resource.errors, status: :unprocessable_entity) do
      render :new
    end
  end
end