Module: JumpIn::Tokenator
- Included in:
- PasswordReset
- Defined in:
- lib/jump_in/tokenator.rb
Constant Summary collapse
- DELIMITER =
'.'.freeze
Instance Method Summary collapse
Instance Method Details
#decode_and_split_token(token) ⇒ Object
12 13 14 15 16 |
# File 'lib/jump_in/tokenator.rb', line 12 def decode_and_split_token(token) Base64.urlsafe_decode64(token).split(DELIMITER) rescue raise JumpIn::InvalidTokenError end |
#decode_time(token) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/jump_in/tokenator.rb', line 18 def decode_time(token) token_time = decode_and_split_token(token)[1] Time.parse(token_time) rescue raise JumpIn::InvalidTokenError end |
#generate_token ⇒ Object
7 8 9 10 |
# File 'lib/jump_in/tokenator.rb', line 7 def generate_token Base64.urlsafe_encode64 [SecureRandom.hex(12), Time.now.xmlschema] .join(DELIMITER) end |