socialite 0.0.1.beta4 → 0.1.0.pre
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/README.md +33 -34
- data/Rakefile +8 -21
- data/app/controllers/socialite/application_controller.rb +4 -0
- data/app/controllers/socialite/identities_controller.rb +2 -14
- data/app/controllers/socialite/session_controller.rb +20 -0
- data/app/controllers/socialite/users_controller.rb +0 -1
- data/app/views/layouts/socialite/application.html.haml +11 -0
- data/app/views/socialite/identities/new.html.haml +27 -0
- data/app/views/socialite/session/new.html.haml +31 -14
- data/app/views/socialite/user/edit.html.haml +1 -1
- data/config/routes.rb +7 -7
- data/lib/generators/socialite/install_generator.rb +7 -9
- data/lib/generators/socialite/migrations_generator.rb +34 -0
- data/lib/generators/socialite/templates/identity.rb.erb +25 -0
- data/lib/generators/socialite/templates/socialite.rb +20 -7
- data/lib/generators/socialite/templates/users.rb.erb +12 -0
- data/lib/socialite.rb +25 -27
- data/lib/socialite/controllers/helpers.rb +107 -111
- data/lib/socialite/engine.rb +19 -32
- data/lib/socialite/helpers/authentication.rb +1 -1
- data/lib/socialite/models/identity_concern.rb +91 -0
- data/lib/socialite/models/user_concern.rb +54 -0
- data/lib/socialite/version.rb +1 -1
- data/spec/dummy/README.rdoc +261 -0
- data/spec/dummy/app/assets/javascripts/application.js +9 -3
- data/spec/dummy/app/assets/stylesheets/application.css +11 -5
- data/{app/assets/images/socialite → spec/dummy/app/mailers}/.gitkeep +0 -0
- data/{app/assets/javascripts/socialite → spec/dummy/app/models}/.gitkeep +0 -0
- data/spec/dummy/app/models/identity.rb +4 -0
- data/spec/dummy/app/models/user.rb +4 -0
- data/spec/dummy/app/views/layouts/application.html.erb +1 -5
- data/spec/dummy/config/application.rb +19 -2
- data/spec/dummy/config/boot.rb +1 -11
- data/spec/dummy/config/database.yml +18 -2
- data/spec/dummy/config/environments/development.rb +8 -1
- data/spec/dummy/config/environments/production.rb +9 -2
- data/spec/dummy/config/environments/test.rb +4 -9
- data/spec/dummy/config/initializers/inflections.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +1 -1
- data/spec/dummy/config/initializers/session_store.rb +1 -1
- data/spec/dummy/config/initializers/socialite.rb +26 -4
- data/spec/dummy/config/initializers/wrap_parameters.rb +1 -1
- data/spec/dummy/config/routes.rb +2 -10
- data/{db/migrate/20110914215410_create_users.rb → spec/dummy/db/migrate/20130206224516_create_socialite_users.rb} +2 -4
- data/spec/dummy/db/migrate/20130206224517_create_socialite_identities.rb +25 -0
- data/spec/dummy/db/schema.rb +12 -20
- data/{lib/tasks → spec/dummy/lib/assets}/.gitkeep +0 -0
- data/spec/dummy/log/.gitkeep +0 -0
- data/spec/dummy/public/500.html +0 -1
- data/spec/factories/facebook.rb +5 -5
- data/spec/factories/identity.rb +3 -3
- data/spec/factories/user.rb +10 -12
- data/spec/generators/socialite/install_generator_spec.rb +43 -0
- data/spec/generators/socialite/migrations_generator_spec.rb +27 -0
- data/spec/models/facebook_spec.rb +24 -21
- data/spec/models/identity_spec.rb +2 -2
- data/spec/models/user_spec.rb +7 -7
- data/spec/socialite_spec.rb +53 -0
- data/spec/spec_helper.rb +23 -10
- data/spec/support/identity_shared_example.rb +24 -20
- metadata +202 -144
- data/.autotest +0 -7
- data/.gitignore +0 -9
- data/.rspec +0 -2
- data/.travis.yml +0 -10
- data/.yardopts +0 -8
- data/Gemfile +0 -8
- data/Gemfile.lock +0 -208
- data/app/models/socialite/facebook_identity.rb +0 -5
- data/app/models/socialite/identity.rb +0 -5
- data/app/models/socialite/user.rb +0 -10
- data/config/initializers/simple_form.rb +0 -90
- data/config/locales/simple_form.en.yml +0 -23
- data/db/migrate/20110925224222_create_identities.rb +0 -26
- data/db/migrate/20110926005551_create_facebook_identities.rb +0 -12
- data/lib/socialite/api_wrappers/facebook.rb +0 -67
- data/lib/socialite/api_wrappers/twitter.rb +0 -19
- data/lib/socialite/models/identity.rb +0 -99
- data/lib/socialite/models/user.rb +0 -50
- data/lib/socialite/service_config.rb +0 -14
- data/lib/tasks/cucumber.rake +0 -65
- data/script/cucumber +0 -10
- data/script/rails +0 -6
- data/socialite.gemspec +0 -39
- data/spec/dummy/app/controllers/home_controller.rb +0 -11
- data/spec/dummy/app/views/home/index.html.haml +0 -12
- data/spec/dummy/app/views/home/show.html.haml +0 -6
data/README.md
CHANGED
@@ -1,17 +1,29 @@
|
|
1
1
|
# Socialite
|
2
2
|
|
3
|
-
|
4
|
-
multiple
|
5
|
-
Twitter, Facebook, Github and LinkedIn.
|
3
|
+
This is an opinionated Rails 3.1 mountable engine provides your application with
|
4
|
+
support for managing multiple OAuth providers per User.
|
6
5
|
|
7
|
-
|
8
|
-
the [OmniAuth](http://github.com/intridea/omniauth) project.
|
6
|
+
## Why make this?
|
9
7
|
|
10
|
-
|
8
|
+
Every site I have built in the past couple years has required implementing
|
9
|
+
authentication support for Users. Now this was simple enough when it was only
|
10
|
+
**one** provider (in my case, "Login with Facebook"), but more often then not
|
11
|
+
it evolved into "Login with `<insert_oauth_provider>`".
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
13
|
+
Now OmniAuth has some [good write-ups](https://github.com/intridea/omniauth/wiki/Managing-Multiple-Providers)
|
14
|
+
on handling multiple providers, but it lacked any support for restricting a user
|
15
|
+
to one identity per provider. Socialite aims to solve this and while enforcing
|
16
|
+
every user to have a Basic Authentication identity as a fall-back in case of
|
17
|
+
password recovery.
|
18
|
+
|
19
|
+
## What makes this unique?
|
20
|
+
|
21
|
+
1. Every User can only have one identity per supported provider
|
22
|
+
* Example: User can have only 1 linked Facebook Identity at any given time
|
23
|
+
2. Every User must have an basic-auth identity
|
24
|
+
* Example: User signs up through Facebook, but unlinks it.
|
25
|
+
Enforcing a local basic auth mechanism aids account recovery.
|
26
|
+
3. Supports any provider strategy in the OmniAuth project.
|
15
27
|
|
16
28
|
## Resources
|
17
29
|
|
@@ -26,38 +38,25 @@ version to the public.
|
|
26
38
|
|
27
39
|
To use Socialite in a Rails 3.1 application:
|
28
40
|
|
29
|
-
* Require it in the Gemfile:
|
30
|
-
|
31
|
-
*
|
32
|
-
|
33
|
-
|
34
|
-
application's CSS manifest file
|
41
|
+
* Require it in the Gemfile:
|
42
|
+
`gem 'socialite', git: 'git://github.com/jsmestad/socialite`
|
43
|
+
* Install the gem it by running `bundle install`.
|
44
|
+
* Run the socialite generator using `rails g socialite:install` for typical
|
45
|
+
installs and `rails g active_record:socialite` for specifying custom options.
|
35
46
|
|
36
47
|
## History
|
37
48
|
|
38
49
|
This project began as a fork of [Tim Riley](http://openmonkey.com)'s
|
39
50
|
great Omnisocial plugin. The motivation for this fork is that I required
|
40
51
|
multiple authorizations for each account (linking support) and wanted a
|
41
|
-
proper Rails 3.1 Engine.
|
42
|
-
|
43
|
-
## Socialite Contributers
|
44
|
-
|
45
|
-
* [Justin Smestad](http://github.com/jsmestad)
|
46
|
-
* [Bobby Wilson](http://github.com/bobbyw)
|
47
|
-
|
48
|
-
### Omnisocial Contributers
|
49
|
-
|
50
|
-
* [Klaus Hartl](http://github.com/carhartl)
|
51
|
-
* [Stephen Aument](http://github.com/stephenaument)
|
52
|
-
* [Lucas Allan](http://github.com/lucasallan)
|
53
|
-
* [James Dumay](http://github.com/i386)
|
54
|
-
* [Pablo Dejuan](http://github.com/pdjota)
|
55
|
-
* [Chris Oliver](http://github.com/excid3)
|
52
|
+
proper mountable Rails 3.1 Engine.
|
56
53
|
|
57
54
|
## Copyright & License
|
58
55
|
|
59
|
-
Socialite is Copyright (c) 2011 Justin Smestad. All Rights are Reserved.
|
60
|
-
distributed under the Apache 2.0 License. See LICENSE file for more
|
56
|
+
Socialite is Copyright (c) 2011- 2013 Justin Smestad. All Rights are Reserved.
|
57
|
+
Code is distributed under the Apache 2.0 License. See LICENSE file for more
|
58
|
+
information.
|
61
59
|
|
62
|
-
The original OmniSocial code is Copyright (c) 2010-2011
|
63
|
-
and [Icelab](http://icelab.com.au/), and is
|
60
|
+
The original OmniSocial code is Copyright (c) 2010-2011
|
61
|
+
[Tim Riley](http://openmonkey.com/) and [Icelab](http://icelab.com.au/), and is
|
62
|
+
released under MIT License.
|
data/Rakefile
CHANGED
@@ -5,30 +5,17 @@ rescue LoadError
|
|
5
5
|
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
6
|
end
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
end
|
8
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
9
|
+
load 'rails/tasks/engine.rake'
|
10
|
+
|
11
|
+
Bundler::GemHelper.install_tasks
|
12
|
+
|
13
|
+
Dir[File.join(File.dirname(__FILE__), 'tasks/**/*.rake')].each {|f| load f }
|
15
14
|
|
16
15
|
require 'rspec/core'
|
17
16
|
require 'rspec/core/rake_task'
|
18
17
|
|
19
|
-
|
18
|
+
desc "Run all specs in spec directory (excluding plugin specs)"
|
19
|
+
RSpec::Core::RakeTask.new(:spec => 'app:db:test:prepare')
|
20
20
|
|
21
21
|
task :default => :spec
|
22
|
-
|
23
|
-
Rake::RDocTask.new(:rdoc) do |rdoc|
|
24
|
-
rdoc.rdoc_dir = 'rdoc'
|
25
|
-
rdoc.title = 'Socialite'
|
26
|
-
rdoc.options << '--line-numbers' << '--inline-source'
|
27
|
-
rdoc.rdoc_files.include('README.rdoc')
|
28
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
29
|
-
end
|
30
|
-
|
31
|
-
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
32
|
-
load 'rails/tasks/engine.rake'
|
33
|
-
|
34
|
-
Bundler::GemHelper.install_tasks
|
@@ -5,20 +5,8 @@ module Socialite
|
|
5
5
|
before_filter :ensure_user, :only => [:destroy]
|
6
6
|
respond_to :html, :json
|
7
7
|
|
8
|
-
def
|
9
|
-
|
10
|
-
identity = Identity.find_or_initialize_by_oauth(auth_hash)
|
11
|
-
identity.build_user if identity.user.blank?
|
12
|
-
|
13
|
-
if identity.save
|
14
|
-
self.current_user ||= identity.user
|
15
|
-
flash_message :notice, 'You have logged in successfully.'
|
16
|
-
else
|
17
|
-
flash_message :error, 'An error occurred. Please try again.'
|
18
|
-
end
|
19
|
-
respond_with(identity) do |format|
|
20
|
-
format.html { redirect_back_or_default }
|
21
|
-
end
|
8
|
+
def new
|
9
|
+
@identity = env['omniauth.identity'] ||= User.new
|
22
10
|
end
|
23
11
|
|
24
12
|
def failure
|
@@ -7,6 +7,26 @@ module Socialite
|
|
7
7
|
|
8
8
|
respond_to :html, :json
|
9
9
|
|
10
|
+
def new; end
|
10
11
|
|
12
|
+
def create
|
13
|
+
@identity = Identity.find_or_initialize_by_oauth(env['omniauth.auth'])
|
14
|
+
@identity.build_user if @identity.user.blank?
|
15
|
+
|
16
|
+
if @identity.save
|
17
|
+
self.current_user = @identity.user
|
18
|
+
flash_message :notice, 'You have logged in successfully.'
|
19
|
+
else
|
20
|
+
flash_message :error, 'An error occurred. Please try again.'
|
21
|
+
end
|
22
|
+
respond_with(identity) do |format|
|
23
|
+
format.html { redirect_back_or_default }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def destroy
|
28
|
+
logout!
|
29
|
+
redirect_to main_app.root_path, notice: 'Signed out!'
|
30
|
+
end
|
11
31
|
end
|
12
32
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
%h1 New Account
|
2
|
+
|
3
|
+
= form_tag "/auth/identity/register" do
|
4
|
+
- if @identity && @identity.errors.any?
|
5
|
+
.error_messages
|
6
|
+
%h2 #{pluralize(@identity.errors.count, "error")} prohibited this account from being saved:
|
7
|
+
%ul
|
8
|
+
- @identity.errors.full_messages.each do |msg|
|
9
|
+
%li= msg
|
10
|
+
.field
|
11
|
+
= label_tag :name
|
12
|
+
%br
|
13
|
+
= text_field_tag :name, @identity.try(:name)
|
14
|
+
.field
|
15
|
+
= label_tag :email
|
16
|
+
%br
|
17
|
+
= text_field_tag :email, @identity.try(:email)
|
18
|
+
.field
|
19
|
+
= label_tag :password
|
20
|
+
%br
|
21
|
+
= password_field_tag :password
|
22
|
+
.field
|
23
|
+
= label_tag :password_confirmation
|
24
|
+
%br
|
25
|
+
= password_field_tag :password_confirmation
|
26
|
+
.actions
|
27
|
+
= submit_tag "Register"
|
@@ -1,14 +1,31 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
1
|
+
%h1 Sign In
|
2
|
+
|
3
|
+
%p
|
4
|
+
%strong Sign in through one of these services:
|
5
|
+
|
6
|
+
.auth_providers
|
7
|
+
%a.auth_provider{href: "/auth/twitter"}
|
8
|
+
#{image_tag "twitter_64.png", size: "64x64", alt: "Twitter"}
|
9
|
+
Twitter
|
10
|
+
%a.auth_provider{href: "/auth/facebook"}
|
11
|
+
#{image_tag "facebook_64.png", size: "64x64", alt: "Facebook"}
|
12
|
+
Facebook
|
13
|
+
%a.auth_provider{href: "/auth/google_apps"}
|
14
|
+
#{image_tag "google_apps_64.png", size: "64x64", alt: "Google"}
|
15
|
+
Google
|
16
|
+
|
17
|
+
%p
|
18
|
+
%strong Don't use these services?
|
19
|
+
#{link_to "Create an account", new_identity_path} or login below.
|
20
|
+
|
21
|
+
= form_tag "/auth/identity/callback" do
|
22
|
+
.field
|
23
|
+
= label_tag :auth_key, "Email"
|
24
|
+
%br
|
25
|
+
= text_field_tag :auth_key
|
26
|
+
.field
|
27
|
+
= label_tag :password
|
28
|
+
%br
|
29
|
+
= password_field_tag :password
|
30
|
+
.actions
|
31
|
+
= submit_tag "Login"
|
@@ -1 +1 @@
|
|
1
|
-
= render 'users/form', :locals => {:user => @user
|
1
|
+
= render 'users/form', :locals => {:user => @user}
|
data/config/routes.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
Socialite::Engine.routes.draw do
|
2
|
-
match '/login' => 'session#new', :as => :login
|
3
|
-
match '/auth/:service/callback' => 'identities#create', :as => :callback
|
4
|
-
match '/auth/failure' => 'identities#failure'
|
5
|
-
match '/logout' => 'session#destroy', :as => :logout
|
2
|
+
# match '/login' => 'session#new', :as => :login
|
3
|
+
# match '/auth/:service/callback' => 'identities#create', :as => :callback
|
4
|
+
# match '/auth/failure' => 'identities#failure'
|
5
|
+
# match '/logout' => 'session#destroy', :as => :logout
|
6
6
|
|
7
|
-
resource :user, :except => [:new, :create] do
|
8
|
-
resources :identities
|
9
|
-
end
|
7
|
+
# resource :user, :except => [:new, :create] do
|
8
|
+
# resources :identities
|
9
|
+
# end
|
10
10
|
end
|
@@ -1,21 +1,19 @@
|
|
1
1
|
require 'rails/generators'
|
2
|
-
require 'rails/generators/migration'
|
3
2
|
|
4
3
|
module Socialite
|
5
4
|
module Generators
|
6
|
-
class InstallGenerator < Rails::Generators::Base
|
7
|
-
|
8
|
-
|
9
|
-
desc 'Generates the socialite initializer'
|
10
|
-
|
11
|
-
def self.source_root
|
12
|
-
File.join(File.dirname(__FILE__), 'templates')
|
13
|
-
end
|
5
|
+
class InstallGenerator < ::Rails::Generators::Base
|
6
|
+
source_root File.expand_path("../templates", __FILE__)
|
14
7
|
|
8
|
+
desc 'Creates a socialite initializer'
|
15
9
|
def copy_initializer
|
16
10
|
template 'socialite.rb', 'config/initializers/socialite.rb'
|
17
11
|
end
|
18
12
|
|
13
|
+
# def add_opro_routes
|
14
|
+
# socialite_routes = "mount_socialite_oauth"
|
15
|
+
# route socialite_routes
|
16
|
+
# end
|
19
17
|
end
|
20
18
|
end
|
21
19
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'rails/generators/migration'
|
2
|
+
|
3
|
+
module Socialite
|
4
|
+
module Generators
|
5
|
+
class MigrationsGenerator < ::Rails::Generators::Base
|
6
|
+
include Rails::Generators::Migration
|
7
|
+
source_root File.expand_path('../templates', __FILE__)
|
8
|
+
|
9
|
+
class_option :users_table,
|
10
|
+
:default => 'socialite_users',
|
11
|
+
:type => :string
|
12
|
+
class_option :identity_table,
|
13
|
+
:default => 'socialite_identities',
|
14
|
+
:type => :string
|
15
|
+
|
16
|
+
desc "add the migrations needed for socialite"
|
17
|
+
|
18
|
+
def self.next_migration_number(path)
|
19
|
+
unless @prev_migration_nr
|
20
|
+
@prev_migration_nr = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i
|
21
|
+
else
|
22
|
+
@prev_migration_nr += 1
|
23
|
+
end
|
24
|
+
@prev_migration_nr.to_s
|
25
|
+
end
|
26
|
+
|
27
|
+
def copy_migrations
|
28
|
+
migration_template "users.rb.erb", "db/migrate/create_socialite_users.rb"
|
29
|
+
migration_template "identity.rb.erb", "db/migrate/create_socialite_identities.rb"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class CreateSocialiteIdentities < ActiveRecord::Migration
|
2
|
+
def up
|
3
|
+
create_table :<%= options[:identity_table] %> do |t|
|
4
|
+
t.string :uid, :provider
|
5
|
+
t.text :auth_hash
|
6
|
+
t.integer :<%= "#{options[:users_table].singularize}_id" %>
|
7
|
+
t.timestamps
|
8
|
+
end
|
9
|
+
|
10
|
+
add_index :<%= options[:identity_table] %>,
|
11
|
+
:<%= "#{options[:users_table].singularize}_id" %>
|
12
|
+
|
13
|
+
# Restrict each user to one identity per provider, to disable comment out.
|
14
|
+
add_index :<%= options[:identity_table] %>,
|
15
|
+
[:<%= "#{options[:users_table].singularize}_id" %>, :provider], :unique => true
|
16
|
+
|
17
|
+
# Database constraint to ensure uniqueness of UIDs (scoped to provider)
|
18
|
+
add_index :<%= options[:identity_table] %>,
|
19
|
+
[:provider, :uid], :unique => true
|
20
|
+
end
|
21
|
+
|
22
|
+
def down
|
23
|
+
drop_table :<%= options[:identity_table] %>
|
24
|
+
end
|
25
|
+
end
|
@@ -1,14 +1,27 @@
|
|
1
|
-
require 'socialite'
|
2
|
-
|
3
1
|
Socialite.setup do |config|
|
4
|
-
|
5
|
-
#
|
2
|
+
## Configure Classes
|
3
|
+
# If you are not using the default names set below. Please change them to
|
4
|
+
# reflect the correct classes.
|
5
|
+
#
|
6
|
+
# **NOTE** These _should_ be set to string values to prevent any possible
|
7
|
+
# errors caused by load order.
|
8
|
+
config.user_class = 'User'
|
9
|
+
config.identity_class = 'Identity'
|
6
10
|
|
7
|
-
|
8
|
-
#
|
11
|
+
## Add any supported OmniAuth providers
|
12
|
+
# You can pass any providers that are supported by OmniAuth simply by
|
13
|
+
# including it in your Gemfile.
|
14
|
+
#
|
15
|
+
# Examples:
|
16
|
+
# config.provider :facebook, ENV['FACEBOOK_APP_KEY'], ENV['FACEBOOK_SECRET'],
|
17
|
+
# :scope => 'email,friends'
|
18
|
+
# config.provider :identity, :on_failed_registration => lambda { |env|
|
19
|
+
# UsersController.action(:new).call(env)
|
20
|
+
# }
|
21
|
+
# config.provider :twitter, ENV['TWITTER_APP_KEY'], ENV['TWITTER_SECRET']
|
9
22
|
|
10
23
|
if Rails.env.production?
|
11
|
-
#
|
24
|
+
# Any production specific information
|
12
25
|
elsif Rails.env.development?
|
13
26
|
# Configs for development mode go here
|
14
27
|
end
|
data/lib/socialite.rb
CHANGED
@@ -1,15 +1,10 @@
|
|
1
|
+
require 'socialite/engine'
|
2
|
+
|
1
3
|
require 'haml'
|
2
|
-
require 'omniauth
|
3
|
-
require 'omniauth/oauth'
|
4
|
+
require 'omniauth'
|
4
5
|
|
5
6
|
module Socialite
|
6
7
|
autoload :ControllerSupport, 'socialite/controller_support'
|
7
|
-
autoload :ServiceConfig, 'socialite/service_config'
|
8
|
-
|
9
|
-
module ApiWrappers
|
10
|
-
autoload :Facebook, 'socialite/api_wrappers/facebook'
|
11
|
-
autoload :Twitter, 'socialite/api_wrappers/twitter'
|
12
|
-
end
|
13
8
|
|
14
9
|
module Controllers
|
15
10
|
autoload :Helpers, 'socialite/controllers/helpers'
|
@@ -20,35 +15,38 @@ module Socialite
|
|
20
15
|
end
|
21
16
|
|
22
17
|
module Models
|
23
|
-
autoload :
|
24
|
-
autoload :
|
25
|
-
|
18
|
+
autoload :IdentityConcern, 'socialite/models/identity_concern'
|
19
|
+
autoload :UserConcern, 'socialite/models/user_concern'
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.setup
|
23
|
+
yield self if block_given?
|
26
24
|
end
|
27
25
|
|
28
|
-
mattr_accessor :
|
29
|
-
@@service_configs = {}
|
26
|
+
mattr_accessor :user_class, :identity_class, :providers
|
30
27
|
|
31
|
-
def self.
|
32
|
-
|
28
|
+
def self.providers
|
29
|
+
@@providers ||= []
|
33
30
|
end
|
34
31
|
|
35
|
-
def self.
|
36
|
-
|
32
|
+
def self.provider(klass, *args)
|
33
|
+
@@providers ||= []
|
34
|
+
@@providers << [klass, args]
|
37
35
|
end
|
38
36
|
|
39
|
-
def self.
|
40
|
-
|
37
|
+
def self.identity_class
|
38
|
+
identity_class_name.constantize
|
41
39
|
end
|
42
40
|
|
43
|
-
|
44
|
-
|
45
|
-
@@service_configs[:twitter] = ServiceConfig.new(app_key, app_secret, options)
|
41
|
+
def self.identity_class_name
|
42
|
+
@@identity_class.camelize
|
46
43
|
end
|
47
44
|
|
48
|
-
|
49
|
-
|
50
|
-
@@service_configs[:facebook] = ServiceConfig.new(app_key, app_secret, options)
|
45
|
+
def self.user_class
|
46
|
+
user_class_name.constantize
|
51
47
|
end
|
52
|
-
end
|
53
48
|
|
54
|
-
|
49
|
+
def self.user_class_name
|
50
|
+
@@user_class.camelize
|
51
|
+
end
|
52
|
+
end
|