lita-gauth 0.1.0.4 → 0.1.0.5

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
- SHA256:
3
- metadata.gz: 41d158c285f8d693c0e0e5f32c5fdfd845380b5b669d869db9208b7c71ccf150
4
- data.tar.gz: 601e25c6651dfe49377d26e21bd8bd8a311403eb326343e1e3be89ac640f4c8d
2
+ SHA1:
3
+ metadata.gz: b1ecc93dee8ff3ba21a657062f2a9f510f7e565d
4
+ data.tar.gz: 9e44b5ecd20da03fd98cf7c92e3b5fa9d37fefea
5
5
  SHA512:
6
- metadata.gz: 4f86816edbaf22303c231eb806f837f0b37002051e1a6ac7956252d43e106780c6372ad777c8bd1ce260760b91cd87bf40eb20a5a063889756dcf30d5c1cf39b
7
- data.tar.gz: 569c3e5861cab69b98bb81a2ac4bf85410bb1261a6a19818159e2ba5157597e4414f3992ac2bcc3f19d1bc323752b8a182ca0de3b061e7cbf8f8f9443bb35de8
6
+ metadata.gz: 58c5451dcd615a0cc029b4948679840b396a8f56b51ab297ed5875564cd6b808abc9f1dda683ff90f6c124f397aa5fe8f687db421271bfd87b2c844c9d51db46
7
+ data.tar.gz: f2fef6411e1e5242435ada2ed912c79a748ccd97dce06a2a4edef83d53f6db87e032bf8273b02205d4c868583f9f6aaa1bb58d94cd7d6f153490968f06b37ffd
@@ -2,6 +2,9 @@ require 'google_auth_box'
2
2
  module Lita
3
3
  module Handlers
4
4
  class Gauth < Handler
5
+ on :connected, :log_conn
6
+ on :disconnected, :log_kick
7
+
5
8
  config :client_id_hash, required: true
6
9
 
7
10
  config :scopes, required: true
@@ -15,9 +18,29 @@ module Lita
15
18
  route(/^auth me$/, :request_auth, command: true)
16
19
 
17
20
  route(/^foo$/, :bar)
18
- http.get 'auth-redir', :auth_redir
19
- http.get 'auth-root/:id', :auth_root
20
- http.get 'auth-save/:user_id/', :auth_save
21
+ http.get '/auth-redir', :auth_redir
22
+ http.get '/auth-root/:id', :auth_root
23
+ http.get '/auth-save/:user_id/', :auth_save
24
+ http.get '/foo', :foo
25
+ http.get '/bar', :bar
26
+
27
+ def log_conn(payload)
28
+ p "it worked"
29
+ p payload
30
+ end
31
+
32
+ def log_kick(payload)
33
+ p 'sad panda'
34
+ p payload
35
+ end
36
+
37
+ def foo(req, resp)
38
+ resp.body << "hey there"
39
+ end
40
+
41
+ def bar(req, resp)
42
+ resp.body << "it worked"
43
+ end
21
44
 
22
45
  def get_user_creds(user_id)
23
46
  auth_client.get_creds user_id
@@ -30,6 +53,8 @@ module Lita
30
53
  url = auth_client.get_auth_url
31
54
  msg.reply "You are not authed"
32
55
  msg.reply "Please click the following link to register with the goog: #{url}"
56
+ else
57
+ msg.reply "You are ready to go!"
33
58
  end
34
59
  end
35
60
 
@@ -41,7 +66,7 @@ module Lita
41
66
  attrs = {
42
67
  storage_key: 'lita_gauth_user_id',
43
68
  code: req.params["code"],
44
- base_url: build_redir_url
69
+ base_url: "#{config.base_domain}/auth-save"
45
70
  }
46
71
  resp.body << render_template("auth_redir.html", attrs)
47
72
  end
@@ -49,7 +74,7 @@ module Lita
49
74
  def auth_root(req, resp)
50
75
  attrs = {
51
76
  "auth_redir_url": auth_client.get_auth_url,
52
- "user_id": JSON.parse(req.env["router.params"][:id]),
77
+ "user_id": req.env["router.params"][:id],
53
78
  "storage_key": "lita_gauth_user_id"
54
79
  }
55
80
 
@@ -57,13 +82,14 @@ module Lita
57
82
  end
58
83
 
59
84
  def auth_save(req, resp)
60
- user_id = JSON.parse(req.env['router.params'][:user_id])
85
+ user_id = req.env['router.params'][:user_id]
61
86
  save_creds user_id, req.params["code"]
62
87
  resp.write MultiJson.dump(msg: "ok")
63
88
  end
64
89
 
65
90
  def request_auth(msg)
66
- url = "#{config.base_domain}/auth-root"
91
+ id = msg.user.id
92
+ url = "#{config.base_domain}/auth-root/#{id}"
67
93
  msg.reply "Click the followin link to do the thing! #{url}"
68
94
  end
69
95
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "lita-gauth"
3
- spec.version = "0.1.0.4"
3
+ spec.version = "0.1.0.5"
4
4
  spec.authors = ["Axylos"]
5
5
  spec.email = ["robertdraketalley@gmail.com"]
6
6
  spec.description = "auth with google api"
@@ -12,7 +12,7 @@
12
12
  function showWinner() {
13
13
  const img_url = "https://t1.rbxcdn.com/2997bd147bbf3a8851fbf57339b0e177";
14
14
  const tmpl = `
15
- <div>
15
+ <div style="display: flex; justify-content: center">
16
16
  <img src="${img_url}" />
17
17
  </div>`;
18
18
 
@@ -25,7 +25,7 @@
25
25
  <div>
26
26
  <p>Sorry something went wrong!</p>
27
27
  <p>${JSON.stringify(err)}</p>
28
- <img src="${img_url}" />
28
+ <img src="${sad_img}" />
29
29
  </div>
30
30
  `;
31
31
 
@@ -39,11 +39,12 @@
39
39
  }, 3000);
40
40
  }
41
41
 
42
- const key = <%= @storage_key %>;
42
+ const key = "<%= @storage_key %>";
43
43
  const userId = localStorage.getItem(key);
44
- const code = <%= @code %>;
45
- const base_url = <%= @base_url %>;
46
- fetch("${base_url}/auth-save/${userId}/${code}")
44
+ const code = "<%= @code %>";
45
+ const base_url = "<%= @base_url %>";
46
+ const url = `${base_url}/${userId}/?code=${encodeURIComponent(code)}`;
47
+ fetch(url)
47
48
  .then(resp => {
48
49
  if (resp.ok) {
49
50
  return resp.json()
@@ -16,11 +16,13 @@
16
16
  allowFullScreen>
17
17
  </iframe>
18
18
  <script type="application/javascript">
19
- const user_id = <%= @user_id %>;
20
- const key = <%= @storage_key %>;
21
- localStorage.setItem(key, JSON.stringify(user_id))
22
- const auth_url = <%= @auth_redir_url %>
23
- window.location.href = auth_url
19
+ const user_id = '<%= @user_id %>';
20
+ const key = '<%= @storage_key %>';
21
+ localStorage.setItem(key, user_id);
22
+ const auth_url = '<%= @auth_redir_url %>';
23
+ window.setTimeout(() => {
24
+ window.location.href = auth_url;
25
+ }, 3000)
24
26
  </script>
25
27
  </body>
26
28
  </html>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-gauth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.4
4
+ version: 0.1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Axylos
@@ -193,7 +193,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
193
193
  version: '0'
194
194
  requirements: []
195
195
  rubyforge_project:
196
- rubygems_version: 2.7.6
196
+ rubygems_version: 2.6.14
197
197
  signing_key:
198
198
  specification_version: 4
199
199
  summary: client for google auth