From d3063f844d695ff1c3c1639848c3dc065a73275c Mon Sep 17 00:00:00 2001 From: Daniel O'Connor Date: Sat, 10 Dec 2022 15:52:12 +1030 Subject: [PATCH 01/11] Remove facebook auth. They wanted to dictate the behaviour of an application they didn't own, so I told them to get stuffed a few years ago --- Gemfile | 1 - Gemfile.lock | 13 ------------- app/controllers/members_controller.rb | 1 - app/controllers/omniauth_callbacks_controller.rb | 6 +----- app/controllers/registrations_controller.rb | 1 - app/views/devise/registrations/_edit_apps.html.haml | 13 ------------- app/views/members/_contact.html.haml | 7 +------ app/views/members/show.html.haml | 3 +-- 8 files changed, 3 insertions(+), 42 deletions(-) diff --git a/Gemfile b/Gemfile index 03576d364..c612af7e6 100644 --- a/Gemfile +++ b/Gemfile @@ -94,7 +94,6 @@ gem "bootstrap_form", ">= 4.5.0" # For connecting to other services (eg Twitter) gem 'omniauth', '~> 1.3' -gem 'omniauth-facebook' gem 'omniauth-flickr', '>= 0.0.15' gem 'omniauth-twitter' diff --git a/Gemfile.lock b/Gemfile.lock index bddcd7ac4..31b80d4ca 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -338,7 +338,6 @@ GEM concurrent-ruby railties (>= 4.1) jsonapi-swagger (0.8.1) - jwt (2.3.0) kgio (2.11.4) kramdown (2.4.0) rexml @@ -397,27 +396,16 @@ GEM mini_portile2 (~> 2.8.0) racc (~> 1.4) oauth (0.5.6) - oauth2 (1.4.9) - faraday (>= 0.17.3, < 3.0) - jwt (>= 1.0, < 3.0) - multi_json (~> 1.3) - multi_xml (~> 0.5) - rack (>= 1.2, < 3) oj (3.13.23) omniauth (1.9.2) hashie (>= 3.4.6) rack (>= 1.6.2, < 3) - omniauth-facebook (9.0.0) - omniauth-oauth2 (~> 1.2) omniauth-flickr (0.0.20) multi_json (~> 1.12) omniauth-oauth (~> 1.0) omniauth-oauth (1.1.0) oauth omniauth (~> 1.0) - omniauth-oauth2 (1.7.2) - oauth2 (~> 1.4) - omniauth (>= 1.9, < 3) omniauth-twitter (1.4.0) omniauth-oauth (~> 1.1) rack @@ -713,7 +701,6 @@ DEPENDENCIES memcachier oj omniauth (~> 1.3) - omniauth-facebook omniauth-flickr (>= 0.0.15) omniauth-twitter percy-capybara (~> 5.0.0) diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index 021460c99..1211e870e 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -18,7 +18,6 @@ class MembersController < ApplicationController @member = Member.confirmed.kept.find_by!(slug: params[:slug]) @twitter_auth = @member.auth('twitter') @flickr_auth = @member.auth('flickr') - @facebook_auth = @member.auth('facebook') @posts = @member.posts @activity = TimelineService.member_query(@member).limit(30) diff --git a/app/controllers/omniauth_callbacks_controller.rb b/app/controllers/omniauth_callbacks_controller.rb index c9243c89b..f01ad3d71 100644 --- a/app/controllers/omniauth_callbacks_controller.rb +++ b/app/controllers/omniauth_callbacks_controller.rb @@ -9,10 +9,6 @@ require './lib/actions/oauth_signup_action' # Heavily overlaps with Authentications controller # class OmniauthCallbacksController < Devise::OmniauthCallbacksController - def facebook - create - end - def failure flash[:alert] = "Authentication failed." redirect_to request.env['omniauth.origin'] || "/" @@ -32,7 +28,7 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController @authentication = action.establish_authentication(auth, member) if action.member_created? - raise "Invalid provider" unless %w(facebook twitter flickr).index(auth['provider'].to_s) + raise "Invalid provider" unless %w(twitter flickr).index(auth['provider'].to_s) session["devise.#{auth['provider']}_data"] = request.env["omniauth.auth"] sign_in member diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index 530321233..29cc5e1b1 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -6,7 +6,6 @@ class RegistrationsController < Devise::RegistrationsController def edit @twitter_auth = current_member.auth('twitter') @flickr_auth = current_member.auth('flickr') - @facebook_auth = current_member.auth('facebook') render "edit" end diff --git a/app/views/devise/registrations/_edit_apps.html.haml b/app/views/devise/registrations/_edit_apps.html.haml index da6e88470..f47316b6f 100644 --- a/app/views/devise/registrations/_edit_apps.html.haml +++ b/app/views/devise/registrations/_edit_apps.html.haml @@ -29,16 +29,3 @@ - else = link_to 'Connect to Flickr', '/members/auth/flickr', class: 'btn' - .row - .col-md-12 - %p - = image_tag "facebook_32.png", size: "32x32", alt: 'Facebook logo' - - if @facebook_auth - You are connected to Facebook as - = succeed "." do - = link_to @facebook_auth.name, "https://facebook.com/profile/#{@facebook_auth.uid}" - = link_to "Disconnect", @facebook_auth, - confirm: "Are you sure you want to remove this connection?", - method: :delete, class: "remove btn btn-danger" - - else - = link_to 'Connect to Facebook', '/members/auth/facebook', class: 'btn' diff --git a/app/views/members/_contact.html.haml b/app/views/members/_contact.html.haml index 69e1f60b0..d6bdb7cb9 100644 --- a/app/views/members/_contact.html.haml +++ b/app/views/members/_contact.html.haml @@ -1,4 +1,4 @@ -- if twitter_auth || flickr_auth || facebook_auth || member.show_email +- if twitter_auth || flickr_auth || member.show_email %h4 Contact - if twitter_auth @@ -11,11 +11,6 @@ = image_tag "flickr_32.png", size: "32x32", alt: 'Flickr logo' = link_to flickr_auth.name, "https://flickr.com/photos/#{flickr_auth.uid}" - - if facebook_auth - %p - = image_tag "facebook_32.png", size: "32x32", alt: 'Facebook logo' - = link_to facebook_auth.name, "https://facebook.com/profile/#{facebook_auth.uid}" - - if member.show_email %p Email: diff --git a/app/views/members/show.html.haml b/app/views/members/show.html.haml index 3f56bb4ef..2a62abac9 100644 --- a/app/views/members/show.html.haml +++ b/app/views/members/show.html.haml @@ -57,8 +57,7 @@ = render "stats", member: @member .card-footer = render "contact", member: @member, twitter_auth: @twitter_auth, - flickr_auth: @flickr_auth, - facebook_auth: @facebook_auth + flickr_auth: @flickr_auth .col-md-10 %section= render "map", member: @member From 07feb1cd8540075ca8d6394df382987d45aeb847 Mon Sep 17 00:00:00 2001 From: Daniel O'Connor Date: Sat, 10 Dec 2022 15:54:58 +1030 Subject: [PATCH 02/11] Drop tests --- config/environments/test.rb | 13 ------------ env-example | 4 ---- lib/actions/oauth_signup_action.rb | 2 +- spec/features/signup_spec.rb | 33 ------------------------------ 4 files changed, 1 insertion(+), 51 deletions(-) diff --git a/config/environments/test.rb b/config/environments/test.rb index 1cfd2c15a..14276a429 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -104,16 +104,3 @@ Capybara.configure do |config| end OmniAuth.config.test_mode = true -# Fake the omniauth -OmniAuth.config.mock_auth[:facebook] = OmniAuth::AuthHash.new(provider: 'facebook', - uid: '123545', - info: { - name: "John Testerson", - nickname: 'JohnnyT', - email: 'example.oauth.facebook@example.com', - image: 'http://findicons.com/files/icons/1072/face_avatars/300/i04.png' - }, - credentials: { - token: "token", - secret: "donttell" - }) diff --git a/env-example b/env-example index a7d3ef65e..951611496 100644 --- a/env-example +++ b/env-example @@ -50,10 +50,6 @@ GROWSTUFF_TWITTER_SECRET="" GROWSTUFF_FLICKR_KEY="" GROWSTUFF_FLICKR_SECRET="" -# https://developers.facebook.com/ -GROWSTUFF_FACEBOOK_KEY="" -GROWSTUFF_FACEBOOK_SECRET="" - # Elasticsearch is used for flexible search and it requires another component # to be installed. To make it easy for people who don't need to test this feature # it's been turned off for test and development environment as a default. diff --git a/lib/actions/oauth_signup_action.rb b/lib/actions/oauth_signup_action.rb index a20741fb1..fe00fb305 100644 --- a/lib/actions/oauth_signup_action.rb +++ b/lib/actions/oauth_signup_action.rb @@ -63,7 +63,7 @@ class Growstuff::OauthSignupAction case auth['provider'] when 'twitter' auth['info']['nickname'] - when 'flickr', 'facebook' + when 'flickr' auth['info']['name'] else auth['info']['name'] diff --git a/spec/features/signup_spec.rb b/spec/features/signup_spec.rb index 687253a85..5dabbb02d 100644 --- a/spec/features/signup_spec.rb +++ b/spec/features/signup_spec.rb @@ -45,37 +45,4 @@ describe "signup", js: true do click_button 'Sign up' expect(page).to have_current_path members_path, ignore_query: true end - - context "with facebook" do - it "sign up" do - # Ordinarily done by database_cleaner - Member.where(login_name: 'tdawg').delete_all - Member.where(email: 'tdawg@hotmail.com').delete_all - Member.where(email: 'example.oauth.facebook@example.com').delete_all - Authentication.where(provider: 'facebook', uid: '123545').delete_all - - # Start the test - visit root_path - first('.signup a').click - - # Click the signup with facebook link - - first('a[href="/members/auth/facebook"]').click - # Magic happens! - # See config/environments/test.rb for the fake user - # that we pretended to auth as - - # Confirm page - expect(page).to have_current_path '/members/johnnyt/finish_signup' - - fill_in 'Login name', with: 'tdawg' - fill_in 'Email', with: 'tdawg@hotmail.com' - check 'member_tos_agreement' - click_button 'Continue' - - # Signed up and logged in - expect(page).to have_current_path root_path, ignore_query: true - expect(page.text).to include("Welcome to #{ENV['GROWSTUFF_SITE_NAME']}, tdawg") - end - end end From 28d550d67f5fb0d088ed1e39398f06009c4d7aa4 Mon Sep 17 00:00:00 2001 From: Daniel O'Connor Date: Sat, 10 Dec 2022 15:55:57 +1030 Subject: [PATCH 03/11] Drop test --- config/initializers/devise.rb | 4 ---- spec/features/signin_spec.rb | 24 ------------------------ 2 files changed, 28 deletions(-) diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index 9e5b06c66..4990573d1 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -233,8 +233,4 @@ Devise.setup do |config| # When using omniauth, Devise cannot automatically set Omniauth path, # so you need to do it manually. For the users scope, it would be: # config.omniauth_path_prefix = "/my_engine/users/auth" - - # Later we may wish to ask for user_photos,user_location, however this means we need to be reviewed by facebook - config.omniauth :facebook, ENV['GROWSTUFF_FACEBOOK_KEY'], ENV['GROWSTUFF_FACEBOOK_SECRET'], scope: 'email,public_profile', -display: 'page', info_fields: 'email,name,first_name,last_name,id' end diff --git a/spec/features/signin_spec.rb b/spec/features/signin_spec.rb index 6ea441989..aa9082bd3 100644 --- a/spec/features/signin_spec.rb +++ b/spec/features/signin_spec.rb @@ -82,28 +82,4 @@ describe "signin", js: true do click_button 'Sign in' expect(page).to have_content("There are crops waiting to be wrangled.") end - - context "with facebook" do - it "sign in" do - # Ordinarily done by database_cleaner - Member.where(login_name: 'tdawg').delete_all - - create(:member, login_name: 'tdawg', email: 'example.oauth.facebook@example.com') - - # Start the test - visit root_path - first('.signup a').click - - # Click the signup with facebook link - - first('a[href="/members/auth/facebook"]').click - # Magic happens! - # See config/environments/test.rb for the fake user - # that we pretended to auth as - - # Signed up and logged in - expect(page).to have_current_path root_path, ignore_query: true - expect(page.text).to include("Welcome to #{ENV['GROWSTUFF_SITE_NAME']}, tdawg") - end - end end From dd7c51ea8834624a66bd5273d224d9358c1af09a Mon Sep 17 00:00:00 2001 From: Daniel O'Connor Date: Sat, 10 Dec 2022 16:13:11 +1030 Subject: [PATCH 04/11] Update _edit_apps.html.haml --- app/views/devise/registrations/_edit_apps.html.haml | 1 - 1 file changed, 1 deletion(-) diff --git a/app/views/devise/registrations/_edit_apps.html.haml b/app/views/devise/registrations/_edit_apps.html.haml index f47316b6f..e4bcf487e 100644 --- a/app/views/devise/registrations/_edit_apps.html.haml +++ b/app/views/devise/registrations/_edit_apps.html.haml @@ -28,4 +28,3 @@ method: :delete, class: "remove btn btn-danger" - else = link_to 'Connect to Flickr', '/members/auth/flickr', class: 'btn' - From 74f2ffe86e1eb4749bf87aff16667deba818b63e Mon Sep 17 00:00:00 2001 From: Italo Pires Date: Sat, 10 Dec 2022 18:38:11 -0300 Subject: [PATCH 05/11] Fix test warning about assert link with capybara --- spec/views/scientific_names/edit.html.haml_spec.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spec/views/scientific_names/edit.html.haml_spec.rb b/spec/views/scientific_names/edit.html.haml_spec.rb index 15c904e07..29ce06940 100644 --- a/spec/views/scientific_names/edit.html.haml_spec.rb +++ b/spec/views/scientific_names/edit.html.haml_spec.rb @@ -18,7 +18,9 @@ describe "scientific_names/edit" do expect(rendered).to have_content "Added by #{member} less than a minute ago." end - xit { expect(rendered).to have_link member_path(member) } + it "shows member link" do + expect(rendered).to have_link member.login_name, href: member_path(member) + end it "renders the edit scientific_name form" do assert_select "form", action: scientific_names_path(scientific_name), method: "post" do From 24ac3fc9be8b044893056251734c3304dd99739e Mon Sep 17 00:00:00 2001 From: Italo Pires Date: Sat, 10 Dec 2022 18:42:13 -0300 Subject: [PATCH 06/11] Rename it from shows to render --- spec/views/scientific_names/edit.html.haml_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/views/scientific_names/edit.html.haml_spec.rb b/spec/views/scientific_names/edit.html.haml_spec.rb index 29ce06940..2e31efb0a 100644 --- a/spec/views/scientific_names/edit.html.haml_spec.rb +++ b/spec/views/scientific_names/edit.html.haml_spec.rb @@ -18,7 +18,7 @@ describe "scientific_names/edit" do expect(rendered).to have_content "Added by #{member} less than a minute ago." end - it "shows member link" do + it "render member link" do expect(rendered).to have_link member.login_name, href: member_path(member) end From 5faf99016794130cf5b3c59aed516e04e3376335 Mon Sep 17 00:00:00 2001 From: Italo Pires Date: Sat, 10 Dec 2022 18:50:17 -0300 Subject: [PATCH 07/11] Removed white space --- spec/views/scientific_names/edit.html.haml_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/views/scientific_names/edit.html.haml_spec.rb b/spec/views/scientific_names/edit.html.haml_spec.rb index 2e31efb0a..0b148032b 100644 --- a/spec/views/scientific_names/edit.html.haml_spec.rb +++ b/spec/views/scientific_names/edit.html.haml_spec.rb @@ -18,7 +18,7 @@ describe "scientific_names/edit" do expect(rendered).to have_content "Added by #{member} less than a minute ago." end - it "render member link" do + it "render member link" do expect(rendered).to have_link member.login_name, href: member_path(member) end From 8951ae471999927ee7c5fe1eb03456e8c7e4206b Mon Sep 17 00:00:00 2001 From: Italo Pires Date: Mon, 12 Dec 2022 15:30:41 -0300 Subject: [PATCH 08/11] Added myself to CONTRIBUTORS.md --- CONTRIBUTORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index cdd60ca49..5362e2f72 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -92,6 +92,7 @@ submit the change with your pull request. - André Aubin / [lambda2](https://github.com/lambda2) - Martina Simicic / [simicic](https://github.com/simicic) - Rowan Crawford / [wombleton](https://github.com/wombleton) +- Ítalo Pires / [italopires](https://github.com/italopires) ## Bots From f677500d2e862f947df5690a8e98333d5301f0a6 Mon Sep 17 00:00:00 2001 From: Cesy Avon Date: Thu, 15 Jun 2017 17:17:11 +0000 Subject: [PATCH 09/11] Empty fails on nil, better to use present instead --- app/views/members/_stats.html.haml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/views/members/_stats.html.haml b/app/views/members/_stats.html.haml index 7b7d667f6..86f08adc1 100644 --- a/app/views/members/_stats.html.haml +++ b/app/views/members/_stats.html.haml @@ -2,39 +2,39 @@ %h3 Activity %ul.list-group.list-group-flush %li.list-group-item - - if !member.gardens.empty? + - if member.gardens.present? = link_to localize_plural(member.gardens, Garden), member_gardens_path(member) - else 0 gardens %li.list-group-item - - if !member.plantings.empty? + - if member.plantings.present? = link_to localize_plural(member.plantings, Planting), member_plantings_path(member) - else 0 plantings %li.list-group-item - - if !member.harvests.empty? + - if member.harvests.present? = link_to localize_plural(member.harvests, Harvest), member_harvests_path(member) - else 0 harvests %li.list-group-item - - if !member.seeds.empty? + - if member.seeds.present? = link_to localize_plural(member.seeds, Seed), member_seeds_path(member) - else 0 seeds %li.list-group-item - - if !member.posts.empty? + - if member.posts.present? = link_to localize_plural(member.posts, Post), member_posts_path(member) - else 0 posts %li.list-group-item - - if !member.followed.empty? + - if member.followed.present? = link_to localize_plural(member.followed, Follow), member_follows_path(member) - else 0 following %li.list-group-item - - if !member.followers.empty? + - if member.followers.present? = link_to pluralize(member.followers.size, "follower"), member_followers_path(member) - else 0 followers From 0a9afe03d99986855927348f3e7bfba275fe6b2d Mon Sep 17 00:00:00 2001 From: Daniel O'Connor Date: Thu, 15 Dec 2022 22:28:38 +1030 Subject: [PATCH 10/11] Fix #2743 Remove doubled crops entry --- swagger/v1/swagger.json | 7 ------- 1 file changed, 7 deletions(-) diff --git a/swagger/v1/swagger.json b/swagger/v1/swagger.json index 11d215f1d..575c5423a 100644 --- a/swagger/v1/swagger.json +++ b/swagger/v1/swagger.json @@ -92,13 +92,6 @@ "type": "string", "description": "Display field", "required": false - }, - { - "name": "fields[crops]", - "in": "query", - "type": "string", - "description": "Display field", - "required": false } ], "responses": { From baeb3a109d4100b6692968ee56fd2b24aebcc464 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 16 Dec 2022 07:01:08 +0000 Subject: [PATCH 11/11] Bump haml_lint from 0.42.0 to 0.43.0 Bumps [haml_lint](https://github.com/sds/haml-lint) from 0.42.0 to 0.43.0. - [Release notes](https://github.com/sds/haml-lint/releases) - [Changelog](https://github.com/sds/haml-lint/blob/main/CHANGELOG.md) - [Commits](https://github.com/sds/haml-lint/compare/v0.42.0...v0.43.0) --- updated-dependencies: - dependency-name: haml_lint dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index ffd37321b..1be1aba19 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -288,8 +288,8 @@ GEM activesupport (>= 5.1) haml (>= 4.0.6) railties (>= 5.1) - haml_lint (0.42.0) - haml (>= 4.0, < 6.1) + haml_lint (0.43.0) + haml (>= 4.0, < 6.2) parallel (~> 1.10) rainbow rubocop (>= 0.50.0)