TagoLine 0.1.4.21 → 0.1.4.23

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: 995b43da10b26eec5b779afdae1c2b979050566ab391257a251e1edd8b16d6a4
4
- data.tar.gz: 4fe23a51867ae1ae395560679e932bd36bb8fd40d482dc190d0f2d3a937e3ac9
3
+ metadata.gz: 1829940877a5c688d57b31fe88314b22e04cf51cf61c0b172d891b22931ab18a
4
+ data.tar.gz: ba6d4e8d8864aef5b8767e8fb5c8d1442980b7d06b35cf1718b287cece99b573
5
5
  SHA512:
6
- metadata.gz: 89a5c97f0d95ae1be7bcfac13b0febc70b982e64f60d035d377327bf201e327e13fb76c75cd47962007bea4f5001276a782442f9a677911e2c8e338d42f5a7b8
7
- data.tar.gz: f82a67c0581bd38f24e8d250d1ef047aa140a863f6cea8dbb2b186c13678564c7e150c29003c2e8c839526ee54780c40174e82a5310be5e4b6213d6becc854f8
6
+ metadata.gz: 5d70a9a4a4265be75b1445aab9600c24ba425ff2870670430ba4e5c667ffcd5cb7feb180d360456e6b65f623487762415c2c2b8dc2c43fa93055f28ad4230e2c
7
+ data.tar.gz: fe33e9f8887be4aa85ed31f8888b33e585150bd0be401cef49d0c6488c1e5c589ca8629525767f3b0604089f63a75d7845348bdff25144fa7b45d35e77806f27
@@ -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,37 +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
- logger.debug('heeeeeeeeeeeeeeeeeeeeee')
49
- user.save!
50
-
51
- controller.session[:user_id] = user.id
52
- end
53
-
54
40
  JSON.parse(res.body)
55
41
  end
56
42
 
57
43
  def self.getAccessToken(controller)
58
44
  uri = URI('https://api.line.me/oauth2/v2.1/token')
59
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])
60
- # ##セッションにアクセストークンを保存
61
- # controller.session[:line_access_token] = JSON.parse(res.body)["access_token"]
62
- # ##セッションにexpires_inを保存
63
- # controller.session[:line_expires_in] = JSON.parse(res.body)["expires_in"]
64
- # ##セッションにid_tokenを保存
65
- # controller.session[:line_id_token] = JSON.parse(res.body)["id_token"]
66
- # ##セッションにrefresh_tokenを保存
67
- # controller.session[:line_refresh_token] = JSON.parse(res.body)["refresh_token"]
68
46
  JSON.parse(res.body)
69
47
  end
70
48
 
@@ -0,0 +1,38 @@
1
+ require 'action_view'
2
+
3
+ module TagoLine
4
+ class LogoutButton
5
+
6
+ def self.show(logout_path)
7
+ text = buttonStyle()
8
+ text+="<a class='line_logout_button' href='"+logout_path+"'>Log out</a>"
9
+ text.html_safe
10
+ end
11
+
12
+ def self.buttonStyle()
13
+ "<style>
14
+ .line_logout_button {
15
+ width: 142px;
16
+ height: 40px;
17
+ display: block;
18
+ background-color: #06C755;
19
+ color:white;
20
+ text-decoration: none;
21
+ text-align: center;
22
+ line-height: 40px;
23
+ vertical-align: middle;
24
+ font-weight: bold;
25
+ font-size: 20px;
26
+ border-radius: 5px;
27
+ opacity: 0.8;
28
+ }
29
+ .line_login_button:hover{
30
+ opacity: 0.9;
31
+ }
32
+ .line_login_button:active{
33
+ opacity: 1;
34
+ }
35
+ </style>"
36
+ end
37
+ end
38
+ end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TagoLine
4
- VERSION = "0.1.4.21"
4
+ VERSION = "0.1.4.23"
5
5
  CALLBACK_URL = ENV["LINE_CALLBACK_URL"]
6
6
  CHANNEL_ID = ENV["LINE_CHANNEL_ID"]
7
7
  CHANNEL_SECRET = ENV["LINE_CHANNEL_SECRET"]
data/lib/TagoLine.rb CHANGED
@@ -3,6 +3,7 @@
3
3
  require_relative "TagoLine/version"
4
4
  require_relative "TagoLine/LoginButton"
5
5
  require_relative "TagoLine/LoginAction"
6
+ require_relative "TagoLine/LogoutButton"
6
7
 
7
8
  module TagoLine
8
9
  class Error < StandardError; end
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.21
4
+ version: 0.1.4.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - manatago
@@ -27,6 +27,7 @@ files:
27
27
  - lib/TagoLine.rb
28
28
  - lib/TagoLine/LoginAction.rb
29
29
  - lib/TagoLine/LoginButton.rb
30
+ - lib/TagoLine/LogoutButton.rb
30
31
  - lib/TagoLine/version.rb
31
32
  - memo.txt
32
33
  - sig/TagoLine.rbs