TagoLine 0.1.4.20 → 0.1.4.22
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/TagoLine/LoginAction.rb +5 -25
- data/lib/TagoLine/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3df9e71ad211f8f08815b847d4d2e07b0ee57a378938cc49507c4ff4b43d05ee
|
4
|
+
data.tar.gz: 5d6bf280916969f560697ebdcc7b6209ca600d304d3ed2318b4dfa472dfef4ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5df5f6b0a2eb50f176584a7bcd3ecdd3baaea52fba91b6eb0d1d20bd450e5663cf7cf819d44ee04d4b2eb554fc22bfe1c461c3045d5d2021c4807c10a7a53bcb
|
7
|
+
data.tar.gz: d9b816dd959eabec310ad8c4b7d6afc8d4bdbc26f428bc0a3fe0ef78a01d655ab57b2ea7ca292dc1eeaf8d57edfec37f19564344230b8189c9926043a2e2a21e
|
data/lib/TagoLine/LoginAction.rb
CHANGED
@@ -5,24 +5,21 @@ require 'json'
|
|
5
5
|
module TagoLine
|
6
6
|
class LoginAction
|
7
7
|
|
8
|
-
def self.logoutProcess(controller
|
8
|
+
def self.logoutProcess(controller)
|
9
9
|
controller.session.delete(:line_sub)
|
10
10
|
controller.session.delete(:line_name)
|
11
11
|
controller.session.delete(:line_picture)
|
12
12
|
controller.session.delete(:line_state)
|
13
|
-
if(user_class != nil)
|
14
|
-
controller.session.delete(:user_id)
|
15
|
-
end
|
16
13
|
end
|
17
14
|
|
18
|
-
def self.loginProcess(controller
|
19
|
-
if controller.session[:line_sub] && controller.session[:line_sub].length >
|
15
|
+
def self.loginProcess(controller)
|
16
|
+
if controller.session[:line_sub] && controller.session[:line_sub].length > 10
|
20
17
|
return true
|
21
18
|
end
|
22
19
|
|
23
20
|
if stateIsRight(controller)
|
24
21
|
res = getAccessToken(controller)
|
25
|
-
getUserInfo(controller, res["id_token"]
|
22
|
+
getUserInfo(controller, res["id_token"])
|
26
23
|
return true
|
27
24
|
else
|
28
25
|
return false
|
@@ -34,35 +31,18 @@ module TagoLine
|
|
34
31
|
end
|
35
32
|
|
36
33
|
|
37
|
-
def self.getUserInfo(controller, id_token
|
34
|
+
def self.getUserInfo(controller, id_token)
|
38
35
|
uri = URI('https://api.line.me/oauth2/v2.1/verify')
|
39
36
|
res = Net::HTTP.post_form(uri,'id_token' => id_token , 'client_id' => ENV['LINE_CHANNEL_ID'])
|
40
37
|
controller.session[:line_sub] = JSON.parse(res.body)["sub"]
|
41
38
|
controller.session[:line_name]= JSON.parse(res.body)["name"]
|
42
39
|
controller.session[:line_picture]= JSON.parse(res.body)["picture"]
|
43
|
-
|
44
|
-
if user_class != nil
|
45
|
-
user = user_class.find_or_initialize_by(line_sub: JSON.parse(res.body)["sub"])
|
46
|
-
user.line_name = JSON.parse(res.body)["name"]
|
47
|
-
user.line_picture = JSON.parse(res.body)["picture"]
|
48
|
-
user.save
|
49
|
-
controller.session[:user_id] = user.id
|
50
|
-
end
|
51
|
-
|
52
40
|
JSON.parse(res.body)
|
53
41
|
end
|
54
42
|
|
55
43
|
def self.getAccessToken(controller)
|
56
44
|
uri = URI('https://api.line.me/oauth2/v2.1/token')
|
57
45
|
res = Net::HTTP.post_form(uri, 'grant_type' => 'authorization_code', 'redirect_uri' => ENV['LINE_CALLBACK_URL'], 'client_id' => ENV['LINE_CHANNEL_ID'], 'client_secret' => ENV['LINE_CHANNEL_SECRET'], 'code' => controller.params[:code])
|
58
|
-
# ##セッションにアクセストークンを保存
|
59
|
-
# controller.session[:line_access_token] = JSON.parse(res.body)["access_token"]
|
60
|
-
# ##セッションにexpires_inを保存
|
61
|
-
# controller.session[:line_expires_in] = JSON.parse(res.body)["expires_in"]
|
62
|
-
# ##セッションにid_tokenを保存
|
63
|
-
# controller.session[:line_id_token] = JSON.parse(res.body)["id_token"]
|
64
|
-
# ##セッションにrefresh_tokenを保存
|
65
|
-
# controller.session[:line_refresh_token] = JSON.parse(res.body)["refresh_token"]
|
66
46
|
JSON.parse(res.body)
|
67
47
|
end
|
68
48
|
|
data/lib/TagoLine/version.rb
CHANGED