-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Conversation
@romankovt I think this change makes sense. If another maintainer approves it, we can merge it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
@@ -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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
Thanks for your vigilance all! |
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