Class: OmniAuth::Whichsignupapi::TokenTools
- Inherits:
-
Object
- Object
- OmniAuth::Whichsignupapi::TokenTools
- Defined in:
- lib/omniauth/whichsignupapi/token_tools.rb
Instance Method Summary collapse
- #decode_token(token) ⇒ Object
- #generate_token(token_data) ⇒ Object
-
#initialize(password) ⇒ TokenTools
constructor
A new instance of TokenTools.
Constructor Details
#initialize(password) ⇒ TokenTools
Returns a new instance of TokenTools.
4 5 6 |
# File 'lib/omniauth/whichsignupapi/token_tools.rb', line 4 def initialize(password) @password = password end |
Instance Method Details
#decode_token(token) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/omniauth/whichsignupapi/token_tools.rb', line 14 def decode_token(token) dec = get_cipher.decrypt(token) parts = dec.split('|') { time: parts.pop, token_data: parts.join('|') } end |
#generate_token(token_data) ⇒ Object
8 9 10 11 12 |
# File 'lib/omniauth/whichsignupapi/token_tools.rb', line 8 def generate_token(token_data) raise 'token generations not possible is token is blank' if token_data.blank? t = "#{token_data}|#{Time.now.to_i}" get_cipher.encrypt(t) end |