Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow only one confirmation #1001

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/controllers/devise_token_auth/confirmations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ def show
token_hash = BCrypt::Password.create(token)
expiry = (Time.now + @resource.token_lifespan).to_i

if @resource.sign_in_count > 0
expiry = (Time.now + 1.second).to_i
end

@resource.tokens[client_id] = {
token: token_hash,
expiry: expiry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ def token_and_client_config_from(body)
test 'User shoud have the Last checkin filled' do
assert @resource.last_sign_in_at?
end

test 'user already confirmed' do
assert @resource.sign_in_count > 0 do
assert expiry == (Time.now + Time.now + 1.second).to_i
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The #assert method from minitest does not yield the block that is given here!
(See RDoc for Minitest::Assertions#assert)

To further demonstrate this, even with an exception raised from within the block, the test still passes!

test 'user already confirmed' do
  assert @resource.sign_in_count > 0 do
    assert expiry == (Time.now + Time.now + 1.second).to_i
    raise "Chunky Bacon!"
  end
end

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

n/m... I commented here waaay late, and this has been resolved by #1113.

end
end
end

describe 'failure' do
Expand Down