heapsource / active_model_otp

Adds methods to set and authenticate against one time passwords (Two-Factor Authentication). Inspired in AM::SecurePassword
MIT License
773 stars 81 forks source link

Generate otp_secret_key for some specific users not for all users. #35

Closed MohdAnas closed 7 years ago

MohdAnas commented 7 years ago

Is there any possibility to generate otp_secret_key only for some specific users not for all users?

robertomiranda commented 7 years ago

@MohdAnas sorry for the late response. Unfortunately Active Model OTP doesn't provide an api that provide such option. But you can override this Instance method on your model Model#otp_regenerate_secret

e.g

class User
  def otp_regenerate_secret
    if my_condition
       self.otp_column = ROTP::Base32.random_base32
    end
  end
end
MohdAnas commented 7 years ago

Can we generate the Key to setup google authenticator instead of scanning the QR code?

ghost commented 7 years ago

The result of ROTP::Base32.random_base32 can directly be used to setup Google Authenticator.

MohdAnas commented 7 years ago

I already did that. Thanks for you help.