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

Length attribute not working #29

Closed parasjain27 closed 8 years ago

parasjain27 commented 8 years ago

Hi, I'm using this gem to generate OTP for User. As specified in the documentation I've provided the length attribute as 4. But still the OTP being generated is more than 4 characters. Below is my code snippet :

`class User < ActiveRecord::Base

Include default devise modules. Others available are:

:confirmable, :lockable, :timeoutable and :omniauthable

has_one :user_detail has_many :products has_one_time_password length: 4 before_create :generate_authentication_token!

devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable

accepts_nested_attributes_for :user_detail

def generate_authentication_token! begin self.auth_token = Devise.friendly_token puts self.auth_token end while self.class.exists?(auth_token: auth_token) end

end`

Can someone tell if possibly I'm going wrong somewhere?