social_login 0.0.4 → 1.0.1beta
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.
- data/lib/generators/{.DS_Store → social_login/.DS_Store} +0 -0
- data/lib/generators/social_login/create_authentication_generator.rb +29 -0
- data/lib/generators/social_login/create_authentication_generator.rb~ +45 -0
- data/lib/generators/social_login/install_generator.rb +53 -0
- data/lib/generators/social_login/install_generator.rb~ +30 -0
- data/lib/generators/templates/#authentications.html.erb# +3 -0
- data/lib/generators/templates/create_authentication.rb +11 -0
- data/lib/generators/templates/images/facebook_64.png +0 -0
- data/lib/generators/templates/images/linkedin_64.png +0 -0
- data/lib/generators/templates/images/twitter_64.png +0 -0
- data/lib/generators/templates/omniauth.rb +3 -3
- data/lib/social_login/.DS_Store +0 -0
- data/lib/social_login/version.rb +1 -1
- data/lib/social_login.rb +2 -6
- data/social_login.gemspec +1 -1
- metadata +17 -10
- data/lib/generators/omniauth_generator.rb +0 -11
- data/lib/generators/omniauth_generator.rb~ +0 -6
- data/lib/social_login/translator.rb +0 -14
|
Binary file
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require "rails/generators"
|
|
2
|
+
|
|
3
|
+
module SocialLogin
|
|
4
|
+
class CreateAuthenticationGenerator < Rails::Generators::Base
|
|
5
|
+
source_root File.expand_path("../../templates", __FILE__)
|
|
6
|
+
|
|
7
|
+
desc "Creates the file that configure the authentication on the creation."
|
|
8
|
+
|
|
9
|
+
def create_omniauth_file
|
|
10
|
+
template 'create_authentication.rb', 'public/create_authentication.rb'
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def copy_auth_images
|
|
14
|
+
template 'images/twitter_64.png', 'app/assets/images/twitter_64.png'
|
|
15
|
+
template 'images/facebook_64.png', 'app/assets/images/facebook_64.png'
|
|
16
|
+
template 'images/linkedin_64.png', 'app/assets/images/linkedin_64.png'
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def create_authentication_partials
|
|
20
|
+
|
|
21
|
+
auth = File.open("public/_auth.html.erb", "w")
|
|
22
|
+
auth << "<%= link_to(image_tag('twitter_64.png', :size => '64x64', :alt => 'Twitter'), '/auth/twitter') %>\n"
|
|
23
|
+
auth << "<%= link_to(image_tag('facebook_64.png', :size => '64x64', :alt => 'Facebook'), '/auth/facebook') %>\n"
|
|
24
|
+
auth << "<%= link_to(image_tag('linkedin_64.png', :size => '64x64', :alt => 'LinkedIn'), '/auth/linkedin') %>\n"
|
|
25
|
+
auth.close
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
require "rails/generators"
|
|
2
|
+
require "fileutils"
|
|
3
|
+
|
|
4
|
+
module SocialLogin
|
|
5
|
+
class InstallGenerator < Rails::Generators::Base
|
|
6
|
+
source_root File.expand_path("../../templates", __FILE__)
|
|
7
|
+
|
|
8
|
+
desc "Creates the omniauth file to configure the authentication."
|
|
9
|
+
|
|
10
|
+
def create_omniauth_file
|
|
11
|
+
template 'create_authentication.rb', 'public/create_authentication.rb'
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def create_routes
|
|
15
|
+
tempfile = File.open("config/routes.tmp", 'w')
|
|
16
|
+
f = File.new("config/routes.rb")
|
|
17
|
+
f.each do |line|
|
|
18
|
+
tempfile << line
|
|
19
|
+
if line.include?("Application.routes.draw")
|
|
20
|
+
tempfile << " match '/auth/:provider/callback' => # Create controller action."
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
f.close
|
|
24
|
+
tempfile.close
|
|
25
|
+
FileUtils.mv("config/routes.tmp", "config/routes.rb")
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def create_dependencies
|
|
29
|
+
tempfile = File.open("Gemfile.tmp", 'w')
|
|
30
|
+
f = File.new("Gemfile")
|
|
31
|
+
f.each do |line|
|
|
32
|
+
tempfile << line
|
|
33
|
+
if line.include?("gem 'rails'")
|
|
34
|
+
tempfile << "gem 'omniauth-twitter'\n"
|
|
35
|
+
tempfile << "gem 'omniauth-facebook'\n"
|
|
36
|
+
tempfile << "gem 'omniauth-linkedin'\n"
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
f.close
|
|
40
|
+
tempfile.close
|
|
41
|
+
FileUtils.mv("Gemfile.tmp", "Gemfile")
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
require "rails/generators"
|
|
2
|
+
require "fileutils"
|
|
3
|
+
|
|
4
|
+
module SocialLogin
|
|
5
|
+
class InstallGenerator < Rails::Generators::Base
|
|
6
|
+
source_root File.expand_path("../../templates", __FILE__)
|
|
7
|
+
|
|
8
|
+
desc "Initial configuration."
|
|
9
|
+
|
|
10
|
+
def create_omniauth_file
|
|
11
|
+
template 'omniauth.rb', 'config/initializers/omniauth.rb'
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def create_routes
|
|
15
|
+
tempfile = File.open("config/routes.tmp", 'w')
|
|
16
|
+
f = File.new("config/routes.rb")
|
|
17
|
+
f.each do |line|
|
|
18
|
+
tempfile << line
|
|
19
|
+
if line.include?("Application.routes.draw")
|
|
20
|
+
tempfile << "#This is a route example, to make it works, you must create an authnetications controller.\n"
|
|
21
|
+
tempfile << " #match '/auth/:provider/callback' => 'authentications#create'\n\n"
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
f.close
|
|
25
|
+
tempfile.close
|
|
26
|
+
FileUtils.mv("config/routes.tmp", "config/routes.rb")
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def create_dependencies
|
|
30
|
+
tempfile = File.open("Gemfile.tmp", 'w')
|
|
31
|
+
f = File.new("Gemfile")
|
|
32
|
+
wrote = false
|
|
33
|
+
f.each do |line|
|
|
34
|
+
tempfile << line
|
|
35
|
+
if line.include?("gem 'rails'")
|
|
36
|
+
unless wrote
|
|
37
|
+
tempfile << "gem 'omniauth-twitter'\n"
|
|
38
|
+
tempfile << "gem 'omniauth-facebook'\n"
|
|
39
|
+
tempfile << "gem 'omniauth-linkedin'\n"
|
|
40
|
+
wrote = true
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
f.close
|
|
45
|
+
tempfile.close
|
|
46
|
+
FileUtils.mv("Gemfile.tmp", "Gemfile")
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
puts "Now you have to create the authentication model."
|
|
50
|
+
puts "This is an example:"
|
|
51
|
+
puts "rails g scaffold authentication user_id:integer provider:string uid:string"
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require "rails/generators"
|
|
2
|
+
require "fileutils"
|
|
3
|
+
|
|
4
|
+
module SocialLogin
|
|
5
|
+
class OmniauthGenerator < Rails::Generators::Base
|
|
6
|
+
source_root File.expand_path("../../templates", __FILE__)
|
|
7
|
+
|
|
8
|
+
desc "Creates the omniauth file to configure the authentication."
|
|
9
|
+
|
|
10
|
+
#root = File.expand_path("../templates/", __FILE__)
|
|
11
|
+
#puts root
|
|
12
|
+
def create_omniauth_file
|
|
13
|
+
template 'omniauth.rb', 'config/initializers/omniauth.rb'
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def create_routes
|
|
17
|
+
tempfile = File.open("config/routes.tmp", 'w')
|
|
18
|
+
f = File.new("config/routes.rb")
|
|
19
|
+
f.each do |line|
|
|
20
|
+
tempfile << line
|
|
21
|
+
if line.include?("Application.routes.draw")
|
|
22
|
+
tempfile << " match '/auth/:provider/callback' => # Create controller action."
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
f.close
|
|
26
|
+
tempfile.close
|
|
27
|
+
FileUtils.mv("config/routes.tmp", "config/routes.rb")
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
<%= link_to(image_tag("twitter_64.png", :size => "64x64", :alt => "Twitter"), "/auth/twitter") %>
|
|
2
|
+
<%= link_to(image_tag("facebook_64.png", :size => "64x64", :alt => "Facebook"), "/auth/facebook") %>
|
|
3
|
+
<%= link_to(image_tag("linkedin_64.png", :size => "64x64", :alt => "LinkedIn"), "/auth/linkedin") %>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
def create
|
|
2
|
+
omniauth = request.env['omniauth.auth']
|
|
3
|
+
if current_user
|
|
4
|
+
current_user.authentications.find_or_create_by_provider_and_uid(omniauth['provider'], omniauth['uid'])
|
|
5
|
+
flash[:notice] = "The authentication was successfull."
|
|
6
|
+
redirect_to authentications_url
|
|
7
|
+
else
|
|
8
|
+
flash[:error] = "You have to be logged in to authenticate."
|
|
9
|
+
redirect_to root_url
|
|
10
|
+
end
|
|
11
|
+
end
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Rails.application.config.middleware.use OmniAuth::Builder do
|
|
2
|
-
provider :twitter, '
|
|
3
|
-
provider :facebook, '
|
|
4
|
-
provider :linkedin, '
|
|
2
|
+
provider :twitter, 'KEY', 'SECRET'
|
|
3
|
+
provider :facebook, 'KEY', 'SECRET', { :scope => 'email, offline_access, user_photos, publish_stream', :client_options => { :ssl => { :ca_path => "/etc/ssl/certs" } } }
|
|
4
|
+
provider :linkedin, 'KEY', 'SECRET'
|
|
5
5
|
end
|
|
Binary file
|
data/lib/social_login/version.rb
CHANGED
data/lib/social_login.rb
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
+
require "rails"
|
|
1
2
|
require "social_login/version"
|
|
2
|
-
require "social_login/translator"
|
|
3
|
-
require "generators/omniauth_generator"
|
|
4
3
|
|
|
5
4
|
module SocialLogin
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
translator = Translator.new(language)
|
|
9
|
-
translator.hi
|
|
10
|
-
end
|
|
6
|
+
|
|
11
7
|
end
|
data/social_login.gemspec
CHANGED
|
@@ -8,7 +8,7 @@ Gem::Specification.new do |gem|
|
|
|
8
8
|
gem.summary = %q{This gem help you to login to different social networks (Academic project).}
|
|
9
9
|
gem.homepage = "http://github.com/dagosi89/social_login"
|
|
10
10
|
|
|
11
|
-
gem.add_development_dependency "
|
|
11
|
+
gem.add_development_dependency "rspec"
|
|
12
12
|
gem.files = `git ls-files`.split($\)
|
|
13
13
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
|
14
14
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
metadata
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: social_login
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
5
|
-
prerelease:
|
|
4
|
+
version: 1.0.1beta
|
|
5
|
+
prerelease: 5
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
8
8
|
- Daniel Gomez Sierra
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2012-06-
|
|
12
|
+
date: 2012-06-03 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
|
-
name:
|
|
15
|
+
name: rspec
|
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
|
17
17
|
none: false
|
|
18
18
|
requirements:
|
|
@@ -43,12 +43,19 @@ files:
|
|
|
43
43
|
- Rakefile
|
|
44
44
|
- bin/hola
|
|
45
45
|
- lib/.DS_Store
|
|
46
|
-
- lib/generators/.DS_Store
|
|
47
|
-
- lib/generators/
|
|
48
|
-
- lib/generators/
|
|
46
|
+
- lib/generators/social_login/.DS_Store
|
|
47
|
+
- lib/generators/social_login/create_authentication_generator.rb
|
|
48
|
+
- lib/generators/social_login/create_authentication_generator.rb~
|
|
49
|
+
- lib/generators/social_login/install_generator.rb
|
|
50
|
+
- lib/generators/social_login/install_generator.rb~
|
|
51
|
+
- lib/generators/templates/#authentications.html.erb#
|
|
52
|
+
- lib/generators/templates/create_authentication.rb
|
|
53
|
+
- lib/generators/templates/images/facebook_64.png
|
|
54
|
+
- lib/generators/templates/images/linkedin_64.png
|
|
55
|
+
- lib/generators/templates/images/twitter_64.png
|
|
49
56
|
- lib/generators/templates/omniauth.rb
|
|
50
57
|
- lib/social_login.rb
|
|
51
|
-
- lib/social_login
|
|
58
|
+
- lib/social_login/.DS_Store
|
|
52
59
|
- lib/social_login/version.rb
|
|
53
60
|
- social_login.gemspec
|
|
54
61
|
homepage: http://github.com/dagosi89/social_login
|
|
@@ -66,9 +73,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
66
73
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
67
74
|
none: false
|
|
68
75
|
requirements:
|
|
69
|
-
- - ! '
|
|
76
|
+
- - ! '>'
|
|
70
77
|
- !ruby/object:Gem::Version
|
|
71
|
-
version:
|
|
78
|
+
version: 1.3.1
|
|
72
79
|
requirements: []
|
|
73
80
|
rubyforge_project:
|
|
74
81
|
rubygems_version: 1.8.24
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
require 'ftools'
|
|
2
|
-
module SocialLogin
|
|
3
|
-
module Generators
|
|
4
|
-
class OmniauthGenerator < Rails::Generators::Base
|
|
5
|
-
desc "Creates the omniauth file to configure the authentication."
|
|
6
|
-
def initialize()
|
|
7
|
-
File.copy("templates/omniauth.rb", "config/initializers/omniauth.rb")
|
|
8
|
-
end
|
|
9
|
-
end
|
|
10
|
-
end
|
|
11
|
-
endxs
|