verse-ruby 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/verse/controller.rb +20 -18
- data/lib/verse/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 255311fb8cc0e58f96a8183ba7f47866e6ec352c
|
4
|
+
data.tar.gz: 478a3c0fc53eaa66d71af0c710dd8e8329c643f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8c2a99b5871386dc39cb4fa0c57bff5dafebc93d37ed2b5534319ba0ac910c4834c1d544a1053aa1af8f2c919f553e52c3346e8ae7606e86885ff229303fb04
|
7
|
+
data.tar.gz: 8052ecb87d52a96d39d4ff078e443c1307b3208150d65f7dbe4b09d1206d1f1f8c9e152d4e3d2afc303445ee304dce59f20c337d41af0747148ce12157131574
|
data/lib/verse/controller.rb
CHANGED
@@ -1,27 +1,29 @@
|
|
1
1
|
require 'active_support'
|
2
2
|
require 'jwt'
|
3
3
|
|
4
|
-
module Verse
|
5
|
-
|
4
|
+
module Verse
|
5
|
+
module Controller
|
6
|
+
extend ActiveSupport::Concern
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
included do
|
9
|
+
before_action :set_user_token
|
10
|
+
helper_method :current_user
|
11
|
+
end
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
13
|
+
def current_user
|
14
|
+
if Verse.user_token
|
15
|
+
data = JWT.decode(Verse.user_token, nil, false)[0]['data']
|
16
|
+
Verse::Auth::Core::User.new(
|
17
|
+
id: data['user_id'],
|
18
|
+
display_name: data['display_name'],
|
19
|
+
email: data['email'],
|
20
|
+
username: data['username']
|
21
|
+
)
|
22
|
+
end
|
21
23
|
end
|
22
|
-
end
|
23
24
|
|
24
|
-
|
25
|
-
|
25
|
+
def set_user_token
|
26
|
+
Verse.user_token = cookies[:user_token]
|
27
|
+
end
|
26
28
|
end
|
27
29
|
end
|
data/lib/verse/version.rb
CHANGED