mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-29 21:17:17 +00:00
Direct people to refresh OIDC connection
Not the best UX but the easiest next step to implement. Next we should: * Include link in error message instead of redirecting straight there. Otherwise users may feel disoriented. * Provide a custom error message?
This commit is contained in:
@@ -32,6 +32,9 @@ module Admin
|
||||
ActionController::ParameterMissing => e
|
||||
flash[:error] = e.message
|
||||
redirect_to admin_product_import_path
|
||||
rescue Rack::OAuth2::Client::Error
|
||||
flash[:error] = t(".connection_invalid")
|
||||
redirect_to admin_oidc_settings_path
|
||||
end
|
||||
|
||||
def import
|
||||
|
||||
@@ -847,6 +847,9 @@ en:
|
||||
map: Map
|
||||
|
||||
dfc_product_imports:
|
||||
connection_invalid: |
|
||||
Connecting with your OIDC account failed.
|
||||
Please refresh your OIDC connection.
|
||||
index:
|
||||
title: "DFC product catalog"
|
||||
catalog_url: "%{count} products to be imported from: %{catalog_url}"
|
||||
|
||||
102
spec/fixtures/vcr_cassettes/DFC_Product_Import/prompts_to_refresh_OIDC_connection.yml
vendored
Normal file
102
spec/fixtures/vcr_cassettes/DFC_Product_Import/prompts_to_refresh_OIDC_connection.yml
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -114,4 +114,25 @@ RSpec.describe "DFC Product Import" do
|
||||
click_button "Preview"
|
||||
expect(page).to have_content "param is missing or the value is empty: catalog_url"
|
||||
end
|
||||
|
||||
it "prompts to refresh OIDC connection", vcr: true do
|
||||
# Stale access token will be renewed, but refresh token isn't valid either.
|
||||
user.oidc_account.update!(
|
||||
refresh_token: "something-expired-or-invalid",
|
||||
updated_at: 1.day.ago,
|
||||
)
|
||||
|
||||
catalog_url = "https://example.net/unauthorized"
|
||||
stub_request(:get, catalog_url).to_return(status: [401, "Unauthorized"])
|
||||
|
||||
visit admin_product_import_path
|
||||
|
||||
select enterprise.name, from: "Enterprise"
|
||||
fill_in "catalog_url", with: catalog_url
|
||||
|
||||
click_button "Preview"
|
||||
|
||||
expect(page).to have_content "OIDC Settings"
|
||||
expect(page).to have_content "Connecting with your OIDC account failed."
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user