omniauth-social 0.1.0 → 0.1.1
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 +4 -4
- data/Gemfile.lock +115 -0
- data/lib/omniauth/social/callbacks.rb +24 -0
- data/lib/omniauth/social/service.rb +63 -0
- data/lib/omniauth/social/version.rb +1 -1
- data/lib/omniauth/social.rb +1 -1
- data/omniauth-social-0.1.0.gem +0 -0
- data/omniauth-social.gemspec +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d9146d5e0bbbc5e9cfdb3a12ebd95ca24137e9d3
|
4
|
+
data.tar.gz: 21f4eeff444c26983870aa7fef3d2710d1b5f25f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84cd922f60733c367a51a1badb1874a3c0d15548ca74abfadeed6bec5ea068fd6c7e62e0064b96368c67c1f9fec99b106a38f47a564224f429f70c6d7d213cc0
|
7
|
+
data.tar.gz: 7243f8034a8b65149c160b2935a6c154fd0d55dc958af69db0d716bfeb87d9955a1b7c48a155393884cfe601b616640f2816aa822fba80149b2b76bc914d4538
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
omniauth-social (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
actionpack (5.2.3)
|
10
|
+
actionview (= 5.2.3)
|
11
|
+
activesupport (= 5.2.3)
|
12
|
+
rack (~> 2.0)
|
13
|
+
rack-test (>= 0.6.3)
|
14
|
+
rails-dom-testing (~> 2.0)
|
15
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
16
|
+
actionview (5.2.3)
|
17
|
+
activesupport (= 5.2.3)
|
18
|
+
builder (~> 3.1)
|
19
|
+
erubi (~> 1.4)
|
20
|
+
rails-dom-testing (~> 2.0)
|
21
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
22
|
+
activemodel (5.2.3)
|
23
|
+
activesupport (= 5.2.3)
|
24
|
+
activesupport (5.2.3)
|
25
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
26
|
+
i18n (>= 0.7, < 2)
|
27
|
+
minitest (~> 5.1)
|
28
|
+
tzinfo (~> 1.1)
|
29
|
+
bindex (0.8.1)
|
30
|
+
builder (3.2.3)
|
31
|
+
concurrent-ruby (1.1.5)
|
32
|
+
crass (1.0.4)
|
33
|
+
erubi (1.8.0)
|
34
|
+
faraday (0.15.4)
|
35
|
+
multipart-post (>= 1.2, < 3)
|
36
|
+
hashie (3.6.0)
|
37
|
+
i18n (1.6.0)
|
38
|
+
concurrent-ruby (~> 1.0)
|
39
|
+
jwt (1.5.6)
|
40
|
+
loofah (2.2.3)
|
41
|
+
crass (~> 1.0.2)
|
42
|
+
nokogiri (>= 1.5.9)
|
43
|
+
method_source (0.9.2)
|
44
|
+
mini_portile2 (2.4.0)
|
45
|
+
minitest (5.11.3)
|
46
|
+
multi_json (1.13.1)
|
47
|
+
multi_xml (0.6.0)
|
48
|
+
multipart-post (2.1.1)
|
49
|
+
nokogiri (1.10.4)
|
50
|
+
mini_portile2 (~> 2.4.0)
|
51
|
+
oauth (0.5.4)
|
52
|
+
oauth2 (1.4.1)
|
53
|
+
faraday (>= 0.8, < 0.16.0)
|
54
|
+
jwt (>= 1.0, < 3.0)
|
55
|
+
multi_json (~> 1.3)
|
56
|
+
multi_xml (~> 0.5)
|
57
|
+
rack (>= 1.2, < 3)
|
58
|
+
omniauth (1.9.0)
|
59
|
+
hashie (>= 3.4.6, < 3.7.0)
|
60
|
+
rack (>= 1.6.2, < 3)
|
61
|
+
omniauth-facebook (4.0.0)
|
62
|
+
omniauth-oauth2 (~> 1.2)
|
63
|
+
omniauth-google-oauth2 (0.4.1)
|
64
|
+
jwt (~> 1.5.2)
|
65
|
+
multi_json (~> 1.3)
|
66
|
+
omniauth (>= 1.1.1)
|
67
|
+
omniauth-oauth2 (>= 1.3.1)
|
68
|
+
omniauth-oauth (1.1.0)
|
69
|
+
oauth
|
70
|
+
omniauth (~> 1.0)
|
71
|
+
omniauth-oauth2 (1.6.0)
|
72
|
+
oauth2 (~> 1.1)
|
73
|
+
omniauth (~> 1.9)
|
74
|
+
omniauth-twitter (1.4.0)
|
75
|
+
omniauth-oauth (~> 1.1)
|
76
|
+
rack
|
77
|
+
rack (2.0.7)
|
78
|
+
rack-test (1.1.0)
|
79
|
+
rack (>= 1.0, < 3)
|
80
|
+
rails-dom-testing (2.0.3)
|
81
|
+
activesupport (>= 4.2.0)
|
82
|
+
nokogiri (>= 1.6)
|
83
|
+
rails-html-sanitizer (1.2.0)
|
84
|
+
loofah (~> 2.2, >= 2.2.2)
|
85
|
+
railties (5.2.3)
|
86
|
+
actionpack (= 5.2.3)
|
87
|
+
activesupport (= 5.2.3)
|
88
|
+
method_source
|
89
|
+
rake (>= 0.8.7)
|
90
|
+
thor (>= 0.19.0, < 2.0)
|
91
|
+
rake (10.5.0)
|
92
|
+
thor (0.20.3)
|
93
|
+
thread_safe (0.3.6)
|
94
|
+
tzinfo (1.2.5)
|
95
|
+
thread_safe (~> 0.1)
|
96
|
+
web-console (3.7.0)
|
97
|
+
actionview (>= 5.0)
|
98
|
+
activemodel (>= 5.0)
|
99
|
+
bindex (>= 0.4.0)
|
100
|
+
railties (>= 5.0)
|
101
|
+
|
102
|
+
PLATFORMS
|
103
|
+
ruby
|
104
|
+
|
105
|
+
DEPENDENCIES
|
106
|
+
bundler (~> 1.17)
|
107
|
+
omniauth-facebook (~> 4.0)
|
108
|
+
omniauth-google-oauth2 (~> 0.4.1)
|
109
|
+
omniauth-social!
|
110
|
+
omniauth-twitter (~> 1.2, >= 1.2.1)
|
111
|
+
rake (~> 10.0)
|
112
|
+
web-console (~> 3.3, >= 3.3.0)
|
113
|
+
|
114
|
+
BUNDLED WITH
|
115
|
+
1.17.3
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Omniauth
|
2
|
+
module Social::Callbacks
|
3
|
+
def google_oauth2
|
4
|
+
signin_and_redirect
|
5
|
+
end
|
6
|
+
|
7
|
+
def facebook
|
8
|
+
signin_and_redirect
|
9
|
+
end
|
10
|
+
|
11
|
+
def twitter
|
12
|
+
signin_and_redirect
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def signin_and_redirect
|
18
|
+
Social::Service.new(request, self).execute do |success, failure|
|
19
|
+
success.call { redirect_to root_path, notice: t('.notice') }
|
20
|
+
failure.call { redirect_to root_path, alert: t('.alert') }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module Omniauth
|
2
|
+
class Social::Service
|
3
|
+
attr_reader :auth, :controller
|
4
|
+
|
5
|
+
def initialize(auth, controller)
|
6
|
+
@auth = auth
|
7
|
+
@controller = controller
|
8
|
+
end
|
9
|
+
|
10
|
+
def execute
|
11
|
+
if signin_via_social
|
12
|
+
yield(PostService::Success, PostService::Failure)
|
13
|
+
else
|
14
|
+
yield(PostService::Failure, PostService::Success)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def signin_via_social
|
21
|
+
false unless @provider_data
|
22
|
+
|
23
|
+
account = AuthProvider.find_by(provider_params)&.user || User.find_by(email: provider_data.info.email)
|
24
|
+
|
25
|
+
if account
|
26
|
+
account.auth_providers.find_or_create_by(provider_params)
|
27
|
+
else
|
28
|
+
account = User.create!(user_params)
|
29
|
+
account.auth_providers.create(provider_params)
|
30
|
+
end
|
31
|
+
|
32
|
+
controller.sign_in(account)
|
33
|
+
controller.session[:user] = account.email
|
34
|
+
true
|
35
|
+
end
|
36
|
+
|
37
|
+
def provider_params
|
38
|
+
{ uid: provider_data.uid, provider: provider_data.provider }
|
39
|
+
end
|
40
|
+
|
41
|
+
def user_params
|
42
|
+
{ username: provider_data.info.name, email: provider_data.info.email, avatar: avatar(provider_data.info.image) }
|
43
|
+
end
|
44
|
+
|
45
|
+
def avatar(url)
|
46
|
+
file = Tempfile.new
|
47
|
+
file.binmode
|
48
|
+
file.write open(url).read
|
49
|
+
file.rewind
|
50
|
+
file
|
51
|
+
end
|
52
|
+
|
53
|
+
class Success
|
54
|
+
def self.call
|
55
|
+
yield
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
class Failure
|
60
|
+
def self.call; end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
data/lib/omniauth/social.rb
CHANGED
Binary file
|
data/omniauth-social.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
11
11
|
|
12
12
|
spec.summary = "this is the all module for wakuwaku appkication"
|
13
13
|
spec.description = "Write a longer description or delete this line."
|
14
|
-
spec.homepage = "https://github.com/
|
14
|
+
spec.homepage = "https://github.com/nguyenthanhcong101096/omniauth-social"
|
15
15
|
spec.license = "Apache-2.0"
|
16
16
|
|
17
17
|
# Specify which files should be added to the gem when it is released.
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-social
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nguyenthanhcong101096
|
@@ -68,15 +68,19 @@ files:
|
|
68
68
|
- ".gitignore"
|
69
69
|
- CODE_OF_CONDUCT.md
|
70
70
|
- Gemfile
|
71
|
+
- Gemfile.lock
|
71
72
|
- LICENSE.txt
|
72
73
|
- README.md
|
73
74
|
- Rakefile
|
74
75
|
- bin/console
|
75
76
|
- bin/setup
|
76
77
|
- lib/omniauth/social.rb
|
78
|
+
- lib/omniauth/social/callbacks.rb
|
79
|
+
- lib/omniauth/social/service.rb
|
77
80
|
- lib/omniauth/social/version.rb
|
81
|
+
- omniauth-social-0.1.0.gem
|
78
82
|
- omniauth-social.gemspec
|
79
|
-
homepage: https://github.com/
|
83
|
+
homepage: https://github.com/nguyenthanhcong101096/omniauth-social
|
80
84
|
licenses:
|
81
85
|
- Apache-2.0
|
82
86
|
metadata: {}
|