Class: My::ConfirmationsController

Inherits:
ApplicationController
  • Object
show all
Includes:
Authentication
Defined in:
app/controllers/my/confirmations_controller.rb

Overview

Sending and checking email confirmation codes

Instance Method Summary collapse

Methods included from Authentication

#cookie_data, #create_token_for_user, #deactivate_token, #pop_token, #redirect_authenticated_user

Instance Method Details

#createObject

post /my/confirmation



14
15
16
17
18
19
20
21
22
# File 'app/controllers/my/confirmations_controller.rb', line 14

def create
  if current_user.email.blank?
    redirect_to edit_my_profile_path, notice: t('.set_email')
  else
    component_handler.send_email_confirmation(current_user)

    redirect_to my_confirmation_path, notice: t('.success')
  end
end

#showObject

get /my/confirmation



10
11
# File 'app/controllers/my/confirmations_controller.rb', line 10

def show
end

#updateObject

patch /my/confirmation



25
26
27
28
29
30
31
32
33
34
35
# File 'app/controllers/my/confirmations_controller.rb', line 25

def update
  code = Code.find_by(body: param_from_request(:code))
  if component_handler.valid_email_confirmation?(code)
    component_handler.activate_email_confirmation(code)
    create_token_for_user(code.user)
    redirect_to my_path
  else
    flash[:error] = t('.invalid_code')
    redirect_to my_confirmation_path
  end
end