Class: Janus::ConfirmationsController

Inherits:
ApplicationController
  • Object
show all
Includes:
InternalHelpers
Defined in:
lib/janus/controllers/confirmations_controller.rb

Overview

This controller is responsible for confirming any user email. It’s also responsible for resending the confirmation email on demand by the user.

Instance Method Summary collapse

Methods included from InternalHelpers

#authenticate!, #initialize_resource, #janus_scope, #mailer_class, #resource, #resource=, #resource_authentication_params, #resource_class, #resource_name, #respond_with_failure, #respond_with_success

Instance Method Details

#after_confirmation_url(resource) ⇒ Object

Where to redirect when the user has confirmed her account.



47
48
49
# File 'lib/janus/controllers/confirmations_controller.rb', line 47

def after_confirmation_url(resource)
  root_url
end

#after_resending_confirmation_instructions_url(resource) ⇒ Object

Where to redirect after the instructions have been sent.



42
43
44
# File 'lib/janus/controllers/confirmations_controller.rb', line 42

def after_resending_confirmation_instructions_url(resource)
  root_url
end

#createObject



25
26
27
28
29
30
31
32
# File 'lib/janus/controllers/confirmations_controller.rb', line 25

def create
  deliver_confirmation_instructions(resource)

  respond_with_success do
    redirect_to after_resending_confirmation_instructions_url(resource),
      notice: t('flash.janus.confirmations.create.email_sent')
  end
end

#deliver_confirmation_instructions(resource) ⇒ Object

Simple wrapper for Mailer#confirmation_instructions.deliver to allow customization of the email (eg: to pass additional data).



36
37
38
39
# File 'lib/janus/controllers/confirmations_controller.rb', line 36

def deliver_confirmation_instructions(resource)
  mail = mailer_class.confirmation_instructions(resource)
  mail.respond_to?(:deliver_later) ? mail.deliver_later : mail.deliver
end

#newObject



20
21
22
23
# File 'lib/janus/controllers/confirmations_controller.rb', line 20

def new
  self.resource = resource_class.new
  respond_with(resource)
end

#showObject



11
12
13
14
15
16
17
18
# File 'lib/janus/controllers/confirmations_controller.rb', line 11

def show
  resource.confirm!

  respond_with_success do
    redirect_to after_confirmation_url(resource),
      notice: t('flash.janus.confirmations.edit.confirmed')
  end
end