solidus_social 1.0.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.circleci/config.yml +35 -0
- data/.gem_release.yml +5 -0
- data/.gitignore +6 -8
- data/.rspec +3 -3
- data/.rubocop.yml +3 -7
- data/.rubocop_todo.yml +42 -0
- data/CHANGELOG.md +34 -4
- data/Gemfile +23 -0
- data/{LICENSE.md → LICENSE} +2 -2
- data/README.md +133 -78
- data/Rakefile +4 -13
- data/app/controllers/spree/admin/authentication_methods_controller.rb +2 -12
- data/app/controllers/spree/omniauth_callbacks_controller.rb +46 -42
- data/app/controllers/spree/user_authentications_controller.rb +3 -1
- data/app/core/spree/permission_sets/authentication_method_display.rb +11 -0
- data/app/core/spree/permission_sets/authentication_method_management.rb +11 -0
- data/app/decorators/controllers/solidus_social/spree/user_registrations_controller_decorator.rb +27 -0
- data/app/decorators/models/solidus_social/spree/user_decorator.rb +28 -0
- data/app/helpers/spree/omniauth_callbacks_helper.rb +2 -0
- data/app/models/spree/authentication_method.rb +8 -2
- data/app/models/spree/social_configuration.rb +3 -0
- data/app/models/spree/user_authentication.rb +3 -1
- data/app/overrides/add_authentications_to_account_summary.rb +2 -0
- data/app/overrides/admin_configuration_decorator.rb +9 -2
- data/app/overrides/user_registrations_decorator.rb +2 -0
- data/app/views/spree/admin/authentication_methods/_form.html.erb +6 -22
- data/app/views/spree/admin/authentication_methods/edit.html.erb +5 -3
- data/app/views/spree/admin/authentication_methods/index.html.erb +22 -18
- data/app/views/spree/admin/authentication_methods/new.html.erb +5 -3
- data/app/views/spree/shared/_social.html.erb +5 -5
- data/app/views/spree/shared/_user_form.html.erb +3 -3
- data/app/views/spree/users/_new-customer.html.erb +2 -2
- data/app/views/spree/users/_social.html.erb +24 -22
- data/bin/console +17 -0
- data/bin/rails +15 -4
- data/bin/rake +7 -0
- data/bin/sandbox +72 -0
- data/bin/setup +8 -0
- data/config/locales/en.yml +1 -0
- data/config/locales/es-MX.yml +8 -4
- data/config/locales/es.yml +30 -0
- data/config/locales/it.yml +26 -0
- data/config/routes.rb +7 -5
- data/db/migrate/20120120163432_create_user_authentications.rb +3 -1
- data/db/migrate/20120123163222_create_authentication_methods.rb +3 -1
- data/lib/generators/solidus_social/install/install_generator.rb +13 -5
- data/lib/generators/solidus_social/install/templates/config/initializers/solidus_social.rb +50 -0
- data/lib/solidus_social.rb +24 -8
- data/lib/solidus_social/engine.rb +29 -55
- data/lib/solidus_social/facebook_omniauth_strategy_ext.rb +25 -0
- data/lib/solidus_social/factories.rb +4 -0
- data/lib/solidus_social/version.rb +3 -16
- data/solidus_social.gemspec +43 -46
- data/spec/controllers/spree/omniauth_callbacks_controller_spec.rb +42 -9
- data/spec/features/spree/admin/authentication_methods_configuration_spec.rb +21 -27
- data/spec/features/spree/sign_in_spec.rb +27 -19
- data/spec/lib/solidus_social/engine_spec.rb +9 -0
- data/spec/lib/solidus_social_speec.rb +25 -0
- data/spec/lib/spree/social_config_spec.rb +11 -0
- data/spec/models/spree/authentication_method_spec.rb +19 -0
- data/spec/models/spree/social_configuration_spec.rb +6 -0
- data/spec/models/spree/user_decorator_spec.rb +25 -2
- data/spec/spec_helper.rb +17 -29
- data/spec/support/omniauth.rb +4 -0
- metadata +71 -198
- data/.hound.yml +0 -26
- data/.travis.yml +0 -19
- data/Guardfile +0 -10
- data/app/assets/javascripts/spree/backend/solidus_social.js +0 -1
- data/app/assets/javascripts/spree/frontend/solidus_social.js +0 -1
- data/app/assets/stylesheets/spree/backend/solidus_social.css +0 -3
- data/app/controllers/spree/user_registrations_controller_decorator.rb +0 -15
- data/app/models/spree/user_decorator.rb +0 -16
- data/app/views/spree/admin/shared/_configurations_menu.html.erb +0 -4
- data/config/initializers/devise.rb +0 -13
- data/spec/lib/spree_social/engine_spec.rb +0 -16
- data/spec/support/capybara.rb +0 -18
- data/spec/support/database_cleaner.rb +0 -24
- data/spec/support/devise.rb +0 -3
- data/spec/support/factory_girl.rb +0 -7
- data/spec/support/spree.rb +0 -8
@@ -1,11 +1,11 @@
|
|
1
1
|
<%= render 'spree/admin/shared/configuration_menu' %>
|
2
2
|
|
3
3
|
<% content_for :page_title do %>
|
4
|
-
<%=
|
4
|
+
<%= I18n.t('spree.new_social_method') %>
|
5
5
|
<% end %>
|
6
6
|
|
7
7
|
<% content_for :page_actions do %>
|
8
|
-
<li><%= link_to_with_icon 'icon-arrow-left',
|
8
|
+
<li><%= link_to_with_icon 'icon-arrow-left', I18n.t('spree.back_to_authentication_methods_list'), admin_authentication_methods_path, class: 'button' %></li>
|
9
9
|
<% end %>
|
10
10
|
|
11
11
|
<%= render 'spree/shared/error_messages', target: @authentication_method %>
|
@@ -13,6 +13,8 @@
|
|
13
13
|
<%= form_for [:admin, @authentication_method] do |f| %>
|
14
14
|
<fieldset class="no-border-top">
|
15
15
|
<%= render 'form', f: f %>
|
16
|
-
|
16
|
+
<% if can? :manage, Spree::AuthenticationMethod %>
|
17
|
+
<%= render 'spree/admin/shared/new_resource_links' %>
|
18
|
+
<% end %>
|
17
19
|
</fieldset>
|
18
20
|
<% end %>
|
@@ -1,11 +1,11 @@
|
|
1
1
|
<div id="social-signin-links">
|
2
2
|
<% if (!spree_current_user || !spree_current_user.user_authentications) && Spree::AuthenticationMethod.active_authentication_methods? %>
|
3
|
-
<h2><%=
|
3
|
+
<h2><%= I18n.t('spree.sign_in_through_one_of_these_services') %></h2>
|
4
4
|
<% end %>
|
5
5
|
|
6
|
-
<% Spree::AuthenticationMethod.available_for(
|
7
|
-
<%= link_to(content_tag(:i, '', class: "icon-spree-#{method.provider.
|
8
|
-
spree.
|
9
|
-
title:
|
6
|
+
<% Spree::AuthenticationMethod.available_for(spree_current_user).each do |method| %>
|
7
|
+
<%= link_to(content_tag(:i, '', class: "icon-spree-#{method.provider.dasherize}-circled"),
|
8
|
+
spree.send("spree_user_#{method.provider}_omniauth_authorize_path", r: rand),
|
9
|
+
title: t('spree.sign_in_with', provider: method.provider)) if method.active %>
|
10
10
|
<% end %>
|
11
11
|
</div>
|
@@ -1,16 +1,16 @@
|
|
1
1
|
<p>
|
2
|
-
<%= f.label :email,
|
2
|
+
<%= f.label :email, I18n.t('spree.email') %><br />
|
3
3
|
<%= f.email_field :email, class: 'title' %>
|
4
4
|
</p>
|
5
5
|
<% if spree_current_user.nil? || spree_current_user.password_required? %>
|
6
6
|
<div id="password-credentials">
|
7
7
|
<p>
|
8
|
-
<%= f.label :password,
|
8
|
+
<%= f.label :password, I18n.t('spree.password') %><br />
|
9
9
|
<%= f.password_field :password, class: 'title' %>
|
10
10
|
</p>
|
11
11
|
|
12
12
|
<p>
|
13
|
-
<%= f.label :password_confirmation,
|
13
|
+
<%= f.label :password_confirmation, I18n.t('spree.confirm_password') %><br />
|
14
14
|
<%= f.password_field :password_confirmation, class: 'title' %>
|
15
15
|
</p>
|
16
16
|
</div>
|
@@ -1,28 +1,30 @@
|
|
1
1
|
<% if Spree::AuthenticationMethod.active_authentication_methods? %>
|
2
|
-
<% @body_id = 'login' %>
|
3
|
-
<div id="existing-customer">
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
2
|
+
<% @body_id = 'login' %>
|
3
|
+
<div id="existing-customer">
|
4
|
+
<% if spree_current_user.user_authentications %>
|
5
|
+
<% unless spree_current_user.user_authentications.empty? %>
|
6
|
+
<p><strong><%= I18n.t('spree.you_have_signed_in_with_these_services') %>:</strong></p>
|
7
|
+
<div class="authentications">
|
8
|
+
<% for user_authentication in spree_current_user.user_authentications %>
|
9
|
+
<div class="authentication">
|
10
|
+
<div class="provider columns two">
|
11
|
+
<%= content_tag(:i, '', class: "icon-spree-#{user_authentication.provider.dasherize}-circled columns") %>
|
12
|
+
<%= user_authentication.provider %>
|
13
|
+
</div>
|
14
|
+
<div class="uid columns two"><%= user_authentication.uid %></div>
|
15
|
+
<%= link_to 'X', user_authentication, data: { confirm: I18n.t('spree.remove_authentication_option_confirmation') }, method: :delete, class: 'remove' %>
|
13
16
|
</div>
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
<div class="clear"></div>
|
19
|
-
</div>
|
17
|
+
<% end %>
|
18
|
+
<div class="clear"></div>
|
19
|
+
</div>
|
20
|
+
<% end %>
|
20
21
|
<% end %>
|
21
22
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
<% if Spree::AuthenticationMethod.available_for(spree_current_user).present? %>
|
24
|
+
<%= content_tag(:p, content_tag(:strong, I18n.t('spree.add_another_service'))) %>
|
25
|
+
<%= render 'spree/shared/social' %>
|
26
|
+
<% end %>
|
27
|
+
</div>
|
26
28
|
|
27
|
-
<div class="clear"></div>
|
29
|
+
<div class="clear"></div>
|
28
30
|
<% end %>
|
data/bin/console
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
5
|
+
require "bundler/setup"
|
6
|
+
require "solidus_social"
|
7
|
+
|
8
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
9
|
+
# with your gem easier. You can also use a different console, if you like.
|
10
|
+
$LOAD_PATH.unshift(*Dir["#{__dir__}/../app/*"])
|
11
|
+
|
12
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
13
|
+
# require "pry"
|
14
|
+
# Pry.start
|
15
|
+
|
16
|
+
require "irb"
|
17
|
+
IRB.start(__FILE__)
|
data/bin/rails
CHANGED
@@ -1,7 +1,18 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
4
|
-
ENGINE_PATH = File.expand_path('../../lib/solidus_social/engine', __FILE__)
|
3
|
+
# frozen_string_literal: true
|
5
4
|
|
6
|
-
|
7
|
-
|
5
|
+
app_root = 'sandbox'
|
6
|
+
|
7
|
+
unless File.exist? "#{app_root}/bin/rails"
|
8
|
+
warn 'Creating the sandbox app...'
|
9
|
+
Dir.chdir "#{__dir__}/.." do
|
10
|
+
system "#{__dir__}/sandbox" or begin # rubocop:disable Style/AndOr
|
11
|
+
warn 'Automatic creation of the sandbox app failed'
|
12
|
+
exit 1
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
Dir.chdir app_root
|
18
|
+
exec 'bin/rails', *ARGV
|
data/bin/rake
ADDED
data/bin/sandbox
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
set -e
|
4
|
+
|
5
|
+
case "$DB" in
|
6
|
+
postgres|postgresql)
|
7
|
+
RAILSDB="postgresql"
|
8
|
+
;;
|
9
|
+
mysql)
|
10
|
+
RAILSDB="mysql"
|
11
|
+
;;
|
12
|
+
sqlite|'')
|
13
|
+
RAILSDB="sqlite3"
|
14
|
+
;;
|
15
|
+
*)
|
16
|
+
echo "Invalid DB specified: $DB"
|
17
|
+
exit 1
|
18
|
+
;;
|
19
|
+
esac
|
20
|
+
|
21
|
+
extension_name="solidus_social"
|
22
|
+
|
23
|
+
# Stay away from the bundler env of the containing extension.
|
24
|
+
function unbundled {
|
25
|
+
ruby -rbundler -e'b = proc {system *ARGV}; Bundler.respond_to?(:with_unbundled_env) ? Bundler.with_unbundled_env(&b) : Bundler.with_clean_env(&b)' -- $@
|
26
|
+
}
|
27
|
+
|
28
|
+
rm -rf ./sandbox
|
29
|
+
unbundled bundle exec rails new sandbox --database="$RAILSDB" \
|
30
|
+
--skip-bundle \
|
31
|
+
--skip-git \
|
32
|
+
--skip-keeps \
|
33
|
+
--skip-rc \
|
34
|
+
--skip-spring \
|
35
|
+
--skip-test \
|
36
|
+
--skip-javascript
|
37
|
+
|
38
|
+
if [ ! -d "sandbox" ]; then
|
39
|
+
echo 'sandbox rails application failed'
|
40
|
+
exit 1
|
41
|
+
fi
|
42
|
+
|
43
|
+
cd ./sandbox
|
44
|
+
cat <<RUBY >> Gemfile
|
45
|
+
|
46
|
+
gem '$extension_name', path: '..'
|
47
|
+
gem 'solidus_auth_devise', '>= 2.1.0'
|
48
|
+
gem 'rails-i18n'
|
49
|
+
gem 'solidus_i18n'
|
50
|
+
|
51
|
+
group :test, :development do
|
52
|
+
platforms :mri do
|
53
|
+
gem 'pry-byebug'
|
54
|
+
end
|
55
|
+
end
|
56
|
+
RUBY
|
57
|
+
|
58
|
+
unbundled bundle install --gemfile Gemfile
|
59
|
+
|
60
|
+
unbundled bundle exec rake db:drop db:create
|
61
|
+
|
62
|
+
unbundled bundle exec rails generate spree:install \
|
63
|
+
--auto-accept \
|
64
|
+
--user_class=Spree::User \
|
65
|
+
--enforce_available_locales=true \
|
66
|
+
$@
|
67
|
+
|
68
|
+
unbundled bundle exec rails generate solidus:auth:install
|
69
|
+
|
70
|
+
echo
|
71
|
+
echo "🚀 Sandbox app successfully created for $extension_name!"
|
72
|
+
echo "🚀 This app is intended for test purposes."
|
data/bin/setup
ADDED
data/config/locales/en.yml
CHANGED
@@ -10,6 +10,7 @@ en:
|
|
10
10
|
destroy: 'Successfully destroyed authentication method.'
|
11
11
|
back_to_authentication_methods_list: "Back To Authentication Methods List"
|
12
12
|
edit_social_method: "Editing Social Authentication Method"
|
13
|
+
environment: "Environment"
|
13
14
|
new_social_method: "New Authentication Method"
|
14
15
|
no_authentication_methods_found: "No Authentication Methods Found"
|
15
16
|
one_more_step: 'One more step to complete your registration from %{kind}'
|
data/config/locales/es-MX.yml
CHANGED
@@ -1,17 +1,20 @@
|
|
1
1
|
---
|
2
2
|
es-MX:
|
3
|
+
authentications:
|
4
|
+
spree:
|
5
|
+
destroy: Método de autenticación eliminado
|
3
6
|
devise:
|
4
7
|
omniauth_callbacks:
|
5
|
-
success: "Estás sesión con tu cuenta de %{kind}."
|
8
|
+
success: "Estás en sesión con tu cuenta de %{kind}."
|
6
9
|
spree:
|
7
10
|
user_was_not_valid: "El usuario no fue válido."
|
8
11
|
add_another_service: 'Añadir otro servicio para inicio de sesión:'
|
9
12
|
authentications:
|
10
|
-
destroy: 'Método de autenticación
|
13
|
+
destroy: 'Método de autenticación eliminado exitosamente.'
|
11
14
|
back_to_authentication_methods_list: "Volver a la lista de métodos de autenticación"
|
12
15
|
edit_social_method: 'Editando metodo de autenticación'
|
13
16
|
new_social_method: 'Nuevo método de autenticación'
|
14
|
-
no_authentication_methods_found: "No se encuentran
|
17
|
+
no_authentication_methods_found: "No se encuentran ningún método de autenticación"
|
15
18
|
one_more_step: 'Un paso más para completar tu registro desde %{kind}'
|
16
19
|
remove_authentication_option_confirmation: '¿Está seguro que quiere eliminar este método de autenticación?'
|
17
20
|
sign_into_account: 'Puedes iniciar sesión usando:'
|
@@ -22,5 +25,6 @@ es-MX:
|
|
22
25
|
social_authentication_methods_description: 'Configurar métodos de autenticación de OAuth'
|
23
26
|
social_provider: 'Proveedor social'
|
24
27
|
please_confirm_your_email: 'Por favor confirme su email para continuar'
|
25
|
-
sign_in_with: '
|
28
|
+
sign_in_with: 'Autenticado con %{provider}'
|
26
29
|
you_have_signed_in_with_these_services: "Has iniciado sesión con estos servicios"
|
30
|
+
environment: Ambiente
|
@@ -0,0 +1,30 @@
|
|
1
|
+
---
|
2
|
+
es:
|
3
|
+
authentications:
|
4
|
+
spree:
|
5
|
+
destroy: Método de autenticación eliminado
|
6
|
+
devise:
|
7
|
+
omniauth_callbacks:
|
8
|
+
success: "Estás en sesión con tu cuenta de %{kind}."
|
9
|
+
spree:
|
10
|
+
user_was_not_valid: "El usuario no fue válido."
|
11
|
+
add_another_service: 'Añadir otro servicio para inicio de sesión:'
|
12
|
+
authentications:
|
13
|
+
destroy: 'Método de autenticación eliminado exitosamente.'
|
14
|
+
back_to_authentication_methods_list: "Volver a la lista de métodos de autenticación"
|
15
|
+
edit_social_method: 'Editando metodo de autenticación'
|
16
|
+
new_social_method: 'Nuevo método de autenticación'
|
17
|
+
no_authentication_methods_found: "No se encuentran ningún método de autenticación"
|
18
|
+
one_more_step: 'Un paso más para completar tu registro desde %{kind}'
|
19
|
+
remove_authentication_option_confirmation: '¿Está seguro que quiere eliminar este método de autenticación?'
|
20
|
+
sign_into_account: 'Puedes iniciar sesión usando:'
|
21
|
+
sign_in_through_one_of_these_services: 'Iniciar sesión a través de uno de estos servicios:'
|
22
|
+
social_api_key: 'API Clave'
|
23
|
+
social_api_secret: 'API Secreto'
|
24
|
+
social_authentication_methods: 'Métodos de autenticación'
|
25
|
+
social_authentication_methods_description: 'Configurar métodos de autenticación de OAuth'
|
26
|
+
social_provider: 'Proveedor social'
|
27
|
+
please_confirm_your_email: 'Por favor confirme su email para continuar'
|
28
|
+
sign_in_with: 'Autenticado con %{provider}'
|
29
|
+
you_have_signed_in_with_these_services: "Has iniciado sesión con estos servicios"
|
30
|
+
environment: Ambiente
|
@@ -0,0 +1,26 @@
|
|
1
|
+
---
|
2
|
+
it:
|
3
|
+
devise:
|
4
|
+
omniauth_callbacks:
|
5
|
+
success: "Sei ora loggato con il tuo account di tipo %{kind}."
|
6
|
+
spree:
|
7
|
+
user_was_not_valid: L'utente non è valido
|
8
|
+
add_another_service: "Aggiungi un servizio per il log-in:"
|
9
|
+
authentications:
|
10
|
+
destroy: 'Metodo di autenticazione cancellato con successo.'
|
11
|
+
back_to_authentication_methods_list: "Torna alla lista dei metodi di autenticazione"
|
12
|
+
edit_social_method: "Modifica metodo di autenticazione social"
|
13
|
+
new_social_method: "Nuovo metodo di autenticazione"
|
14
|
+
no_authentication_methods_found: "Nessun metodo di autenticazione trovato"
|
15
|
+
one_more_step: 'Un altro passo per completare il processo di autenticazione %{kind}'
|
16
|
+
remove_authentication_option_confirmation: "Sei sicuro di voler cancellare questo metodo di autenticazione?"
|
17
|
+
sign_into_account: "Puoi fare log-in utilizzando:"
|
18
|
+
sign_in_through_one_of_these_services: "Entra con uno di questi servizi:"
|
19
|
+
social_api_key: "API Key"
|
20
|
+
social_api_secret: "API Secret"
|
21
|
+
social_authentication_methods: "Metodi di autenticazione social"
|
22
|
+
social_authentication_methods_description: "Setup metodi di autenticazione OAuth"
|
23
|
+
social_provider: "Social Provider"
|
24
|
+
please_confirm_your_email: "Per favore, conferma il tuo indirizzo e-mail per continuare."
|
25
|
+
sign_in_with: "Login con %{provider}"
|
26
|
+
you_have_signed_in_with_these_services: "Hai fatto log-in con questi servizi"
|
data/config/routes.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
Spree::Core::Engine.routes.draw do
|
2
4
|
devise_for :spree_user,
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
5
|
+
class_name: Spree.user_class,
|
6
|
+
only: [:omniauth_callbacks],
|
7
|
+
controllers: { omniauth_callbacks: 'spree/omniauth_callbacks' },
|
8
|
+
path: Spree::SocialConfig[:path_prefix]
|
7
9
|
resources :user_authentications
|
8
10
|
|
9
11
|
get 'account' => 'users#show', as: 'user_root'
|
@@ -1,22 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module SolidusSocial
|
2
4
|
module Generators
|
3
5
|
class InstallGenerator < Rails::Generators::Base
|
6
|
+
source_root "#{__dir__}/templates"
|
7
|
+
|
4
8
|
class_option :auto_run_migrations, type: :boolean, default: false
|
5
9
|
|
6
10
|
def add_stylesheets
|
7
|
-
inject_into_file 'vendor/assets/stylesheets/spree/frontend/all.css', " *= require spree/frontend/solidus_social\n", before:
|
11
|
+
inject_into_file 'vendor/assets/stylesheets/spree/frontend/all.css', " *= require spree/frontend/solidus_social\n", before: %r{\*/}, verbose: true
|
8
12
|
end
|
9
13
|
|
10
14
|
def add_migrations
|
11
|
-
run '
|
15
|
+
run 'bin/rails railties:install:migrations FROM=solidus_social'
|
16
|
+
end
|
17
|
+
|
18
|
+
def copy_initializer
|
19
|
+
template "config/initializers/solidus_social.rb"
|
12
20
|
end
|
13
21
|
|
14
22
|
def run_migrations
|
15
|
-
run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask
|
23
|
+
run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask('Would you like to run the migrations now? [Y/n]'))
|
16
24
|
if run_migrations
|
17
|
-
run '
|
25
|
+
run 'bin/rails db:migrate'
|
18
26
|
else
|
19
|
-
puts 'Skipping
|
27
|
+
puts 'Skipping bin/rails db:migrate, don\'t forget to run it!' # rubocop:disable Rails/Output
|
20
28
|
end
|
21
29
|
end
|
22
30
|
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
Spree::SocialConfig.configure do |config|
|
4
|
+
config.use_static_preferences!
|
5
|
+
|
6
|
+
# Configure the Path prefix for OAuth paths
|
7
|
+
# The default is /user/auth/:provider
|
8
|
+
#
|
9
|
+
# for /member/auth/:provider
|
10
|
+
# config.path_prefix = 'member'
|
11
|
+
# for /profile/auth/:provider
|
12
|
+
# config.path_prefix = 'profile'
|
13
|
+
# for /auth/:provider
|
14
|
+
# config.path_prefix = ''
|
15
|
+
|
16
|
+
config.providers = {
|
17
|
+
facebook: {
|
18
|
+
api_key: ENV['FACEBOOK_API_KEY'],
|
19
|
+
api_secret: ENV['FACEBOOK_API_SECRET'],
|
20
|
+
},
|
21
|
+
twitter: {
|
22
|
+
api_key: ENV['TWITTER_API_KEY'],
|
23
|
+
api_secret: ENV['TWITTER_API_SECRET'],
|
24
|
+
},
|
25
|
+
github: {
|
26
|
+
api_key: ENV['GITHUB_API_KEY'],
|
27
|
+
api_secret: ENV['GITHUB_API_SECRET'],
|
28
|
+
},
|
29
|
+
google_oauth2: {
|
30
|
+
api_key: ENV['GOOGLE_OAUTH2_API_KEY'],
|
31
|
+
api_secret: ENV['GOOGLE_OAUTH2_API_SECRET'],
|
32
|
+
},
|
33
|
+
amazon: {
|
34
|
+
api_key: ENV['AMAZON_API_KEY'],
|
35
|
+
api_secret: ENV['AMAZON_API_SECRET'],
|
36
|
+
}
|
37
|
+
}
|
38
|
+
end
|
39
|
+
|
40
|
+
SolidusSocial.init_providers
|
41
|
+
|
42
|
+
OmniAuth.config.logger = Logger.new(STDOUT)
|
43
|
+
OmniAuth.logger.progname = 'omniauth'
|
44
|
+
|
45
|
+
OmniAuth.config.on_failure = proc do |env|
|
46
|
+
env['devise.mapping'] = Devise.mappings[Spree.user_class.table_name.singularize.to_sym]
|
47
|
+
controller_name = ActiveSupport::Inflector.camelize(env['devise.mapping'].controllers[:omniauth_callbacks])
|
48
|
+
controller_klass = ActiveSupport::Inflector.constantize("#{controller_name}Controller")
|
49
|
+
controller_klass.action(:failure).call(env)
|
50
|
+
end
|