Class: My::ConfirmationsController

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

Instance Method Summary collapse

Methods included from Authentication

#create_token_for_user, #deactivate_token, #pop_token, #redirect_authenticated_user

Instance Method Details

#createObject

post /my/confirmation



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

def create
  if current_user.email.blank?
    redirect_to edit_my_profile_path, notice: t('my.confirmations.create.set_email')
  else
    code = CodeManager::Confirmation.code_for_user(current_user)
    CodeSender.email(code.id).deliver_later unless code.nil?
    redirect_to my_confirmation_path, notice: t('my.confirmations.create.success')
  end
end

#showObject

get /my/confirmation



8
9
# File 'app/controllers/my/confirmations_controller.rb', line 8

def show
end

#updateObject

patch /my/confirmation



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

def update
  code    = Code.find_by(body: param_from_request(:code))
  manager = CodeManager::Confirmation.new(code)
  if manager.code_is_valid?
    manager.activate
    create_token_for_user(code.user)
    redirect_to my_path
  else
    redirect_to my_confirmation_path, alert: t('my.confirmations.update.invalid_code')
  end
end