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:
Maikel Linke
2025-02-06 16:56:13 +11:00
parent 00a2894e93
commit bb503e12a3
4 changed files with 129 additions and 0 deletions

View File

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

View File

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

File diff suppressed because one or more lines are too long

View File

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