socials 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +24 -0
- data/Rakefile +1 -2
- data/lib/generators/socials/install_generator.rb +46 -0
- data/lib/generators/templates/config/social_keys.yml +31 -0
- data/lib/generators/templates/controllers/omniauth_callbacks_controller.rb +28 -0
- data/lib/socials/connector.rb +8 -1
- data/lib/socials/facebook.rb +8 -2
- data/lib/socials/google_plus.rb +1 -1
- data/lib/socials/twitter.rb +1 -1
- data/lib/socials/version.rb +2 -2
- data/socials.gemspec +1 -1
- metadata +11 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 00476d621a6b4cdef34730db1490849db6edce98
|
4
|
+
data.tar.gz: f33ddb7a50cf00d7c625eabcefc16cc590c316c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34e4d17944fcbd6e1c665712819ad14db1a4bdaa4e21780e2ce90e463c0457fa6755f5e406531777af249b97a06859fcd4baea2fb2ca20384b40e4a29d758010
|
7
|
+
data.tar.gz: 337983c6b9561f545a715930a3d98cdbba6023708a1a5213fc889f887d0d32466ae799cab6993d82ebe212fa4e8ea81a207767bf69bfc6766ab072bcebab358a
|
data/Gemfile
CHANGED
@@ -4,3 +4,27 @@ source 'https://rubygems.org'
|
|
4
4
|
|
5
5
|
# Specify your gem's dependencies in socials.gemspec
|
6
6
|
gemspec
|
7
|
+
|
8
|
+
# Gems for the social LogIn based on:
|
9
|
+
# https://github.com/mohitjain/social-login-in-rails
|
10
|
+
|
11
|
+
# LogIn
|
12
|
+
gem 'devise'
|
13
|
+
|
14
|
+
# Helpers
|
15
|
+
gem 'json'
|
16
|
+
gem 'airbrake'
|
17
|
+
|
18
|
+
# OAuth
|
19
|
+
gem 'koala'
|
20
|
+
gem 'omniauth'
|
21
|
+
gem 'omniauth-oauth2'
|
22
|
+
gem 'omniauth-facebook'
|
23
|
+
gem 'omniauth-github'
|
24
|
+
gem 'omniauth-google-oauth2'
|
25
|
+
gem 'omniauth-linkedin'
|
26
|
+
gem 'omniauth-twitter'
|
27
|
+
|
28
|
+
# Social
|
29
|
+
gem 'twitter'
|
30
|
+
gem 'linkedin'
|
data/Rakefile
CHANGED
@@ -1,2 +1 @@
|
|
1
|
-
require "bundler/gem_tasks"
|
2
|
-
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'colorize'
|
2
|
+
module Socials
|
3
|
+
module Generators
|
4
|
+
class InstallGenerator < Rails::Generators::Base
|
5
|
+
source_root File.expand_path("../../templates", __FILE__)
|
6
|
+
|
7
|
+
desc "It automatically create it SOCIALS initializer on the rails app"
|
8
|
+
def copy_initializer
|
9
|
+
add_templates
|
10
|
+
update_files
|
11
|
+
end
|
12
|
+
|
13
|
+
# Add the files on the templates folder to the Rails App
|
14
|
+
def add_templates
|
15
|
+
# Add the config YML (social_credentials)
|
16
|
+
template "config/social_keys.yml", "config/social_keys.yml"
|
17
|
+
template "config/social_keys.yml", "config/social_keys.example.yml"
|
18
|
+
puts 'Update your social_keys.yml with your social credentials & add it to your IGNORE & just keep the .example'.colorize(:light_yellow)
|
19
|
+
|
20
|
+
# Add the OAuth Controller
|
21
|
+
template "controllers/omniauth_callbacks_controller.rb", "app/controllers/omniauth_callbacks_controller.rb"
|
22
|
+
puts 'Check out you your app/controllers/omniauth_callbacks_controller.rb which persist the social user through devise'.colorize(:light_yellow)
|
23
|
+
end
|
24
|
+
|
25
|
+
# Update files to let the Social working
|
26
|
+
def update_files
|
27
|
+
# Update the Routes to have it DEVISE_SOCIAL_ROUTE
|
28
|
+
inject_into_file 'config/routes.rb', after: "Application.routes.draw do\n" do <<-'RUBY'
|
29
|
+
devise_for :users, controllers: { omniauth_callbacks: "omniauth_callbacks" }
|
30
|
+
RUBY
|
31
|
+
end
|
32
|
+
|
33
|
+
# Update the application.rb to load the socials_keys on initialize
|
34
|
+
application do
|
35
|
+
social_keys = File.join(Rails.root, 'config', 'social_keys.yml')
|
36
|
+
yml = YAML::load(IO.read(social_keys))
|
37
|
+
hash = HashWithIndifferentAccess.new(yml)
|
38
|
+
CONFIG = hash[Rails.env] # it is calling as error because it is a Rails CONSTANT
|
39
|
+
CONFIG.each do |k,v|
|
40
|
+
ENV[k.upcase] ||= v
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
development:
|
2
|
+
facebook_key: "YOUR_KEY"
|
3
|
+
facebook_secret: "YOUR_SECRET"
|
4
|
+
|
5
|
+
twitter_key: "YOUR_KEY"
|
6
|
+
twitter_secret: "YOUR_SECRET"
|
7
|
+
|
8
|
+
github_key: "YOUR_KEY"
|
9
|
+
github_secret: "YOUR_SECRET"
|
10
|
+
|
11
|
+
linkedin_key: "YOUR_KEY"
|
12
|
+
linkedin_secret: "YOUR_SECRET"
|
13
|
+
|
14
|
+
google_key: "YOUR_KEY"
|
15
|
+
google_secret: "YOUR_SECRET"
|
16
|
+
|
17
|
+
production:
|
18
|
+
facebook_key: "YOUR_KEY"
|
19
|
+
facebook_secret: "YOUR_SECRET"
|
20
|
+
|
21
|
+
twitter_key: "YOUR_KEY"
|
22
|
+
twitter_secret: "YOUR_SECRET"
|
23
|
+
|
24
|
+
github_key: "YOUR_KEY"
|
25
|
+
github_secret: "YOUR_SECRET"
|
26
|
+
|
27
|
+
linkedin_key: "YOUR_KEY"
|
28
|
+
linkedin_secret: "YOUR_SECRET"
|
29
|
+
|
30
|
+
google_key: "YOUR_KEY"
|
31
|
+
google_secret: "YOUR_SECRET"
|
@@ -0,0 +1,28 @@
|
|
1
|
+
class OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
2
|
+
skip_before_filter :authenticate_user!
|
3
|
+
def all
|
4
|
+
p env["omniauth.auth"]
|
5
|
+
user = User.from_omniauth(env["omniauth.auth"], current_user)
|
6
|
+
if user.persisted?
|
7
|
+
flash[:notice] = "You are in..!!! Go to edit profile to see the status for the accounts"
|
8
|
+
sign_in_and_redirect(user)
|
9
|
+
else
|
10
|
+
session["devise.user_attributes"] = user.attributes
|
11
|
+
redirect_to new_user_registration_url
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def failure
|
16
|
+
#handle you logic here..
|
17
|
+
#and delegate to super.
|
18
|
+
super
|
19
|
+
end
|
20
|
+
|
21
|
+
# Alias for the actions call
|
22
|
+
alias_method :facebook, :all
|
23
|
+
alias_method :twitter, :all
|
24
|
+
alias_method :linkedin, :all
|
25
|
+
alias_method :github, :all
|
26
|
+
alias_method :passthru, :all
|
27
|
+
alias_method :google_oauth2, :all
|
28
|
+
end
|
data/lib/socials/connector.rb
CHANGED
@@ -2,6 +2,13 @@ require 'cgi'
|
|
2
2
|
|
3
3
|
# ParentClass which have the attrs to create the links
|
4
4
|
class Socials::Connector
|
5
|
+
# base attrs to create the links
|
6
|
+
attr_accessor :protocol # http OR https
|
7
|
+
attr_accessor :domain # api.facebook.com OR api.twitter.com OR api.google.com
|
8
|
+
attr_accessor :scope # api/v2.2 OR api OR /+/
|
9
|
+
attr_accessor :action # auth
|
10
|
+
attr_accessor :path # more paths like auth/action_auth/action_auth_param
|
11
|
+
|
5
12
|
# It constructor must be reused by it children
|
6
13
|
def initialize(params={})
|
7
14
|
# SetUp, dynamically, the attrs
|
@@ -11,7 +18,7 @@ class Socials::Connector
|
|
11
18
|
# Config the app for the connection
|
12
19
|
def setup() end
|
13
20
|
# Redirect the user to the SocialNetwork SignUp page
|
14
|
-
def sign_up(
|
21
|
+
def sign_up() end
|
15
22
|
# Return a base user to sig in it out of it lib
|
16
23
|
def get_base_user() end
|
17
24
|
# Get the user Logged hash & accesses (OAuth)
|
data/lib/socials/facebook.rb
CHANGED
@@ -1,8 +1,14 @@
|
|
1
1
|
class Socials::Facebook < Socials::Connector
|
2
2
|
# Config the app for the connection
|
3
|
-
def setup
|
3
|
+
def setup
|
4
|
+
|
5
|
+
end
|
6
|
+
|
4
7
|
# Redirect the user to the SocialNetwork SignUp page
|
5
|
-
def sign_up
|
8
|
+
def sign_up
|
9
|
+
|
10
|
+
end
|
11
|
+
|
6
12
|
# Return a base user to sig in it out of it lib
|
7
13
|
def get_base_user() end
|
8
14
|
# Get the user Logged hash & accesses (OAuth)
|
data/lib/socials/google_plus.rb
CHANGED
@@ -2,7 +2,7 @@ class Socials::GooglePlus < Socials::Connector
|
|
2
2
|
# Config the app for the connection
|
3
3
|
def setup() end
|
4
4
|
# Redirect the user to the SocialNetwork SignUp page
|
5
|
-
def sign_up(
|
5
|
+
def sign_up() end
|
6
6
|
# Return a base user to sig in it out of it lib
|
7
7
|
def get_base_user() end
|
8
8
|
# Get the user Logged hash & accesses (OAuth)
|
data/lib/socials/twitter.rb
CHANGED
@@ -2,7 +2,7 @@ class Socials::Twitter < Socials::Connector
|
|
2
2
|
# Config the app for the connection
|
3
3
|
def setup() end
|
4
4
|
# Redirect the user to the SocialNetwork SignUp page
|
5
|
-
def sign_up(
|
5
|
+
def sign_up() end
|
6
6
|
# Return a base user to sig in it out of it lib
|
7
7
|
def get_base_user() end
|
8
8
|
# Get the user Logged hash & accesses (OAuth)
|
data/lib/socials/version.rb
CHANGED
data/socials.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
#================== GEMs to build it GEM, so its improve the development ==============================
|
22
22
|
# Base GEMs to build it gem
|
23
|
-
spec.add_development_dependency
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1.7', '>= 1.7.12'
|
24
24
|
spec.add_development_dependency "rake", "~> 10.3", '>= 10.3.2'
|
25
25
|
|
26
26
|
# RSpec for tests
|
metadata
CHANGED
@@ -1,20 +1,23 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: socials
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ilton Garcia dos Santos Silveira
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
- - ">="
|
18
21
|
- !ruby/object:Gem::Version
|
19
22
|
version: 1.7.12
|
20
23
|
type: :development
|
@@ -22,6 +25,9 @@ dependencies:
|
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
27
|
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.7'
|
30
|
+
- - ">="
|
25
31
|
- !ruby/object:Gem::Version
|
26
32
|
version: 1.7.12
|
27
33
|
- !ruby/object:Gem::Dependency
|
@@ -222,6 +228,9 @@ files:
|
|
222
228
|
- Rakefile
|
223
229
|
- bin/console
|
224
230
|
- bin/setup
|
231
|
+
- lib/generators/socials/install_generator.rb
|
232
|
+
- lib/generators/templates/config/social_keys.yml
|
233
|
+
- lib/generators/templates/controllers/omniauth_callbacks_controller.rb
|
225
234
|
- lib/socials.rb
|
226
235
|
- lib/socials/connector.rb
|
227
236
|
- lib/socials/facebook.rb
|