Merge branch 'dev' into issue/2743

This commit is contained in:
Daniel O'Connor
2022-12-18 11:44:52 +10:30
committed by GitHub
16 changed files with 10 additions and 125 deletions

View File

@@ -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

View File

@@ -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'

View File

@@ -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)
@@ -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
@@ -399,27 +398,16 @@ GEM
nokogiri (1.13.10-x86_64-linux)
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
@@ -716,7 +704,6 @@ DEPENDENCIES
memcachier
oj
omniauth (~> 1.3)
omniauth-facebook
omniauth-flickr (>= 0.0.15)
omniauth-twitter
percy-capybara (~> 5.0.0)

View File

@@ -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)

View File

@@ -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

View File

@@ -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

View File

@@ -28,17 +28,3 @@
method: :delete, class: "remove btn btn-danger"
- 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'

View File

@@ -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:

View File

@@ -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

View File

@@ -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"
})

View File

@@ -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

View File

@@ -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.

View File

@@ -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']

View File

@@ -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

View File

@@ -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

View File

@@ -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 "render 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