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

Added Counter based OTP (HOTP) #19

Merged
merged 18 commits into from Feb 26, 2015
Merged

Added Counter based OTP (HOTP) #19

merged 18 commits into from Feb 26, 2015

Conversation

ghost
Copy link

@ghost ghost commented Feb 12, 2015

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!


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

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]

@robertomiranda
Copy link
Member

@ResultsMayVary thanks I'll check it during the weekend, in the mean time could you apply the changes suggested by @houndci?

@ghost
Copy link
Author

ghost commented Feb 12, 2015

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?

@robertomiranda
Copy link
Member

sure, follow this ruby style guide https://github.com/bbatsov/ruby-style-guide#no-double-indent

@robertomiranda
Copy link
Member

btw, we should add that ruby style to the contributors guideline 😁

self.save if !self.new_record?
end

ROTP::HOTP.new(self.otp_column, digits: otp_digits).at(self.otp_counter)

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 {

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.

Copy link
Member

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

Choose a reason for hiding this comment

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

Redundant self detected.

@ghost
Copy link
Author

ghost commented Feb 12, 2015

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 false:FalseClass.

@robertomiranda
Copy link
Member

@ResultsMayVary sure, it doesn't matter

@robertomiranda
Copy link
Member

@ResultsMayVary all looks good for me, but I'd like to have another opinion @guilleiguaran could you check it?

robertomiranda added a commit that referenced this pull request Feb 26, 2015
@robertomiranda robertomiranda merged commit 0fa31d0 into heapsource:master Feb 26, 2015
@robertomiranda
Copy link
Member

@ResultsMayVary thanks 👍

@ghost
Copy link
Author

ghost commented Feb 26, 2015

@robertomiranda welcome! I did the changes for work so I always contribute back when I can.

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.

None yet

3 participants