TagoLine 0.1.4.14 → 0.1.4.15

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a76b81291fa6f7ae8dffefade3facc1e3470bd61190706bdf6d569bdc1c8af4d
4
- data.tar.gz: babc61f711f92ddc53e369c38d02c62e314a25c21bc08097220e30987f9fb952
3
+ metadata.gz: b7388a0ce3ebc371e784733d9832a87190b925f93080b34d3de72958be15583e
4
+ data.tar.gz: be17bcd1fe1a385c404a5734f5cd3c5c32d5bc08e32edf2a1dd8acf603a8143f
5
5
  SHA512:
6
- metadata.gz: c2ccf1d973a9546a4f8bc96839736276edb4bfb66f4c213a20c4365c4536a4229e216144872f00651281af7920b3f825e1620b355f54ae9d523e51f298e283dc
7
- data.tar.gz: 3b3853cc1d944b32aad97f2d0f61ab0e270c20b6619f7430d4e0e17b74b31a5970591f0defcf1aab0fbc5f32e6cdccb2528d0f5ee3395b0cfa8a5bbdd8926b78
6
+ metadata.gz: d5adbdd711037454c455edaf4b93bb28d72d9be994cec26334612e8431660085efe8fd60986fb13e22c3bf1c3e7494fa3270ed9294007e37f4fdcce3ee516742
7
+ data.tar.gz: dd963d37664c7ff004cc0e0709cfcef8d33f820824f7820de1812d33fa03c3027835a72955998ff2abecef479dfa9d65726b097e71d35824f0ccc92c54074f08
@@ -4,14 +4,32 @@ require 'json'
4
4
 
5
5
  module TagoLine
6
6
  class LoginAction
7
+
8
+ def self.loginProcess(controller)
9
+ if controller.session[:line_sub] && controller.session[:line_sub].length > 0
10
+ return true
11
+ end
12
+
13
+ if stateIsRight(controller)
14
+ res = getAccessToken(controller)
15
+ getUserInfo(controller, res["id_token"])
16
+ return true
17
+ else
18
+ return false
19
+ end
20
+ end
21
+
7
22
  def self.stateIsRight(controller)
8
23
  controller.session[:line_state] == controller.params[:state]
9
24
  end
10
25
 
11
26
 
12
- def self.getUserInfo(id_token)
27
+ def self.getUserInfo(controller, id_token)
13
28
  uri = URI('https://api.line.me/oauth2/v2.1/verify')
14
29
  res = Net::HTTP.post_form(uri,'id_token' => id_token , 'client_id' => ENV['LINE_CHANNEL_ID'])
30
+ controller.session[:line_sub] = JSON.parse(res.body)["sub"]
31
+ controller.session[:line_name]= JSON.parse(res.body)["name"]
32
+ controller.session[:line_picture]= JSON.parse(res.body)["picture"]
15
33
  JSON.parse(res.body)
16
34
  end
17
35
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TagoLine
4
- VERSION = "0.1.4.14"
4
+ VERSION = "0.1.4.15"
5
5
  CALLBACK_URL = ENV["LINE_CALLBACK_URL"]
6
6
  CHANNEL_ID = ENV["LINE_CHANNEL_ID"]
7
7
  CHANNEL_SECRET = ENV["LINE_CHANNEL_SECRET"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: TagoLine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4.14
4
+ version: 0.1.4.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - manatago