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

Make confirmable not dependant on trackable #1064

Merged
merged 1 commit into from
Jan 12, 2018

Conversation

romankovt
Copy link
Contributor

Hello,

At the moment we have confirmable dependant on trackable because it excplicitly calls sign_in_count column while confirming email, but one should have an ability to use it without trackable module

@zachfeldman
Copy link
Contributor

@romankovt I think this change makes sense. If another maintainer approves it, we can merge it.

@zachfeldman zachfeldman self-requested a review January 12, 2018 15:13
Copy link
Owner

@lynndylanhurley lynndylanhurley left a comment

Choose a reason for hiding this comment

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

Thanks!

@zachfeldman zachfeldman merged commit d71c054 into lynndylanhurley:master Jan 12, 2018
@@ -10,7 +10,7 @@ def show
token_hash = BCrypt::Password.create(token)
expiry = (Time.now + @resource.token_lifespan).to_i

if @resource.sign_in_count > 0
if defined? @resource.sign_in_count && @resource.sign_in_count > 0

Choose a reason for hiding this comment

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

@zachfeldman, @lynndylanhurley Guys, there is a bug:
The parentheses are required here around the first @resource.sign_in_count, i.e.:

if defined?(@resource.sign_in_count) && @resource.sign_in_count > 0

Otherwise defined? is applied to the whole expression and returns string "expression", which results into assigning expiry to 1 second ahead of now even when sign_in_count equals 0.

Choose a reason for hiding this comment

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

There is a simple snippet to show the difference:

irb(main):001:0> defined? some_var
=> nil
irb(main):002:0> defined? some_var && some_var > 0
=> "expression"
irb(main):003:0> defined?(some_var) && some_var > 0
=> nil

Copy link
Contributor Author

@romankovt romankovt Jan 16, 2018

Choose a reason for hiding this comment

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

made a PR #1067 fixing this, thank you for the report

@zachfeldman
Copy link
Contributor

Thanks for your vigilance all!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants