Class: Devise::DisplayqrController

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

Instance Method Summary collapse

Instance Method Details

#refreshObject



46
47
48
49
50
51
52
53
54
55
56
# File 'app/controllers/devise/displayqr_controller.rb', line 46

def refresh
  unless resource.nil?
    resource.send(:assign_auth_secret)
    resource.save
    set_flash_message :notice, :newtoken
     scope, resource, bypass: true
    redirect_to [resource_name, :displayqr]
  else
    redirect_to :root
  end
end

#showObject

GET /resource/displayqr



15
16
17
18
19
20
21
22
23
# File 'app/controllers/devise/displayqr_controller.rb', line 15

def show
  if resource.nil? || resource.gauth_secret.nil?
     resource_class.new, resource
    redirect_to stored_location_for(scope) || :root
  else
    @tmpid = resource.assign_tmp
    render :show
  end
end

#updateObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'app/controllers/devise/displayqr_controller.rb', line 25

def update
  if resource.gauth_tmp != params[resource_name]['tmpid'] || !resource.validate_token(params[resource_name]['gauth_token'].to_i)
    set_flash_message(:error, :invalid_token)
    render :show
    return
  end

  if resource.set_gauth_enabled(params[resource_name]['gauth_enabled'])
    set_flash_message :notice, (resource.gauth_enabled? ? :enabled : :disabled)
    if Gem::Version.new(Devise::VERSION) < Gem::Version.new('4.2.0')
       scope, resource, bypass: true
    else
       resource, scope: scope
    end

    respond_with resource, location: (resource)
  else
    render :show
  end
end