Class: Milia::ConfirmationsController

Inherits:
Devise::ConfirmationsController
  • Object
show all
Defined in:
app/controllers/confirmations_controller.rb

Instance Method Summary collapse

Instance Method Details

#showObject

GET /resource/confirmation?confirmation_token=abcdef entered on new sign-ups and invite-members


42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'app/controllers/confirmations_controller.rb', line 42

def show
  if @confirmable.new_record?  ||
     !::Milia.use_invite_member ||
     @confirmable.skip_confirm_change_password

    log_action( "devise pass-thru" )
    super  # this will redirect
    if @confirmable.skip_confirm_change_password
      (resource)
    end
  else
    log_action( "password set form" )
    prep_do_show()  # prep for the form
  end
  # else fall thru to show template which is form to set a password
  # upon SUBMIT, processing will continue from update
end

#updateObject

PUT /resource/confirmation entered ONLY on invite-members usage to set password at time of confirmation


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/controllers/confirmations_controller.rb', line 14

def update
  if @confirmable.attempt_set_password(user_params)

    # this section is patterned off of devise 3.2.5 confirmations_controller#show

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

    if resource.errors.empty?
      log_action( "invitee confirmed" )
      set_flash_message(:notice, :confirmed)
        # sign in automatically
      (resource)

    else
      log_action( "invitee confirmation failed" )
      respond_with_navigational(resource.errors, :status => :unprocessable_entity){ render :new }
    end

  else
    log_action( "invitee password set failed" )
    prep_do_show()  # prep for the form
    respond_with_navigational(resource.errors, :status => :unprocessable_entity){ render :show }
  end  # if..then..else passwords are valid
end