Class: DeviseOtp::TokensController
- Inherits:
-
DeviseController
- Object
- DeviseController
- DeviseOtp::TokensController
- Includes:
- Devise::Controllers::Helpers
- Defined in:
- app/controllers/devise_otp/tokens_controller.rb
Instance Method Summary collapse
-
#clear_persistence ⇒ Object
clears persistence for the current browser.
-
#delete_persistence ⇒ Object
rehash the persistence secret, thus, making all the persistence cookies invalid.
-
#destroy ⇒ Object
Resets OTP authentication, generates new credentials, sets it to off.
-
#get_persistence ⇒ Object
makes the current browser persistent.
- #recovery ⇒ Object
-
#show ⇒ Object
Displays the status of OTP authentication.
-
#update ⇒ Object
Updates the status of OTP authentication.
Instance Method Details
#clear_persistence ⇒ Object
clears persistence for the current browser
61 62 63 64 65 66 67 |
# File 'app/controllers/devise_otp/tokens_controller.rb', line 61 def clear_persistence if otp_clear_trusted_device_for(resource) :success, :successfully_cleared_persistence end redirect_to :action => :show end |
#delete_persistence ⇒ Object
rehash the persistence secret, thus, making all the persistence cookies invalid
73 74 75 76 77 78 79 |
# File 'app/controllers/devise_otp/tokens_controller.rb', line 73 def delete_persistence if otp_reset_persistence_for(resource) :notice, :successfully_reset_persistence end redirect_to :action => :show end |
#destroy ⇒ Object
Resets OTP authentication, generates new credentials, sets it to off
36 37 38 39 40 41 42 |
# File 'app/controllers/devise_otp/tokens_controller.rb', line 36 def destroy if resource.reset_otp_credentials! :success, :successfully_reset_creds end render :show end |
#get_persistence ⇒ Object
makes the current browser persistent
48 49 50 51 52 53 54 55 |
# File 'app/controllers/devise_otp/tokens_controller.rb', line 48 def get_persistence if otp_set_trusted_device_for(resource) :success, :successfully_set_persistence end redirect_to :action => :show end |
#recovery ⇒ Object
84 85 86 87 88 89 90 91 92 |
# File 'app/controllers/devise_otp/tokens_controller.rb', line 84 def recovery respond_to do |format| format.html format.js format.text do send_data render_to_string(template: "devise_otp/tokens/recovery_codes.text.erb"), filename: "recovery-codes.txt" end end end |
#show ⇒ Object
Displays the status of OTP authentication
12 13 14 15 16 17 18 |
# File 'app/controllers/devise_otp/tokens_controller.rb', line 12 def show if resource.nil? redirect_to stored_location_for(scope) || :root else render :show end end |
#update ⇒ Object
Updates the status of OTP authentication
23 24 25 26 27 28 29 30 31 |
# File 'app/controllers/devise_otp/tokens_controller.rb', line 23 def update enabled = (params[resource_name][:otp_enabled] == '1') if (enabled ? resource.enable_otp! : resource.disable_otp!) :info, :successfully_updated end render :show end |