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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 277ca5f10f90d6717f0600f6d6e87dcff55e1e3bd476036ebb02901f0eb7f7c2
4
- data.tar.gz: cd512721127ba751b819009443cb4a5509d89487bc40a5b0160cbb95c7aad88f
3
+ metadata.gz: 3df9e71ad211f8f08815b847d4d2e07b0ee57a378938cc49507c4ff4b43d05ee
4
+ data.tar.gz: 5d6bf280916969f560697ebdcc7b6209ca600d304d3ed2318b4dfa472dfef4ac
5
5
  SHA512:
6
- metadata.gz: 42e24e42a236c6e1ddcb1ce5a9d2291fa7f5fc902b7f47b81cc06e2f620197917f6b81a2ca075544b6eb9942b77506268a856276feb3ae9e960fba09f15bf0a6
7
- data.tar.gz: 7685831c0641975c8a0e08da9cda7ff816ce56641dc395c94e61f67b7a0eab3c181b433702a7f39f4ca0c6aa864c658425928ae303be0dfe898ff9b6a7d5333f
6
+ metadata.gz: 5df5f6b0a2eb50f176584a7bcd3ecdd3baaea52fba91b6eb0d1d20bd450e5663cf7cf819d44ee04d4b2eb554fc22bfe1c461c3045d5d2021c4807c10a7a53bcb
7
+ data.tar.gz: d9b816dd959eabec310ad8c4b7d6afc8d4bdbc26f428bc0a3fe0ef78a01d655ab57b2ea7ca292dc1eeaf8d57edfec37f19564344230b8189c9926043a2e2a21e
@@ -5,24 +5,21 @@ require 'json'
5
5
  module TagoLine
6
6
  class LoginAction
7
7
 
8
- def self.logoutProcess(controller,user_class=nil)
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,user_class=nil)
19
- if controller.session[:line_sub] && controller.session[:line_sub].length > 0
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"], user_class)
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, user_class=nil)
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
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TagoLine
4
- VERSION = "0.1.4.20"
4
+ VERSION = "0.1.4.22"
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.20
4
+ version: 0.1.4.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - manatago