solidus_social 1.4.0 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a86b6cfe4109e24c01c128b99b42a23c5387001a642acbdb4ae78d0efbf5e108
4
- data.tar.gz: 116bca0155aa00db87caac0c00a59bbc2139729e2addd378d7159641ba424613
3
+ metadata.gz: 8f6748bb52dec9c0adf020256d086ea0d55190ed7922d3a6d2def8061763ef5f
4
+ data.tar.gz: 13ea181f254b90bbbdf1c0c100e738cc28a1621f40a3843cd1ca929877f59cee
5
5
  SHA512:
6
- metadata.gz: 3d37b9986abcee5ddd8dd82c003f92b5a497ccbe36c619268f20fc390db9375dd88a05a4536942418afc4193e147fd82028b136d4578cd8888157daa4ea5ce7c
7
- data.tar.gz: 737587a8380670d75146924a52a3794bf628679e6b1701129b10f88fbace10259920b5654b9108f7ba0859a739f529d2c5249afc5e91941cd6016b7ccfc6708b
6
+ metadata.gz: d1c34977fa94f9bfed99c58ab509f891fe2e3b47c10a8ac1a8acce57fdd235c615428a475d5d0c8083828887ca53fd5fdd4bc4341b1b40a47e8af5358b9d52e5
7
+ data.tar.gz: 4a8f38b3f9ec00f1c742425d25d6004586aeca3f7577d971cd3cf107fa6e534b6a466788771571824828b951024dfded8d55fddff43de7e22cd00b45853d384d
data/.circleci/config.yml CHANGED
@@ -8,28 +8,55 @@ orbs:
8
8
  solidusio_extensions: solidusio/extensions@volatile
9
9
 
10
10
  jobs:
11
- run-specs-with-postgres:
12
- executor: solidusio_extensions/postgres
11
+ run-specs:
12
+ parameters:
13
+ solidus:
14
+ type: string
15
+ default: main
16
+ db:
17
+ type: string
18
+ default: "postgres"
19
+ ruby:
20
+ type: string
21
+ default: "3.2"
22
+ executor:
23
+ name: solidusio_extensions/<< parameters.db >>
24
+ ruby_version: << parameters.ruby >>
13
25
  steps:
14
- - solidusio_extensions/run-tests
15
- run-specs-with-mysql:
16
- executor: solidusio_extensions/mysql
17
- steps:
18
- - solidusio_extensions/run-tests
26
+ - checkout
27
+ - solidusio_extensions/run-tests-solidus-<< parameters.solidus >>
19
28
 
20
29
  workflows:
21
30
  "Run specs on supported Solidus versions":
22
31
  jobs:
23
- - run-specs-with-postgres
24
- - run-specs-with-mysql
25
- "Weekly run specs against master":
32
+ - run-specs:
33
+ name: &name "run-specs-solidus-<< matrix.solidus >>-ruby-<< matrix.ruby >>-db-<< matrix.db >>"
34
+ matrix:
35
+ parameters: { solidus: ["main"], ruby: ["3.2"], db: ["postgres"] }
36
+ - run-specs:
37
+ name: *name
38
+ matrix:
39
+ parameters: { solidus: ["current"], ruby: ["3.1"], db: ["mysql"] }
40
+ - run-specs:
41
+ name: *name
42
+ matrix:
43
+ parameters: { solidus: ["older"], ruby: ["3.0"], db: ["sqlite"] }
44
+
45
+ "Weekly run specs against main":
26
46
  triggers:
27
47
  - schedule:
28
48
  cron: "0 0 * * 4" # every Thursday
29
49
  filters:
30
50
  branches:
31
51
  only:
32
- - master
52
+ - main
33
53
  jobs:
34
- - run-specs-with-postgres
35
- - run-specs-with-mysql
54
+ - run-specs:
55
+ name: *name
56
+ matrix:
57
+ parameters: { solidus: ["main"], ruby: ["3.2"], db: ["postgres"] }
58
+ - run-specs:
59
+ name: *name
60
+ matrix:
61
+ parameters: { solidus: ["current"], ruby: ["3.1"], db: ["mysql"] }
62
+
@@ -0,0 +1,7 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: bundler
4
+ directory: "/"
5
+ schedule:
6
+ interval: daily
7
+ open-pull-requests-limit: 10
data/CHANGELOG.md CHANGED
@@ -1,35 +1 @@
1
- ## Unreleased
2
-
3
- ## v1.3.0
4
-
5
- - Migrated factories from FactoryGirl to FactoryBot
6
- - Add support for Solidus 2.4+
7
- - Reduced compatible versions of `solidus_core` to 2.x
8
- - Removed the deprecated `icon:` argument from admin buttons
9
- - Fixed an issue when using Safari to authenticate
10
- - `Spree::UserRegistrationsController` and `Spree.user_class` are now decorated by
11
- prepending modules in the `SolidusSocial::Spree` namespace instead of using `class_eval`
12
- - Development of the extension is not relying on `solidus_dev_support` and CircleCI
13
- - Moved the Facebook strategy patch to it's own prepended module
14
-
15
- ## v1.2.0
16
-
17
- - Switched to using the install generator to import the solidus social
18
- initializer into apps. **Please run `bin/rails generate solidus_social:install`
19
- in order to upgrade.**
20
- - Removed the `SolidusSocial::OAUTH_PROVIDERS` constant in favour of
21
- the `Spree::AuthenticationMethod.providers_options` class
22
- method. This is populated using the `Spree::SocialConfig#providers` Hash.
23
- - Added support for Rails 5.1.
24
- - Added Italian translations
25
-
26
- ## v1.1.0
27
-
28
- - Added support for Solidus 2/Rails 5
29
- - Bugfixes
30
-
31
- ## v1.0.0
32
-
33
- - Renamed SpreeSocial to SolidusSocial
34
- - Relaxed versions to support solidus 1.0+
35
- - Port of https://github.com/DynamoMTL/spree_social's solidus branch
1
+ See https://github.com/solidusio-contrib/solidus_social/releases or [OLD_CHANGELOG.md](OLD_CHANGELOG.md) for older versions.
data/Gemfile CHANGED
@@ -3,9 +3,18 @@
3
3
  source 'https://rubygems.org'
4
4
  git_source(:github) { |repo| "https://github.com/#{repo}.git" }
5
5
 
6
- branch = ENV.fetch('SOLIDUS_BRANCH', 'master')
6
+ branch = ENV.fetch('SOLIDUS_BRANCH', 'main')
7
7
  gem 'solidus', github: 'solidusio/solidus', branch: branch
8
8
 
9
+ # The solidus_frontend gem has been pulled out since v3.2
10
+ if branch >= 'v3.2'
11
+ gem 'solidus_frontend'
12
+ elsif branch == 'main'
13
+ gem 'solidus_frontend', github: 'solidusio/solidus_frontend'
14
+ else
15
+ gem 'solidus_frontend', github: 'solidusio/solidus', branch: branch
16
+ end
17
+
9
18
  # Needed to help Bundler figure out how to resolve dependencies,
10
19
  # otherwise it takes forever to resolve them.
11
20
  # See https://github.com/bundler/bundler/issues/6677
data/OLD_CHANGELOG.md ADDED
@@ -0,0 +1,35 @@
1
+ ## Unreleased
2
+
3
+ ## v1.3.0
4
+
5
+ - Migrated factories from FactoryGirl to FactoryBot
6
+ - Add support for Solidus 2.4+
7
+ - Reduced compatible versions of `solidus_core` to 2.x
8
+ - Removed the deprecated `icon:` argument from admin buttons
9
+ - Fixed an issue when using Safari to authenticate
10
+ - `Spree::UserRegistrationsController` and `Spree.user_class` are now decorated by
11
+ prepending modules in the `SolidusSocial::Spree` namespace instead of using `class_eval`
12
+ - Development of the extension is not relying on `solidus_dev_support` and CircleCI
13
+ - Moved the Facebook strategy patch to it's own prepended module
14
+
15
+ ## v1.2.0
16
+
17
+ - Switched to using the install generator to import the solidus social
18
+ initializer into apps. **Please run `bin/rails generate solidus_social:install`
19
+ in order to upgrade.**
20
+ - Removed the `SolidusSocial::OAUTH_PROVIDERS` constant in favour of
21
+ the `Spree::AuthenticationMethod.providers_options` class
22
+ method. This is populated using the `Spree::SocialConfig#providers` Hash.
23
+ - Added support for Rails 5.1.
24
+ - Added Italian translations
25
+
26
+ ## v1.1.0
27
+
28
+ - Added support for Solidus 2/Rails 5
29
+ - Bugfixes
30
+
31
+ ## v1.0.0
32
+
33
+ - Renamed SpreeSocial to SolidusSocial
34
+ - Relaxed versions to support solidus 1.0+
35
+ - Port of https://github.com/DynamoMTL/spree_social's solidus branch
data/README.md CHANGED
@@ -5,8 +5,8 @@ SolidusSocial
5
5
  [![Code Climate](https://codeclimate.com/github/solidusio-contrib/solidus_social/badges/gpa.svg)](https://codeclimate.com/github/solidusio-contrib/solidus_social)
6
6
 
7
7
  Social login support for Solidus. Solidus Social handles authorization, account
8
- creation and association through third-party services. Currently Twitter,
9
- Facebook, Github, Google OAuth2, and Amazon are available out of the box.
8
+ creation and association through third-party services.
9
+ Currently Facebook, Github and Google OAuth2 are available out of the box.
10
10
 
11
11
  Installation
12
12
  ------------
@@ -44,7 +44,7 @@ Click "New Authentication Method" and choose one of your configured providers.
44
44
  Registering Your Application
45
45
  ----------------------------
46
46
 
47
- Facebook, Twitter, Github, Google OAuth2, and Amazon are supported out of the
47
+ Facebook, Github and Google OAuth2 are supported out of the
48
48
  box but, you will need to register your application with each of the sites you
49
49
  want to use.
50
50
 
@@ -64,20 +64,6 @@ Make sure you specifity the right IP address.
64
64
  `http://your-site.com` for production
65
65
  - Site domain: `yourhostname.local` and `your-site.com` respectively
66
66
 
67
- ### Twitter
68
-
69
- [Twitter / Application Management / Create an application][3]
70
-
71
- 1. Fill in the name and description.
72
- 2. Fill in the rest of the details:
73
- - Application Website: `http://yourhostname.local:3000` for development and
74
- `http://your-site.com` for production
75
- - Application Type: "Browser"
76
- - Callback URL: `http://yourhostname.local:3000` for development and
77
- `http://your-site.com` for production
78
- - Default Access Type: "Read & Write"
79
- 6. Save the application.
80
-
81
67
  ### Github
82
68
 
83
69
  [Github / Applications / Register a new OAuth application][4]
@@ -90,18 +76,6 @@ Make sure you specifity the right IP address.
90
76
  `http://your-site.com` for production
91
77
  4. Click Create.
92
78
 
93
- ### Amazon
94
-
95
- [Amazon / App Console / Register a new OAuth application][10]
96
-
97
- 1. Register New Application.
98
- 2. Name the Application, provide description and URL for Privacy Policy.
99
- 3. Click Save.
100
- 4. Add Your site under Web Settings > Allowed Return URLs (example:
101
- `http://localhost:3000/users/auth/amazon/callback`)
102
-
103
- > The app console is available at [https://login.amazon.com/manageApps](https://login.amazon.com/manageApps)
104
-
105
79
  ### Google OAuth2
106
80
  [Google / APIs / Credentials/ Create Credential](https://console.developers.google.com/)
107
81
 
@@ -140,11 +114,40 @@ strategy][12] for them. (If there isn't, you can [write one][13].)
140
114
  your LinkedIn link.
141
115
  - Include in your CSS a definition for `.icon-spree-linkedin-circled` and an
142
116
  embedded icon font for LinkedIn from [Fontello][14] (the way existing
143
- icons for Facebook, Twitter, etc are implemented). You can also override
117
+ icons for Facebook etc are implemented). You can also override
144
118
  CSS classes for other providers, `.icon-spree-<provider>-circled`, to use
145
119
  different font icons or classic background images, without having to
146
120
  override views.
147
121
 
122
+ #### Apple Id Example
123
+
124
+ 1. Add `gem "omniauth-apple"` to your Gemfile and run `bundle install`.
125
+ 2. In `config/initializers/solidus_social.rb` add and initialize a new provider
126
+ for SolidusSocial:
127
+
128
+ ```ruby
129
+
130
+ config.providers = {
131
+ apple: {
132
+ icon: 'fa-apple',
133
+ title: 'Apple'
134
+ },
135
+ # More providers here
136
+ ```
137
+ add its configuration after `SolidusSocial.init_providers` line:
138
+ ```ruby
139
+
140
+ Devise.setup do |config|
141
+ # The configuration key has to match your omniauth strategy.
142
+ config.omniauth :apple, ENV['APPLE_CLIENT_ID'], '',
143
+ scope: 'email',
144
+ team_id: ENV['APPLE_TEAM_ID'],
145
+ key_id: ENV['APPLE_KEY_ID'],
146
+ pem: ENV['APPLE_PRIVATE_KEY'].gsub('\n', "\n")
147
+ end
148
+ ```
149
+ Notice: APPLE_PRIVATE_KEY should consist from one-line p8-file content, like this `'\n-----BEGIN PRIVATE KEY-----\nsecret\n-----END PRIVATE KEY-----\n'`
150
+
148
151
  Documentation
149
152
  -------------
150
153
 
@@ -188,16 +191,14 @@ Copyright (c) 2014 [John Dyer][7] and [contributors][8], released under the [New
188
191
 
189
192
  [1]: https://github.com/spree/spree
190
193
  [2]: https://developers.facebook.com/apps/?action=create
191
- [3]: https://apps.twitter.com/app/new
192
- [4]: https://github.com/settings/applications/new
193
- [5]: http://www.fsf.org/licensing/essays/free-sw.html
194
- [6]: https://github.com/solidusio-contrib/solidus_social/issues
195
- [7]: https://github.com/LBRapid
196
- [8]: https://github.com/solidusio-contrib/solidus_social/graphs/contributors
197
- [9]: https://github.com/solidusio-contrib/solidus_social/blob/master/LICENSE
198
- [10]: https://login.amazon.com/manageApps
199
- [11]: https://github.com/solidusio-contrib/solidus_social/blob/master/CONTRIBUTING.md
200
- [12]: https://github.com/intridea/omniauth/wiki/List-of-Strategies
201
- [13]: https://github.com/intridea/omniauth/wiki/Strategy-Contribution-Guide
202
- [14]: http://fontello.com/
203
- [15]: http://www.rubydoc.info/github/solidusio-contrib/solidus_social/
194
+ [3]: https://github.com/settings/applications/new
195
+ [4]: http://www.fsf.org/licensing/essays/free-sw.html
196
+ [5]: https://github.com/solidusio-contrib/solidus_social/issues
197
+ [6]: https://github.com/LBRapid
198
+ [7]: https://github.com/solidusio-contrib/solidus_social/graphs/contributors
199
+ [8]: https://github.com/solidusio-contrib/solidus_social/blob/master/LICENSE
200
+ [9]: https://github.com/solidusio-contrib/solidus_social/blob/master/CONTRIBUTING.md
201
+ [10]: https://github.com/intridea/omniauth/wiki/List-of-Strategies
202
+ [11]: https://github.com/intridea/omniauth/wiki/Strategy-Contribution-Guide
203
+ [12]: http://fontello.com/
204
+ [13]: http://www.rubydoc.info/github/solidusio-contrib/solidus_social/
data/Rakefile CHANGED
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'bundler/gem_tasks'
4
+
3
5
  require 'solidus_dev_support/rake_tasks'
4
6
  SolidusDevSupport::RakeTasks.install
5
7
 
@@ -62,7 +62,7 @@ class Spree::OmniauthCallbacksController < Devise::OmniauthCallbacksController
62
62
  end
63
63
 
64
64
  def passthru
65
- render file: "#{Rails.root}/public/404", formats: [:html], status: :not_found, layout: false
65
+ render file: "#{Rails.root}/public/404.html", formats: [:html], status: :not_found, layout: false
66
66
  end
67
67
 
68
68
  def auth_hash
@@ -1,5 +1,5 @@
1
1
  <div data-hook="admin_social_methods_form_fields" class="row">
2
- <div class="alpha five columns">
2
+ <div class="col-4">
3
3
  <div data-hook="environment" class="field">
4
4
  <%= f.field_container :environment do %>
5
5
  <%= label_tag nil, Spree::AuthenticationMethod.human_attribute_name(:environment) %>
@@ -7,7 +7,7 @@
7
7
  <% end %>
8
8
  </div>
9
9
  </div>
10
- <div class="alpha five columns">
10
+ <div class="col-4">
11
11
  <div data-hook="environment" class="field">
12
12
  <%= f.field_container :provider do %>
13
13
  <%= f.label :provider, I18n.t('spree.social_provider') %>
@@ -15,14 +15,12 @@
15
15
  <% end %>
16
16
  </div>
17
17
  </div>
18
- <div class="alpha five columns">
18
+ <div class="col-4">
19
19
  <div data-hook="environment" class="field">
20
20
  <%= f.field_container :active do %>
21
- <span style="padding:0 10px 2px;"><%= f.label :active, I18n.t('spree.active') %></span>
22
- <%= f.radio_button :active, :true %>
23
- <span style="padding:0 2px;"><%= I18n.t('spree.say_yes') %></span>
24
- <%= f.radio_button :active, :false %>
25
- <span style="padding:0 2px"><%= I18n.t('spree.say_no') %></span>
21
+ <%= f.label :active, I18n.t('spree.active') %><br>
22
+ <%= f.radio_button :active, :true %><span style="padding:0 2px;"><%= I18n.t('spree.say_yes') %></span>
23
+ <%= f.radio_button :active, :false %><span style="padding:0 2px"><%= I18n.t('spree.say_no') %></span>
26
24
  <% end %>
27
25
  </div>
28
26
  </div>
@@ -1,13 +1,11 @@
1
1
  <%= render 'spree/admin/shared/configuration_menu' %>
2
2
 
3
+ <% admin_breadcrumb(link_to I18n.t('spree.social_authentication_methods'), spree.admin_authentication_methods_path) %>
4
+
3
5
  <% content_for :page_title do %>
4
6
  <%= I18n.t('spree.edit_social_method') %>
5
7
  <% end %>
6
8
 
7
- <% content_for :page_actions do %>
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
- <% end %>
10
-
11
9
  <%= render 'spree/shared/error_messages', target: @authentication_method %>
12
10
 
13
11
  <%= form_for [:admin, @authentication_method] do |f| %>
@@ -8,7 +8,7 @@
8
8
  <% if can? :manage, Spree::AuthenticationMethod %>
9
9
  <ul class="actions inline-menu">
10
10
  <li>
11
- <%= link_to I18n.t('spree.new_social_method'), new_object_url, id: 'admin_new_slide_link' %>
11
+ <%= link_to I18n.t('spree.new_social_method'), new_object_url, id: 'admin_new_slide_link', class: "btn btn-primary" %>
12
12
  </li>
13
13
  </ul>
14
14
  <% end %>
@@ -29,17 +29,17 @@
29
29
  <th><%= I18n.t('spree.social_api_key') %></th>
30
30
  <th><%= I18n.t('spree.social_api_secret') %></th>
31
31
  <th><%= I18n.t('spree.environment') %></th>
32
- <th><%= I18n.t('spree.active') %></th>
32
+ <th class="align-right"><%= I18n.t('spree.active') %></th>
33
33
  <th data-hook="admin_social_methods_index_header_actions" class="actions"></th>
34
34
  </thead>
35
35
  <tbody>
36
36
  <% @authentication_methods.each do |method|%>
37
37
  <tr id="<%= dom_id method %>" data-hook="admin_trackers_index_rows">
38
- <td class="align-center"><%= method.provider %></td>
39
- <td class="align-center"><%= truncate method.api_key, length: 10 %></td>
40
- <td class="align-center"><%= truncate method.api_secret, length: 10 %></td>
41
- <td class="align-center"><%= method.environment.to_s.titleize %></td>
42
- <td class="align-center"><%= method.active ? I18n.t('spree.yes') : I18n.t('spree.no') %></td>
38
+ <td><%= method.provider %></td>
39
+ <td><%= truncate method.api_key, length: 10 %></td>
40
+ <td><%= truncate method.api_secret, length: 10 %></td>
41
+ <td><%= method.environment.to_s.titleize %></td>
42
+ <td class="align-right"><%= method.active ? I18n.t('spree.say_yes') : I18n.t('spree.say_no') %></td>
43
43
  <td class="actions">
44
44
  <% if can? :manage, Spree::AuthenticationMethod %>
45
45
  <%= link_to_edit method, no_text: true %>
@@ -1,13 +1,11 @@
1
1
  <%= render 'spree/admin/shared/configuration_menu' %>
2
2
 
3
+ <% admin_breadcrumb(link_to I18n.t('spree.social_authentication_methods'), spree.admin_authentication_methods_path) %>
4
+
3
5
  <% content_for :page_title do %>
4
6
  <%= I18n.t('spree.new_social_method') %>
5
7
  <% end %>
6
8
 
7
- <% content_for :page_actions do %>
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
- <% end %>
10
-
11
9
  <%= render 'spree/shared/error_messages', target: @authentication_method %>
12
10
 
13
11
  <%= form_for [:admin, @authentication_method] do |f| %>
@@ -4,8 +4,12 @@
4
4
  <% end %>
5
5
 
6
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 %>
7
+ <% if method.active %>
8
+ <%= form_tag(spree.send("spree_user_#{method.provider}_omniauth_authorize_path", r: rand), method: 'post') do %>
9
+ <%= button_tag(type: 'submit', title: t('spree.sign_in_with', provider: method.provider)) do %>
10
+ <%= content_tag(:i, '', class: "icon-spree-#{method.provider.dasherize}-circled") %>
11
+ <% end %>
12
+ <% end %>
13
+ <% end %>
10
14
  <% end %>
11
15
  </div>
@@ -8,7 +8,6 @@ en:
8
8
  add_another_service: "Add another service to sign in with:"
9
9
  authentications:
10
10
  destroy: 'Successfully destroyed authentication method.'
11
- back_to_authentication_methods_list: "Back To Authentication Methods List"
12
11
  edit_social_method: "Editing Social Authentication Method"
13
12
  environment: "Environment"
14
13
  new_social_method: "New Authentication Method"
@@ -18,10 +18,6 @@ Spree::SocialConfig.configure do |config|
18
18
  api_key: ENV['FACEBOOK_API_KEY'],
19
19
  api_secret: ENV['FACEBOOK_API_SECRET'],
20
20
  },
21
- twitter: {
22
- api_key: ENV['TWITTER_API_KEY'],
23
- api_secret: ENV['TWITTER_API_SECRET'],
24
- },
25
21
  github: {
26
22
  api_key: ENV['GITHUB_API_KEY'],
27
23
  api_secret: ENV['GITHUB_API_SECRET'],
@@ -30,9 +26,9 @@ Spree::SocialConfig.configure do |config|
30
26
  api_key: ENV['GOOGLE_OAUTH2_API_KEY'],
31
27
  api_secret: ENV['GOOGLE_OAUTH2_API_SECRET'],
32
28
  },
33
- amazon: {
34
- api_key: ENV['AMAZON_API_KEY'],
35
- api_secret: ENV['AMAZON_API_SECRET'],
29
+ twitter2: {
30
+ api_key: ENV['TWITTER_API_KEY'],
31
+ api_secret: ENV['TWITTER_API_SECRET']
36
32
  }
37
33
  }
38
34
  end
@@ -44,7 +40,6 @@ OmniAuth.logger.progname = 'omniauth'
44
40
 
45
41
  OmniAuth.config.on_failure = proc do |env|
46
42
  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")
43
+ controller_klass = ActiveSupport::Inflector.constantize("Spree::OmniauthCallbacksController")
49
44
  controller_klass.action(:failure).call(env)
50
45
  end
@@ -1,13 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'omniauth-twitter'
4
3
  require 'omniauth-facebook'
5
4
  require 'omniauth-github'
6
5
  require 'omniauth-google-oauth2'
7
- require 'omniauth-amazon'
6
+ require 'omniauth/twitter2'
7
+ require 'omniauth/rails_csrf_protection'
8
8
  require 'deface'
9
- require 'coffee_script'
10
9
  require 'spree/core'
10
+ require 'solidus_social/social_configuration'
11
11
  require 'solidus_social/facebook_omniauth_strategy_ext'
12
12
 
13
13
  module SolidusSocial
@@ -27,10 +27,6 @@ module SolidusSocial
27
27
  "app/decorators/models/solidus_social/spree/user_decorator.rb"
28
28
  ).to_s
29
29
 
30
- initializer 'solidus_social.environment', before: 'spree.environment' do
31
- ::Spree::SocialConfig = ::Spree::SocialConfiguration.new
32
- end
33
-
34
30
  initializer 'solidus_social.decorate_spree_user' do |app|
35
31
  next unless app.respond_to?(:reloader)
36
32
 
@@ -4,5 +4,7 @@ module Spree
4
4
  class SocialConfiguration < Preferences::Configuration
5
5
  attr_accessor :providers
6
6
  preference :path_prefix, :string, default: 'users'
7
+
8
+ ::Spree::SocialConfig = Spree::SocialConfiguration.new
7
9
  end
8
10
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SolidusSocial
4
- VERSION = '1.4.0'
4
+ VERSION = '1.6.0'
5
5
  end
@@ -31,13 +31,13 @@ Gem::Specification.new do |spec|
31
31
  spec.add_dependency 'deface'
32
32
  spec.add_dependency 'oa-core'
33
33
  spec.add_dependency 'omniauth'
34
- spec.add_dependency 'omniauth-amazon'
35
34
  spec.add_dependency 'omniauth-facebook'
36
35
  spec.add_dependency 'omniauth-github'
37
36
  spec.add_dependency 'omniauth-google-oauth2'
38
- spec.add_dependency 'omniauth-twitter'
37
+ spec.add_dependency 'omniauth-rails_csrf_protection'
38
+ spec.add_dependency 'omniauth-twitter2'
39
39
  spec.add_dependency 'solidus_auth_devise'
40
- spec.add_dependency 'solidus_core', ['>= 2.0.0', '< 4']
40
+ spec.add_dependency 'solidus_core', '>= 2.0.0', '< 5'
41
41
  spec.add_dependency 'solidus_support', '~> 0.5'
42
42
 
43
43
  spec.add_development_dependency 'solidus_dev_support'
@@ -18,17 +18,17 @@ RSpec.describe Spree::OmniauthCallbacksController, type: :controller do
18
18
 
19
19
  it 'redirects properly' do
20
20
  expect(controller).to receive(:redirect_back_or_default)
21
- controller.twitter
21
+ controller.github
22
22
  end
23
23
 
24
24
  it 'displays an error message' do
25
- controller.twitter
25
+ controller.github
26
26
  expect(flash[:error]).not_to be_blank
27
27
  end
28
28
 
29
29
  it 'does not attempt authentication' do
30
30
  expect(controller).not_to receive(:sign_in_and_redirect)
31
- controller.twitter
31
+ controller.github
32
32
  end
33
33
  end
34
34
 
@@ -37,7 +37,7 @@ RSpec.describe Spree::OmniauthCallbacksController, type: :controller do
37
37
 
38
38
  it 'associates the order with the user' do
39
39
  expect(order).to receive(:associate_user!).with(user)
40
- controller.twitter
40
+ controller.github
41
41
  end
42
42
  end
43
43
 
@@ -64,17 +64,17 @@ RSpec.describe Spree::OmniauthCallbacksController, type: :controller do
64
64
 
65
65
  it 'does not need to create the user_authentication' do
66
66
  expect(user.user_authentications).not_to receive(:create!)
67
- controller.twitter
67
+ controller.github
68
68
  end
69
69
 
70
70
  it 'sets the flash notice' do
71
- controller.twitter
71
+ controller.github
72
72
  expect(flash[:notice]).not_to be_blank
73
73
  end
74
74
 
75
75
  it 'authenticates as that user' do
76
76
  expect(controller).to receive(:sign_in_and_redirect)
77
- controller.twitter
77
+ controller.github
78
78
  end
79
79
  end
80
80
 
@@ -86,17 +86,17 @@ RSpec.describe Spree::OmniauthCallbacksController, type: :controller do
86
86
  it 'creates a new user_authentication' do
87
87
  expect(user).to receive(:apply_omniauth)
88
88
  expect(user).to receive(:save!)
89
- controller.twitter
89
+ controller.github
90
90
  end
91
91
 
92
92
  it 'sets the flash notice' do
93
- controller.twitter
93
+ controller.github
94
94
  expect(flash[:notice]).not_to be_blank
95
95
  end
96
96
 
97
97
  it 'redirects properly' do
98
98
  expect(controller).to receive(:redirect_back_or_default)
99
- controller.twitter
99
+ controller.github
100
100
  end
101
101
 
102
102
  it_behaves_like 'associate_order'
@@ -119,17 +119,17 @@ RSpec.describe Spree::OmniauthCallbacksController, type: :controller do
119
119
 
120
120
  it 'does not need to create the user_authentication' do
121
121
  expect(user.user_authentications).not_to receive(:create!)
122
- controller.twitter
122
+ controller.github
123
123
  end
124
124
 
125
125
  it 'does not create a new user account' do
126
126
  expect(Spree::User).not_to receive :new
127
- controller.twitter
127
+ controller.github
128
128
  end
129
129
 
130
130
  it 'authenticates as that user' do
131
131
  expect(controller).to receive(:sign_in_and_redirect).with(:spree_user, user)
132
- controller.twitter
132
+ controller.github
133
133
  end
134
134
  end
135
135
 
@@ -144,7 +144,7 @@ RSpec.describe Spree::OmniauthCallbacksController, type: :controller do
144
144
  context "email doesn't belongs to anyone" do
145
145
  it 'creates a new user' do
146
146
  expect(controller).to receive(:sign_in_and_redirect)
147
- expect { controller.twitter }.to change(Spree::User, :count).by(1)
147
+ expect { controller.github }.to change(Spree::User, :count).by(1)
148
148
  end
149
149
 
150
150
  context 'when `Spree.user_class` has changed' do
@@ -170,7 +170,7 @@ RSpec.describe Spree::OmniauthCallbacksController, type: :controller do
170
170
  expect(Spree::User).not_to receive :new
171
171
  expect_any_instance_of(Spree::User).not_to receive :save
172
172
 
173
- expect { controller.twitter }
173
+ expect { controller.github }
174
174
  .to change(Spree::LegacyUser, :count).by(1)
175
175
  end
176
176
  end
@@ -180,11 +180,11 @@ RSpec.describe Spree::OmniauthCallbacksController, type: :controller do
180
180
  before { @user = create(:user, email: 'spree@gmail.com') }
181
181
 
182
182
  it 'does not create new user' do
183
- expect { controller.twitter }.not_to change(Spree::User, :count)
183
+ expect { controller.github }.not_to change(Spree::User, :count)
184
184
  end
185
185
 
186
186
  it 'assigns authentication to existing user' do
187
- expect { controller.twitter }.to change(@user.user_authentications, :count).by(1)
187
+ expect { controller.github }.to change(@user.user_authentications, :count).by(1)
188
188
  end
189
189
  end
190
190
  end
@@ -19,10 +19,9 @@ RSpec.describe 'Admin Authentication Methods', :js do
19
19
  end
20
20
 
21
21
  it 'can create new' do
22
- expect(page).to have_text /NO AUTHENTICATION METHODS FOUND, ADD ONE!/i
22
+ expect(page).to have_text 'No Authentication Methods Found, Add One!'
23
23
 
24
24
  click_link 'New Authentication Method'
25
- expect(page).to have_text /BACK TO AUTHENTICATION METHODS LIST/i
26
25
  select2 'Test', from: 'Environment'
27
26
  select2 'Github', from: 'Social Provider'
28
27
 
@@ -53,18 +53,122 @@ RSpec.describe 'Signing in using Omniauth', :js do
53
53
  end
54
54
  end
55
55
 
56
+ context 'github' do
57
+ before do
58
+ Spree::AuthenticationMethod.create!(
59
+ provider: 'github',
60
+ api_key: 'fake',
61
+ api_secret: 'fake',
62
+ environment: Rails.env,
63
+ active: true
64
+ )
65
+ OmniAuth.config.mock_auth[:github] = {
66
+ 'provider' => 'github',
67
+ 'uid' => '123545',
68
+ 'info' => {
69
+ 'name' => 'mockuser',
70
+ 'email' => 'mockuser@example.com',
71
+ 'image' => 'mock_user_thumbnail_url'
72
+ },
73
+ 'credentials' => {
74
+ 'token' => 'mock_token',
75
+ 'secret' => 'mock_secret'
76
+ }
77
+ }
78
+ end
79
+
80
+ it 'going to sign in' do
81
+ visit spree.login_path
82
+ click_on 'Login with github'
83
+ expect(page).to have_text 'You are now signed in with your github account.'
84
+ click_link 'Logout'
85
+ click_link 'Login'
86
+ click_on 'Login with github'
87
+ expect(page).to have_text 'You are now signed in with your github account.'
88
+ end
89
+
90
+ # Regression test for #91
91
+ it "attempting to view 'My Account' works" do
92
+ visit spree.login_path
93
+ click_on 'Login with github'
94
+ expect(page).to have_text 'You are now signed in with your github account.'
95
+ click_link 'My Account'
96
+ expect(page).to have_text 'My Account'
97
+ end
98
+
99
+ it "view 'My Account'" do
100
+ visit spree.login_path
101
+ click_on 'Login with github'
102
+ expect(page).to have_text 'You are now signed in with your github account.'
103
+ click_link 'My Account'
104
+ expect(page).not_to have_selector 'div#social-signin-links'
105
+ end
106
+ end
107
+
108
+ context 'google_oauth2' do
109
+ before do
110
+ Spree::AuthenticationMethod.create!(
111
+ provider: 'google_oauth2',
112
+ api_key: 'fake',
113
+ api_secret: 'fake',
114
+ environment: Rails.env,
115
+ active: true
116
+ )
117
+ OmniAuth.config.mock_auth[:google_oauth2] = {
118
+ 'provider' => 'google_oauth2',
119
+ 'uid' => '123545',
120
+ 'info' => {
121
+ 'name' => 'mockuser',
122
+ 'email' => 'mockuser@example.com',
123
+ 'image' => 'mock_user_thumbnail_url'
124
+ },
125
+ 'credentials' => {
126
+ 'token' => 'mock_token',
127
+ 'secret' => 'mock_secret'
128
+ }
129
+ }
130
+ end
131
+
132
+ it 'going to sign in' do
133
+ visit spree.login_path
134
+ click_on 'Login with google_oauth2'
135
+ expect(page).to have_text 'You are now signed in with your google_oauth2 account.'
136
+ click_link 'Logout'
137
+ click_link 'Login'
138
+ click_on 'Login with google_oauth2'
139
+ expect(page).to have_text 'You are now signed in with your google_oauth2 account.'
140
+ end
141
+
142
+ # Regression test for #91
143
+ it "attempting to view 'My Account' works" do
144
+ visit spree.login_path
145
+ click_on 'Login with google_oauth2'
146
+ expect(page).to have_text 'You are now signed in with your google_oauth2 account.'
147
+ click_link 'My Account'
148
+ expect(page).to have_text 'My Account'
149
+ end
150
+
151
+ it "view 'My Account'" do
152
+ visit spree.login_path
153
+ click_on 'Login with google_oauth2'
154
+ expect(page).to have_text 'You are now signed in with your google_oauth2 account.'
155
+ click_link 'My Account'
156
+ expect(page).not_to have_selector 'div#social-signin-links'
157
+ end
158
+ end
159
+
56
160
  context 'twitter' do
57
161
  before do
58
162
  Spree::AuthenticationMethod.create!(
59
- provider: 'twitter',
163
+ provider: 'twitter2',
60
164
  api_key: 'fake',
61
165
  api_secret: 'fake',
62
166
  environment: Rails.env,
63
167
  active: true
64
168
  )
65
169
  OmniAuth.config.test_mode = true
66
- OmniAuth.config.mock_auth[:twitter] = {
67
- 'provider' => 'twitter',
170
+ OmniAuth.config.mock_auth[:twitter2] = {
171
+ 'provider' => 'twitter2',
68
172
  'uid' => '123545',
69
173
  'info' => {
70
174
  'name' => 'mockuser',
@@ -5,7 +5,8 @@ RSpec.describe Spree::SocialConfig do
5
5
  expect { subject.path_prefix = 'customer' }.not_to change(Spree::Preference, :count)
6
6
  end
7
7
 
8
- it "holds configuration for the five default providers" do
9
- expect(subject.providers.keys).to match_array([:amazon, :facebook, :github, :google_oauth2, :twitter])
8
+ it "holds configuration for default providers" do
9
+ providers = %i[facebook github google_oauth2 twitter2]
10
+ expect(subject.providers.keys).to match_array(providers)
10
11
  end
11
12
  end
@@ -6,11 +6,10 @@ RSpec.describe Spree::AuthenticationMethod do
6
6
 
7
7
  let(:expected_provider_options) do
8
8
  [
9
- %w(Amazon amazon),
10
9
  %w(Facebook facebook),
11
- %w(Twitter twitter),
12
10
  %w(Github github),
13
- %w(Google google_oauth2)
11
+ %w(Google google_oauth2),
12
+ %w(Twitter2 twitter2)
14
13
  ]
15
14
  end
16
15
 
data/spec/spec_helper.rb CHANGED
@@ -11,13 +11,12 @@ require File.expand_path('dummy/config/environment.rb', __dir__)
11
11
  # Requires factories and other useful helpers defined in spree_core.
12
12
  require 'solidus_dev_support/rspec/feature_helper'
13
13
 
14
+ SolidusDevSupport::TestingSupport::Factories.load_for(SolidusSocial::Engine, Spree::Auth::Engine)
15
+
14
16
  # Requires supporting ruby files with custom matchers and macros, etc,
15
17
  # in spec/support/ and its subdirectories.
16
18
  Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |f| require f }
17
19
 
18
- # Requires factories defined in lib/solidus_social/factories.rb
19
- require 'solidus_social/factories'
20
-
21
20
  RSpec.configure do |config|
22
21
  config.infer_spec_type_from_file_location!
23
22
  config.use_transactional_fixtures = false
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solidus_social
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Dyer
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-05-31 00:00:00.000000000 Z
11
+ date: 2023-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: deface
@@ -53,7 +53,7 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: omniauth-amazon
56
+ name: omniauth-facebook
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
@@ -67,7 +67,7 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: omniauth-facebook
70
+ name: omniauth-github
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
@@ -81,7 +81,7 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: omniauth-github
84
+ name: omniauth-google-oauth2
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - ">="
@@ -95,7 +95,7 @@ dependencies:
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
- name: omniauth-google-oauth2
98
+ name: omniauth-rails_csrf_protection
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - ">="
@@ -109,7 +109,7 @@ dependencies:
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
- name: omniauth-twitter
112
+ name: omniauth-twitter2
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - ">="
@@ -145,7 +145,7 @@ dependencies:
145
145
  version: 2.0.0
146
146
  - - "<"
147
147
  - !ruby/object:Gem::Version
148
- version: '4'
148
+ version: '5'
149
149
  type: :runtime
150
150
  prerelease: false
151
151
  version_requirements: !ruby/object:Gem::Requirement
@@ -155,7 +155,7 @@ dependencies:
155
155
  version: 2.0.0
156
156
  - - "<"
157
157
  - !ruby/object:Gem::Version
158
- version: '4'
158
+ version: '5'
159
159
  - !ruby/object:Gem::Dependency
160
160
  name: solidus_support
161
161
  requirement: !ruby/object:Gem::Requirement
@@ -192,6 +192,7 @@ extra_rdoc_files: []
192
192
  files:
193
193
  - ".circleci/config.yml"
194
194
  - ".gem_release.yml"
195
+ - ".github/dependabot.yml"
195
196
  - ".gitignore"
196
197
  - ".rspec"
197
198
  - ".rubocop.yml"
@@ -200,6 +201,7 @@ files:
200
201
  - CONTRIBUTING.md
201
202
  - Gemfile
202
203
  - LICENSE
204
+ - OLD_CHANGELOG.md
203
205
  - README.md
204
206
  - Rakefile
205
207
  - app/assets/stylesheets/spree/frontend/fontello.css
@@ -213,7 +215,6 @@ files:
213
215
  - app/decorators/models/solidus_social/spree/user_decorator.rb
214
216
  - app/helpers/spree/omniauth_callbacks_helper.rb
215
217
  - app/models/spree/authentication_method.rb
216
- - app/models/spree/social_configuration.rb
217
218
  - app/models/spree/user_authentication.rb
218
219
  - app/overrides/add_authentications_to_account_summary.rb
219
220
  - app/overrides/admin_configuration_decorator.rb
@@ -249,6 +250,7 @@ files:
249
250
  - lib/solidus_social/engine.rb
250
251
  - lib/solidus_social/facebook_omniauth_strategy_ext.rb
251
252
  - lib/solidus_social/factories.rb
253
+ - lib/solidus_social/social_configuration.rb
252
254
  - lib/solidus_social/version.rb
253
255
  - solidus_social.gemspec
254
256
  - spec/controllers/spree/omniauth_callbacks_controller_spec.rb
@@ -284,7 +286,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
284
286
  - !ruby/object:Gem::Version
285
287
  version: '0'
286
288
  requirements: []
287
- rubygems_version: 3.1.4
289
+ rubygems_version: 3.4.20
288
290
  signing_key:
289
291
  specification_version: 4
290
292
  summary: Adds social network login services (OAuth) to Solidus