-
Notifications
You must be signed in to change notification settings - Fork 81
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
Added Counter based OTP (HOTP) #19
Conversation
Moved counter based OTP section to the bottom of Usage.
|
||
self.otp_column_name = (options[:column_name] || "otp_secret_key").to_s | ||
self.otp_digits = options[:length] || 6 | ||
|
||
self.otp_counter_based = (options[:counter_based] || false) | ||
self.otp_counter_column_name = (options[:counter_column_name] || "otp_counter").to_s |
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.
Line is too long. [92/80]
@ResultsMayVary thanks I'll check it during the weekend, in the mean time could you apply the changes suggested by @houndci? |
Of course. I was just reviewing them. Do you have a recommendation for the comments regarding lines being too long when it's coded the same as other lines? |
sure, follow this ruby style guide https://github.com/bbatsov/ruby-style-guide#no-double-indent |
btw, we should add that ruby style to the contributors guideline 😁 |
…tive_model_otp into add_counter_based_auth
self.save if !self.new_record? | ||
end | ||
|
||
ROTP::HOTP.new(self.otp_column, digits: otp_digits).at(self.otp_counter) |
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.
Line is too long. [82/80]
Redundant self
detected.
include InstanceMethodsOnActivation | ||
|
||
before_create { self.otp_regenerate_secret if !self.otp_column} | ||
before_create { |
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.
Avoid using {...} for multi-line blocks.
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.
right here would be better use, something like:
before do
end
…urn correctly if not accessed as self. Returns as false instead, perhaps a type issue?
before_create { self.otp_regenerate_secret if !self.otp_column} | ||
before_create do | ||
p "BEFORE CREATE" | ||
self.otp_regenerate_secret if !otp_column |
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.
Redundant self
detected.
I've fixed as many of the issues as I can. At this point what do I do about the redundant self issues? Not worry about them? If I don't access otp_counter as self it returns as |
@ResultsMayVary sure, it doesn't matter |
@ResultsMayVary all looks good for me, but I'd like to have another opinion @guilleiguaran could you check it? |
Added Counter based OTP (HOTP)
@ResultsMayVary thanks 👍 |
@robertomiranda welcome! I did the changes for work so I always contribute back when I can. |
For my project I required a counter based solution. I've expanded this to support the counter_based flag to allow HOTP. It's been tested in my environment and is working as expected. Readme has been updated with usage instructions as well as the version number increase to v1.2.0.
Let me know if this is all good and if you want me to perform any other changes before pulling. Thanks!