Class: WebToken::WebtokenValidate

Inherits:
Object
  • Object
show all
Defined in:
lib/validation/token_validate.rb

Instance Method Summary collapse

Instance Method Details

#validate(token) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/validation/token_validate.rb', line 9

def validate( token )
  begin
    decoded_token = JWT.decode token, nil, false
  rescue JWT::ExpiredSignature
  rescue JWT::ImmatureSignature
  rescue JWT::DecodeError
    
  end
  if decoded_token.present?
    @data = decoded_token[0]['data'] 
    time = @data['time'].to_time+ 1.hour > Time.now 
    time ? @data : false
  else
    false
  end
end