Comments (6)
@shivanibhanwal currently there's not way to specified a length for the code generated, but is something that we can add look https://github.com/mdp/rotp/blob/master/lib/rotp/otp.rb#L14 and would looks like:
class User < ActiveRecord::Base
has_one_time_password length: 4
end
about your second question, could you paste some code in order to repreduce the issue?. for me is working good
from active_model_otp.
Thank you @robertomiranda ! yes I think that would really help as most of the time people use 4 or 6 digit code for OTP
I am planning to make this change If I am done soon will send you a PR
(will make change here -
from active_model_otp.
About the other issue I see code is there in the gem files.
In my case I am not using same User table for the Token. I have separate Auth_tokens table for the token. Also the time drift which we needed that is like few minutes so I have passed drift value.
When I test my app for 1-2 hours after every 10-15 tries I get one OTP which is 5 digit.
And that cause a problem too. when I try to authenticate it it does not authenticate 5 digit otp.
user = self.auth_token
drift_time = Time.now + drift
new_otp = user.otp_code(drift_time)
and this time I got it 3 digit
UPDATE "auth_tokens" SET "otp_code" = 940, "otp_code_expiry" = '2014-08-21 17:11:50.147128'
Its happening verify frequently
from active_model_otp.
@robertomiranda About my second query, Issue was the DataType of the "otp_code" field. I was having it as integer and that was trimming these zero paddings.
I have implemented dynamic length for the otp_code. I have not sent a PR as I am yet to write tests for it.
However you can review my changes here https://github.com/shivanibhanwal/active_model_otp/tree/otp_generation_with_custom_length.
from active_model_otp.
@shivanibhanwal for sure, I'll take a look 👍, but please open the Pull request anyway this can help us to keep and track better the discussion.
from active_model_otp.
Sure
from active_model_otp.
Related Issues (20)
- Security vulnerability: backup codes are stored as plain text HOT 1
- Does this work with Sinatra HOT 1
- Release new version of the gem HOT 2
- last_otp_at misbehaving HOT 4
- "Preventing reuse of Time based OTP's" not working HOT 1
- undefined method `dark?' for #<RQRCode::QRCode:0x00005649dee622a0
- BCrypt::Errors::InvalidHash
- Preventing reuse of Time based OTP's README clarification?
- Allow rotp update to 6.3.0 to fix CVE-2024-28862 HOT 5
- undefined method `dark?' when creating QR-Code HOT 2
- Recovery Backup Codes HOT 2
- Enable/disable generate opt_secret_key when is an user is created HOT 2
- Plans to release a new version? HOT 5
- 2 bugs in provisioning_uri for HOTP tokens HOT 3
- Error: "NoMethodError (undefined method `before_create' for {}:Hash)" when used with devise on ruby 3.0.0 HOT 5
- Release of a version with Ruby 3 support HOT 2
- TOTP Server
- authenticate_otp (counter_based) now returns the corresponding otp_counter or nil instead of a boolean value HOT 1
- Token with empty string return true on authenticate_otp HOT 2
- one_time_backup_codes not working as expected HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from active_model_otp.