0.0
No commit activity in last 3 years
No release in over 3 years
Generate a temporary token of secret associated with ActiveRecord. it is stored in redis. You will be able to verify whether the token is correct.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.6
>= 0
>= 0

Runtime

 Project Readme

OnetimeToken

Generate a temporary token of secret associated with ActiveRecord. it is stored in redis. You will be able to verify whether the token is correct.

Installation

Add this line to your application's Gemfile:

gem 'onetime_token'

And then execute:

$ bundle

Or install it yourself as:

$ gem install onetime_token

Usage

OnetimeToken.configure do |config|
  config.redis = {
    url: 'redis://localhost:6379'
    deiver: :redis # e.g :hireds
    pool: {
      size: 1,
      timeout: 1,
    }
  }
end
class User < ActiveRecord::Base
  extend OnetimeToken

  has_onetime_token :email_confirmation, expires_in: 1.hours
end
user = User.find(1)
token = user.generate_email_confirmation_token
token.secret #=> 9eyZsVbrr4jLiVcERI7V6gmo

User.find_by_email_confirmation_token('9eyZsVbrr4jLiVcERI7V6gmo')
#=> #<User id: 1>

user = User.find(1)
user.verify_email_confirmation_token('9eyZsVbrr4jLiVcERI7V6gmo')
#=> true

User.find_by_email_confirmation_token('9eyZsVbrr4jLiVcERI7V6gmo')
#=> nil

Contributing

  1. Fork it ( https://github.com/f-kubotar/onetime_token/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request