Giter Site home page Giter Site logo

Comments (6)

robertomiranda avatar robertomiranda commented on June 15, 2024

@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.

shivanibhanwal avatar shivanibhanwal commented on June 15, 2024

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 -

self.otp_column_name = (options[:column_name] || "otp_secret_key").to_s
)

from active_model_otp.

shivanibhanwal avatar shivanibhanwal commented on June 15, 2024

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.

shivanibhanwal avatar shivanibhanwal commented on June 15, 2024

@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.

robertomiranda avatar robertomiranda commented on June 15, 2024

@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.

shivanibhanwal avatar shivanibhanwal commented on June 15, 2024

Sure

from active_model_otp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.