Sha256: 1f238d71333c38fc3378e6a8371d7cfe7b6b081b72fee24cf5bf472c6ce96ace
Contents?: true
Size: 1.33 KB
Versions: 6
Compression:
Stored size: 1.33 KB
Contents
module DeviseXfactorAuthentication module Controllers module Helpers extend ActiveSupport::Concern included do before_action :handle_devise_xfactor_authentication end private def handle_devise_xfactor_authentication unless devise_controller? Devise.mappings.keys.flatten.any? do |scope| if signed_in?(scope) and warden.session(scope)[DeviseXfactorAuthentication::NEED_AUTHENTICATION] handle_failed_second_factor(scope) end end end end def handle_failed_second_factor(scope) if request.format.present? and request.format.html? session["#{scope}_return_to"] = request.original_fullpath if request.get? redirect_to devise_xfactor_authentication_path_for(scope) else head :unauthorized end end def devise_xfactor_authentication_path_for(resource_or_scope = nil) scope = Devise::Mapping.find_scope!(resource_or_scope) change_path = "#{scope}_devise_xfactor_authentication_path" send(change_path) end end end end module Devise module Controllers module Helpers def is_fully_authenticated? !session["warden.user.user.session"].try(:[], DeviseXfactorAuthentication::NEED_AUTHENTICATION) end end end end
Version data entries
6 entries across 6 versions & 1 rubygems