Class: DeviseOtp::Devise::OtpCredentialsController
- Inherits:
-
DeviseController
- Object
- DeviseController
- DeviseOtp::Devise::OtpCredentialsController
- Defined in:
- app/controllers/devise_otp/devise/otp_credentials_controller.rb
Instance Method Summary collapse
-
#get_refresh ⇒ Object
displays the request for a credentials refresh.
-
#set_refresh ⇒ Object
lets the user through is the refresh is valid.
-
#show ⇒ Object
show a request for the OTP token.
-
#update ⇒ Object
signs the resource in, if the OTP token is valid and the user has a valid challenge.
Instance Method Details
#get_refresh ⇒ Object
displays the request for a credentials refresh
47 48 49 50 |
# File 'app/controllers/devise_otp/devise/otp_credentials_controller.rb', line 47 def get_refresh ensure_resource! render :refresh end |
#set_refresh ⇒ Object
lets the user through is the refresh is valid
55 56 57 58 59 60 61 62 63 |
# File 'app/controllers/devise_otp/devise/otp_credentials_controller.rb', line 55 def set_refresh ensure_resource! if resource.valid_password?(params[resource_name][:refresh_password]) done_valid_refresh else failed_refresh end end |
#show ⇒ Object
show a request for the OTP token
17 18 19 20 21 22 23 |
# File 'app/controllers/devise_otp/devise/otp_credentials_controller.rb', line 17 def show if @recovery @recovery_count = resource.otp_recovery_counter end render :show end |
#update ⇒ Object
signs the resource in, if the OTP token is valid and the user has a valid challenge
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/controllers/devise_otp/devise/otp_credentials_controller.rb', line 28 def update if @token.blank? (:alert, :token_blank) redirect_to otp_credential_path_for(resource_name, challenge: @challenge, recovery: @recovery) elsif resource.otp_challenge_valid? && resource.validate_otp_token(@token, @recovery) sign_in(resource_name, resource) otp_set_trusted_device_for(resource) if params[:enable_persistence] == "true" otp_refresh_credentials_for(resource) respond_with resource, location: after_sign_in_path_for(resource) else :alert, :token_invalid render :show end end |