Class: Devise::DeviseUserbinController

Inherits:
DeviseController
  • Object
show all
Includes:
Controllers::Helpers
Defined in:
app/controllers/devise/devise_userbin_controller.rb

Instance Method Summary collapse

Instance Method Details

#showObject



4
5
6
# File 'app/controllers/devise/devise_userbin_controller.rb', line 4

def show
  self.resource = resource_class.new
end

#updateObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/controllers/devise/devise_userbin_controller.rb', line 8

def update
  render :show and return if params[:code].nil?

  Devise.mappings.keys.flatten.any? do |scope|
    begin
      send("current_#{scope_name}") # initialize after_set_user in warden
      env['userbin'].two_factor_verify(params[:code])

      set_flash_message :notice, :success
      redirect_to (scope)
    rescue Userbin::UserUnauthorizedError => error
      set_flash_message :alert, :failed
      self.resource = resource_class.new
      respond_with_navigational(resource_name) { render :show }
    rescue Userbin::Forbidden => error
      sign_out_with_message(:no_retries_remaining, :alert)
    rescue Userbin::Error => error
      sign_out_with_message(:error, :alert)
    end
  end
end