Browse Source

Merge pull request #28 from edg3r/control

added is_fully_authenticated helper for current version
master
Dmitrii Golub 11 years ago
parent
commit
39deb66561
  1. 10
      lib/two_factor_authentication/controllers/helpers.rb
  2. 20
      spec/controllers/two_factor_auth_spec.rb

10
lib/two_factor_authentication/controllers/helpers.rb

@ -37,3 +37,13 @@ module TwoFactorAuthentication
end
end
end
module Devise
module Controllers
module Helpers
def is_fully_authenticated?
!session["warden.user.user.session"].try(:[], :need_two_factor_authentication)
end
end
end
end

20
spec/controllers/two_factor_auth_spec.rb

@ -0,0 +1,20 @@
require 'spec_helper'
include Warden::Test::Helpers
describe HomeController do
context "passed only 1st factor auth" do
let(:user) { create_user }
describe "is_fully_authenticated helper" do
it "should be true" do
login_as user, scope: :user
visit user_two_factor_authentication_path
controller.is_fully_authenticated?.should be_true
end
end
end
end
Loading…
Cancel
Save