TagoLine 0.1.4.13 → 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: 0ad783064093fe816e6b946d865131820e8fffede606daca53905eebe89ab627
4
- data.tar.gz: 75bc783719c3e500b28d92d703938ac264a20d1ddb636f43482425287117f762
3
+ metadata.gz: b7388a0ce3ebc371e784733d9832a87190b925f93080b34d3de72958be15583e
4
+ data.tar.gz: be17bcd1fe1a385c404a5734f5cd3c5c32d5bc08e32edf2a1dd8acf603a8143f
5
5
  SHA512:
6
- metadata.gz: d373227e52a98509ef0a160e6655ac62a886fd2b1f5c4acc7f9f5b2fc3013a0454295ee8dbcb32126009ad5b6358d5135cb79144981d6ce2bacd7e2d435b8c5b
7
- data.tar.gz: 929ebc39b774cdbaf7effa44da1f180a1da563c0ea79fa354b192954c6536847ad09b5dc43924c6050b804616416c826b31e4e25c892fbb447b03f3032269673
6
+ metadata.gz: d5adbdd711037454c455edaf4b93bb28d72d9be994cec26334612e8431660085efe8fd60986fb13e22c3bf1c3e7494fa3270ed9294007e37f4fdcce3ee516742
7
+ data.tar.gz: dd963d37664c7ff004cc0e0709cfcef8d33f820824f7820de1812d33fa03c3027835a72955998ff2abecef479dfa9d65726b097e71d35824f0ccc92c54074f08
@@ -4,13 +4,46 @@ 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
 
26
+
27
+ def self.getUserInfo(controller, id_token)
28
+ uri = URI('https://api.line.me/oauth2/v2.1/verify')
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"]
33
+ JSON.parse(res.body)
34
+ end
35
+
11
36
  def self.getAccessToken(controller)
12
37
  uri = URI('https://api.line.me/oauth2/v2.1/token')
13
38
  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])
39
+ # ##セッションにアクセストークンを保存
40
+ # controller.session[:line_access_token] = JSON.parse(res.body)["access_token"]
41
+ # ##セッションにexpires_inを保存
42
+ # controller.session[:line_expires_in] = JSON.parse(res.body)["expires_in"]
43
+ # ##セッションにid_tokenを保存
44
+ # controller.session[:line_id_token] = JSON.parse(res.body)["id_token"]
45
+ # ##セッションにrefresh_tokenを保存
46
+ # controller.session[:line_refresh_token] = JSON.parse(res.body)["refresh_token"]
14
47
  JSON.parse(res.body)
15
48
  end
16
49
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TagoLine
4
- VERSION = "0.1.4.13"
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.13
4
+ version: 0.1.4.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - manatago