workarea-facebook_login 2.1.0

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.
Files changed (67) hide show
  1. checksums.yaml +7 -0
  2. data/.editorconfig +15 -0
  3. data/.github/ISSUE_TEMPLATE/bug_report.md +37 -0
  4. data/.github/ISSUE_TEMPLATE/documentation-request.md +17 -0
  5. data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
  6. data/.github/workflows/ci.yml +56 -0
  7. data/.gitignore +13 -0
  8. data/.jshintrc +31 -0
  9. data/.rubocop.yml +2 -0
  10. data/CHANGELOG.md +74 -0
  11. data/Gemfile +11 -0
  12. data/README.md +13 -0
  13. data/Rakefile +42 -0
  14. data/app/controllers/workarea/storefront/users/facebook_logins_controller.rb +46 -0
  15. data/app/models/workarea/user.decorator +41 -0
  16. data/app/views/workarea/storefront/users/_facebook_login.html.haml +6 -0
  17. data/bin/rails +18 -0
  18. data/config/initializers/appends.rb +4 -0
  19. data/config/initializers/omniauth.rb +1 -0
  20. data/config/locales/en.yml +14 -0
  21. data/config/routes.rb +5 -0
  22. data/lib/workarea/facebook_login.rb +36 -0
  23. data/lib/workarea/facebook_login/engine.rb +8 -0
  24. data/lib/workarea/facebook_login/version.rb +5 -0
  25. data/test/dummy/Rakefile +6 -0
  26. data/test/dummy/bin/bundle +3 -0
  27. data/test/dummy/bin/rails +4 -0
  28. data/test/dummy/bin/rake +4 -0
  29. data/test/dummy/bin/setup +34 -0
  30. data/test/dummy/bin/update +29 -0
  31. data/test/dummy/config.ru +5 -0
  32. data/test/dummy/config/application.rb +21 -0
  33. data/test/dummy/config/boot.rb +5 -0
  34. data/test/dummy/config/cable.yml +9 -0
  35. data/test/dummy/config/environment.rb +5 -0
  36. data/test/dummy/config/environments/development.rb +54 -0
  37. data/test/dummy/config/environments/production.rb +86 -0
  38. data/test/dummy/config/environments/test.rb +44 -0
  39. data/test/dummy/config/initializers/application_controller_renderer.rb +6 -0
  40. data/test/dummy/config/initializers/assets.rb +11 -0
  41. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  42. data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
  43. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  44. data/test/dummy/config/initializers/inflections.rb +16 -0
  45. data/test/dummy/config/initializers/mime_types.rb +4 -0
  46. data/test/dummy/config/initializers/workarea.rb +4 -0
  47. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  48. data/test/dummy/config/locales/en.yml +23 -0
  49. data/test/dummy/config/puma.rb +47 -0
  50. data/test/dummy/config/routes.rb +5 -0
  51. data/test/dummy/config/secrets.yml +22 -0
  52. data/test/dummy/config/spring.rb +6 -0
  53. data/test/dummy/db/seeds.rb +2 -0
  54. data/test/dummy/lib/assets/.keep +0 -0
  55. data/test/dummy/log/.keep +0 -0
  56. data/test/dummy/public/404.html +67 -0
  57. data/test/dummy/public/422.html +67 -0
  58. data/test/dummy/public/500.html +66 -0
  59. data/test/dummy/public/apple-touch-icon-precomposed.png +0 -0
  60. data/test/dummy/public/apple-touch-icon.png +0 -0
  61. data/test/dummy/public/favicon.ico +1 -0
  62. data/test/integration/workarea/storefront/users/facebook_logins_integration_test.rb +63 -0
  63. data/test/support/facebook_login_support.rb +50 -0
  64. data/test/system/workarea/storefront/facebook_login_system_test.rb +20 -0
  65. data/test/test_helper.rb +13 -0
  66. data/workarea-facebook_login.gemspec +21 -0
  67. metadata +155 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: bec7144511d2094e5220e8a48e4d6080b1a90c867ac73f8a6c2d9a31b06b638c
4
+ data.tar.gz: c6c8251714088e9f759a6cc920e7964fb55470c5e6b8a33372ea79266670d533
5
+ SHA512:
6
+ metadata.gz: 3ecd210059e03cd671afb83d8e6c194ee8db65d39de8c766ca3b63e5ad5515971cc787bebbb1686826a9badf2aae06d5db3f7e3393643b5016b2366cb62e40b0
7
+ data.tar.gz: 189127e1180ba40f297fa60eface96b5f4ae0f80e9a39666ba8b0e647845afc1e89ef529cdf42bcd20171a613948a34554423cafcaae7765145ba8025cb3271f
@@ -0,0 +1,15 @@
1
+ # editorconfig.org
2
+ root = true
3
+
4
+ [*]
5
+ charset = utf-8
6
+ indent_style = space
7
+ end_of_line = lf
8
+ trim_trailing_whitespace = true
9
+ insert_final_newline = true
10
+
11
+ [{*.rb,*.haml,*.scss}]
12
+ indent_size = 2
13
+
14
+ [{*.js,*.jst,*.ejs}]
15
+ indent_size = 4
@@ -0,0 +1,37 @@
1
+ ---
2
+ name: Bug report
3
+ about: Create a report to help us improve Workarea
4
+ title: ''
5
+ labels: bug
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ ⚠️**Before you create**⚠️
11
+ Please verify the issue you're experiencing is not part of your Workarea project customizations. The best way to do this is with a [vanilla Workarea installation](https://developer.workarea.com/articles/create-a-new-host-application.html). This will help us spend time on fixes/improvements for the whole community. Thank you!
12
+
13
+ **Describe the bug**
14
+ A clear and concise description of what the bug is.
15
+
16
+ **To Reproduce**
17
+ Steps to reproduce the behavior:
18
+ 1. Go to '...'
19
+ 2. Click on '....'
20
+ 3. Scroll down to '....'
21
+ 4. See error
22
+
23
+ **Expected behavior**
24
+ A clear and concise description of what you expected to happen.
25
+
26
+ **Workarea Setup (please complete the following information):**
27
+ - Workarea Version: [e.g. v3.4.6]
28
+ - Plugins [e.g. workarea-blog, workarea-sitemaps]
29
+
30
+ **Attachments**
31
+ If applicable, add any attachments to help explain your problem, things like:
32
+ - screenshots
33
+ - Gemfile.lock
34
+ - test cases
35
+
36
+ **Additional context**
37
+ Add any other context about the problem here.
@@ -0,0 +1,17 @@
1
+ ---
2
+ name: Documentation feedback/request
3
+ about: Provide documentation feedback
4
+ title: ''
5
+ labels: documentation
6
+ assignees: chriscressman
7
+
8
+ ---
9
+
10
+ **Is your documentation related to a problem? Please describe.**
11
+ A clear and concise description of what the problem is. Ex. I'm confused by [...]
12
+
13
+ **Describe the article you'd like**
14
+ A clear and concise description of what would be in the documentation article.
15
+
16
+ **Additional context**
17
+ Add any other context or screenshots about the feature request here.
@@ -0,0 +1,20 @@
1
+ ---
2
+ name: Feature request
3
+ about: Suggest an idea for Workarea
4
+ title: ''
5
+ labels: enhancement
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Is your feature request related to a problem? Please describe.**
11
+ A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12
+
13
+ **Describe the solution you'd like**
14
+ A clear and concise description of what you want to happen.
15
+
16
+ **Describe alternatives you've considered**
17
+ A clear and concise description of any alternative solutions or features you've considered.
18
+
19
+ **Additional context**
20
+ Add any other context or screenshots about the feature request here.
@@ -0,0 +1,56 @@
1
+ name: CI
2
+ on: [push]
3
+
4
+ jobs:
5
+ static_analysis:
6
+ runs-on: ubuntu-latest
7
+ steps:
8
+ - uses: actions/checkout@v1
9
+ - uses: workarea-commerce/ci/bundler-audit@ignore-cves
10
+ with:
11
+ ignored: CVE-2015-9284
12
+ - uses: workarea-commerce/ci/rubocop@v1
13
+
14
+ admin_tests:
15
+ runs-on: ubuntu-latest
16
+ steps:
17
+ - uses: actions/checkout@v1
18
+ - uses: actions/setup-ruby@v1
19
+ with:
20
+ ruby-version: 2.6.x
21
+ - uses: workarea-commerce/ci/test@v1
22
+ with:
23
+ command: bin/rails app:workarea:test:admin
24
+
25
+ core_tests:
26
+ runs-on: ubuntu-latest
27
+ steps:
28
+ - uses: actions/checkout@v1
29
+ - uses: actions/setup-ruby@v1
30
+ with:
31
+ ruby-version: 2.6.x
32
+ - uses: workarea-commerce/ci/test@v1
33
+ with:
34
+ command: bin/rails app:workarea:test:core
35
+
36
+ storefront_tests:
37
+ runs-on: ubuntu-latest
38
+ steps:
39
+ - uses: actions/checkout@v1
40
+ - uses: actions/setup-ruby@v1
41
+ with:
42
+ ruby-version: 2.6.x
43
+ - uses: workarea-commerce/ci/test@v1
44
+ with:
45
+ command: bin/rails app:workarea:test:storefront
46
+
47
+ plugins_tests:
48
+ runs-on: ubuntu-latest
49
+ steps:
50
+ - uses: actions/checkout@v1
51
+ - uses: actions/setup-ruby@v1
52
+ with:
53
+ ruby-version: 2.6.x
54
+ - uses: workarea-commerce/ci/test@v1
55
+ with:
56
+ command: bin/rails app:workarea:test:plugins
@@ -0,0 +1,13 @@
1
+ .bundle/
2
+ .DS_Store
3
+ Gemfile.lock
4
+ .sass-cache/
5
+ log/*.log
6
+ pkg/
7
+ test/dummy/public/system/workarea
8
+ test/dummy/db/*.sqlite3
9
+ test/dummy/log/*.log
10
+ test/dummy/tmp/
11
+ test/dummy/.sass-cache
12
+ coverage
13
+ .rubocop-http*
@@ -0,0 +1,31 @@
1
+ {
2
+ "bitwise": true,
3
+ "camelcase": false,
4
+ "curly": true,
5
+ "eqeqeq": true,
6
+ "forin": true,
7
+ "immed": true,
8
+ "indent": 4,
9
+ "latedef": true,
10
+ "newcap": true,
11
+ "noarg": true,
12
+ "noempty": true,
13
+ "nonew": true,
14
+ "plusplus": true,
15
+ "quotmark": true,
16
+ "undef": true,
17
+ "unused": true,
18
+ "strict": true,
19
+ "trailing": true,
20
+ "browser": true,
21
+ "jquery": true,
22
+ "onevar": true,
23
+ "white": true,
24
+ "globals": {
25
+ "_": false,
26
+ "_gaq": false,
27
+ "JST": false,
28
+ "Modernizr": false,
29
+ "WEBLINC": false
30
+ }
31
+ }
@@ -0,0 +1,2 @@
1
+ inherit_from:
2
+ - https://raw.githubusercontent.com/workarea-commerce/workarea/master/.rubocop.yml
@@ -0,0 +1,74 @@
1
+ Workarea Facebook Login 2.1.0 (2019-12-17)
2
+ --------------------------------------------------------------------------------
3
+
4
+ * Update RuboCop Config
5
+
6
+ Tom Scott
7
+
8
+ * Fix test that can randomly fail due to inconsistent RACK_ENV
9
+
10
+ FACEBOOK-1
11
+ Ben Crouse
12
+
13
+ * This is my life now
14
+
15
+ Tom Scott
16
+
17
+ * Yeah apparently OmniAuth is poorly maintained...
18
+
19
+ Tom Scott
20
+
21
+ * Ensure Compatibility with v3.5.x of Workarea
22
+
23
+ Fixes several issues when using this gem with v3.5:
24
+
25
+ - Update decorated tests to use `session` instead of `cookies` for user
26
+ identification.
27
+ - Set up the gem for hosting on GitHub and CI with GitHub Actions
28
+ - Update OmniAuth to v1.9+ to address security issue
29
+ - Update configuration in `test/dummy` to be compatible with the latest Rails
30
+
31
+ FACEBOOK-1
32
+ Tom Scott
33
+
34
+ * correct spec.files in gemspec
35
+
36
+ Jake Beresford
37
+
38
+ * rename gemspec
39
+
40
+ Jake Beresford
41
+
42
+
43
+
44
+ Workarea Facebook 2.0.0 (2017-07-13)
45
+ --------------------------------------------------------------------------------
46
+
47
+
48
+ Workarea Facebook 2.0.0 (2017-07-13)
49
+ --------------------------------------------------------------------------------
50
+
51
+
52
+ Workarea Facebook 2.0.0 (2017-07-13)
53
+ --------------------------------------------------------------------------------
54
+
55
+ * Rename plugin to FacebookLogin
56
+
57
+ FBLOGIN-11
58
+ Jake Beresford
59
+
60
+ * Upgrade Facebook Login for Workarea V3
61
+
62
+ Breaking Changes
63
+ Remove partial from Users Accounts, "unlinking from facebook" served no purpose
64
+ Storefront::Users::FacebookController was renamed to Storefront::Users::FacebookLoginsController
65
+ FacebookHelper was removed and path is now in Workarea::Facebook.auth_path
66
+ The storefront/_facebook partial was moved to storefront/users/_facebook_login
67
+
68
+ FBLOGIN-8
69
+ Eric Pigeon
70
+
71
+ * Capitalize facebook in error message
72
+
73
+ FBLOGIN-7
74
+ Eric Pigeon
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ gem "rubocop", require: false
6
+ gem "bundler-audit", require: false
7
+ gem "sprockets", "~> 3"
8
+
9
+ group :test do
10
+ gem "simplecov", require: false
11
+ end
@@ -0,0 +1,13 @@
1
+ # Workarea Facebook Login
2
+
3
+ Allows customers to log using Facebook oath.
4
+
5
+ ## Installation
6
+
7
+ Add the following to secrets
8
+
9
+ ```ruby
10
+ facebook_login:
11
+ :key: YOUR_APP_ID
12
+ :secret: YOUR_APP_SECRET
13
+ ```
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require "bundler/setup"
4
+ rescue LoadError
5
+ puts "You must `gem install bundler` and `bundle install` to run rake tasks"
6
+ end
7
+
8
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
9
+
10
+ load "rails/tasks/engine.rake"
11
+ load "rails/tasks/statistics.rake"
12
+ load 'workarea/changelog.rake'
13
+ require "rake/testtask"
14
+
15
+ # Run all tests
16
+ Rake::TestTask.new do |t|
17
+ t.libs << "test"
18
+ t.pattern = "test/**/*_test.rb"
19
+ t.verbose = false
20
+ t.warning = false
21
+ end
22
+
23
+ $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
24
+ require "workarea/facebook_login/version"
25
+
26
+ desc "Release version #{Workarea::FacebookLogin::VERSION} of the gem"
27
+ task :release do
28
+ host = "https://#{ENV['BUNDLE_GEMS__WEBLINC__COM']}@gems.weblinc.com"
29
+
30
+ Rake::Task['workarea:changelog'].execute
31
+ system 'git add CHANGELOG.md'
32
+ system 'git commit -m "Update CHANGELOG"'
33
+ system 'git push origin HEAD'
34
+
35
+ system "git tag -a v#{Workarea::FacebookLogin::VERSION} -m 'Tagging #{Workarea::FacebookLogin::VERSION}'"
36
+ system "git push --tags"
37
+
38
+ system "gem build workarea-facebook_login.gemspec"
39
+ system "gem push workarea-facebook_login-#{Workarea::FacebookLogin::VERSION}.gem #{host}"
40
+ system "gem push workarea-facebook_login-#{Workarea::FacebookLogin::VERSION}.gem --host #{host}"
41
+ system "rm workarea-facebook_login-#{Workarea::FacebookLogin::VERSION}.gem"
42
+ end
@@ -0,0 +1,46 @@
1
+ module Workarea
2
+ class Storefront::Users::FacebookLoginsController < Storefront::ApplicationController
3
+ before_action :user_from_omniauth, only: :create
4
+ before_action :fail_admin_log_in, only: :create
5
+ before_action :validate_current_email, only: :create
6
+
7
+ def create
8
+ login(@user)
9
+
10
+ login_service = Login.new(@user, current_order).tap(&:perform)
11
+ self.current_order = login_service.current_order
12
+
13
+ flash[:success] = t("workarea.storefront.flash_messages.logged_in")
14
+ redirect_back_or users_account_path
15
+ end
16
+
17
+ def failure
18
+ flash[:error] = t("workarea.storefront.facebook_login.flash_messages.failure")
19
+ redirect_to login_path
20
+ end
21
+
22
+ private
23
+
24
+ def auth_hash
25
+ @auth_hash ||= request.env["omniauth.auth"]
26
+ end
27
+
28
+ def user_from_omniauth
29
+ @user ||= Workarea::User.from_omniauth(auth_hash)
30
+ end
31
+
32
+ def fail_admin_log_in
33
+ return unless @user.admin? || @user.super_admin?
34
+
35
+ flash[:error] = t("workarea.storefront.facebook_login.flash_messages.admin_failure")
36
+ redirect_to login_path
37
+ end
38
+
39
+ def validate_current_email
40
+ return if current_user.nil? || current_user.email == auth_hash.info.email
41
+
42
+ flash[:error] = t("workarea.storefront.facebook_login.flash_messages.email_mismatch")
43
+ redirect_back_or users_account_path
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,41 @@
1
+ module Workarea
2
+ decorate User, with: :facebook_login do
3
+ decorated do
4
+ field :provider, type: String
5
+ field :uid, type: String
6
+ field :oauth_token, type: String
7
+ field :oauth_expires_at, type: DateTime
8
+ field :deleted_at, type: DateTime
9
+ field :is_omniauthed, type: Boolean, default: false
10
+ end
11
+
12
+ class_methods do
13
+ # Finds or initializes a User by an omniauth auth hash.
14
+ #
15
+ # @param [OmniAuth::AuthHash] auth_hash
16
+ #
17
+ # @return [Workarea::User]
18
+ #
19
+ def from_omniauth(auth)
20
+ return nil if auth.nil?
21
+
22
+ user = find_by_email(auth.info.email) || new(email: auth.info.email)
23
+
24
+ # Workarea/Core has a password validator and has_secure_password from
25
+ # ActiveModel validates password length so just set a random password
26
+ user.password = SecureRandom.hex
27
+ user.is_omniauthed = true
28
+ user.provider = auth.provider
29
+ user.uid = auth.uid
30
+ user.name = auth.info.name
31
+ user.email = auth.info.email
32
+ user.oauth_token = auth.credentials.token
33
+ user.oauth_expires_at = Time.at(auth.credentials.expires_at)
34
+ user.first_name = auth.info.first_name.presence
35
+ user.last_name = auth.info.last_name.presence
36
+ user.save
37
+ user
38
+ end
39
+ end
40
+ end
41
+ end