The project is in a healthy, maintained state
This gem allows ActiveRecord models to generate, validate, and clear OTP codes with an expiration time.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0

Runtime

 Project Readme

Iprog OTP Code Generator

IPROG TECH

This gem is provided by IPROG TECH, an information technology company specializing in web development services using Ruby on Rails. IPROG TECH also offers free programming tutorials.

Providing Good Quality Web Services:

  • Startup
  • Maintenance
  • Upgrading & Conversion

Buy Me A Coffee

Installation

To install the gem, add this line to your application's Gemfile:

gem 'iprog_otp_generator'

And then execute:

$ bundle install

Or initialize and install

$ bundle add iprog_otp_generator

Or install it yourself as:

$ gem install iprog_otp_generator

Generate Migration File

$ rails generate iprog_otp_generator:install MODEL

Run migration

$ rails db:migrate

Initialization

app/models/user.rb

class User < ApplicationRecord
 enable_otp
end

Usage

Generate new OTP Code

user = User.take
user.generate_otp_code

or 

user.generate_otp_code(10)

default length parameter: 8


Validate OTP Code

user = User.take
code = 12351234

user.valid_otp_code?(code)

Reset OTP Code

user = User.take

user.clear_otp_code

Rspec Testing

Run Spec:

$ rspec spec/iprog_otp_generator_spec.rb

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/iprog21/iprog_otp_generator.

License

This gem is available as open source under the terms of the MIT License.

Code of Conduct

This project has adopted the Contributor Covenant Code of Conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to iprog.tech@gmail.com.