Skip to content

Commit

Permalink
Fix bug preventing a user with no otp from being redirected correctly (
Browse files Browse the repository at this point in the history
…#50)

* Fixed bug preventing a user with no otp from being redirected correctly

* Rename before_filter => before_action

Co-authored-by: Kurt Robert Rudolph <kurt.rudolph@erisfutures.com>
  • Loading branch information
n-rodriguez and Kurt Robert Rudolph authored Mar 15, 2022
1 parent 9ce95e1 commit 5a4b5bb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/devise_otp_authenticatable/hooks/sessions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def create_with_otp
resource = warden.authenticate!(auth_options)

devise_stored_location = stored_location_for(resource) # Grab the current stored location before it gets lost by warden.logout
store_location_for(resource, devise_stored_location) # Restore it since #stored_location_for removes it

otp_refresh_credentials_for(resource)

Expand Down
2 changes: 2 additions & 0 deletions test/dummy/app/controllers/posts_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
class PostsController < ApplicationController
before_action :authenticate_user!

# GET /posts
# GET /posts.json
def index
Expand Down
4 changes: 2 additions & 2 deletions test/integration/sign_in_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ def teardown
test 'a new user should be able to sign in without using their token' do
create_full_user

visit new_user_session_path
visit posts_path
fill_in 'user_email', :with => 'user@email.invalid'
fill_in 'user_password', :with => '12345678'
page.has_content?('Log in') ? click_button('Log in') : click_button('Sign in')

assert_equal root_path, current_path
assert_equal posts_path, current_path
end

test 'a new user, just signed in, should be able to sign in and enable their OTP authentication' do
Expand Down

0 comments on commit 5a4b5bb

Please sign in to comment.