webtoken 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/token/web_token_gen.rb +25 -0
- data/lib/validation/token_validate.rb +27 -0
- metadata +3 -2
- data/lib/webtoken.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 95f7dae0b92a3d7cf94e7386e1800bcd23126f7d53e19b8a2f12b89e4bd71ac8
|
4
|
+
data.tar.gz: d8d06979f65766a5d125d13e6adcbb2f35c280766c399f4d51f9d132ab7c0fe3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b62ce7855707adc7600b14b2318c9a133300914b0bf10145f9dc4f4673e8771e05fb62f21133b0a7a8027bef7554ee451bbc76e01b89241d12ab64ca403429d
|
7
|
+
data.tar.gz: 6135787f77e28b7b02064090ea76e946ffb5ca3eba17c9a6537b9caa4c6433eaf7c5cec692c72d7846c8eca820ac74d592d966b09a215983c9724449fa50e45a
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'active_support'
|
2
|
+
require 'active_support/all'
|
3
|
+
require 'fnv'
|
4
|
+
require 'byebug'
|
5
|
+
require 'bcrypt'
|
6
|
+
require 'jwt'
|
7
|
+
require "date"
|
8
|
+
module WebToken
|
9
|
+
class MakeToken
|
10
|
+
def initialize( user_id )
|
11
|
+
data = {
|
12
|
+
userid: user_id,
|
13
|
+
date: Date.today.to_s,
|
14
|
+
time: Time.now
|
15
|
+
}
|
16
|
+
payload = {:data => data}
|
17
|
+
@token = JWT.encode payload, nil, 'none'
|
18
|
+
end
|
19
|
+
def web_token
|
20
|
+
@token
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'byebug'
|
2
|
+
require 'bcrypt'
|
3
|
+
require 'jwt'
|
4
|
+
require "date"
|
5
|
+
|
6
|
+
module WebToken
|
7
|
+
|
8
|
+
class WebtokenValidate
|
9
|
+
def validate( token )
|
10
|
+
begin
|
11
|
+
decoded_token = JWT.decode token, nil, false
|
12
|
+
rescue JWT::ExpiredSignature
|
13
|
+
rescue JWT::ImmatureSignature
|
14
|
+
rescue JWT::DecodeError
|
15
|
+
|
16
|
+
end
|
17
|
+
if decoded_token.present?
|
18
|
+
@data = decoded_token[0]['data']
|
19
|
+
time = @data['time'].to_time+ 1.hour > Time.now
|
20
|
+
time ? @data : false
|
21
|
+
else
|
22
|
+
false
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webtoken
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- velusamy Venkatraman
|
@@ -16,7 +16,8 @@ executables: []
|
|
16
16
|
extensions: []
|
17
17
|
extra_rdoc_files: []
|
18
18
|
files:
|
19
|
-
- lib/
|
19
|
+
- lib/token/web_token_gen.rb
|
20
|
+
- lib/validation/token_validate.rb
|
20
21
|
homepage: http://www.velusamy.tk
|
21
22
|
licenses:
|
22
23
|
- MIT
|