mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-25 20:46:48 +00:00
Oh, and a transaction block. Because the controller after hooks tried to update the DB which resulted in PG::InFailedSqlTransaction: ERROR: current transaction is aborted, commands ignored until end of transaction block Even for a small rescue statement, it's worth adding a spec. You never know what might not be working!
22 lines
623 B
Ruby
22 lines
623 B
Ruby
# frozen_string_literal: true
|
|
|
|
class OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
|
def openid_connect
|
|
ActiveRecord::Base.transaction do
|
|
OidcAccount.link(spree_current_user, request.env["omniauth.auth"])
|
|
end
|
|
|
|
redirect_to admin_oidc_settings_path
|
|
rescue ActiveRecord::RecordNotUnique
|
|
flash[:error] = t("devise.oidc.record_not_unique", uid: request.env["omniauth.auth"].uid)
|
|
redirect_to admin_oidc_settings_path
|
|
end
|
|
|
|
def failure
|
|
error_message = request.env["omniauth.error"].to_s
|
|
flash[:error] = t("devise.oidc.failure", error: error_message)
|
|
|
|
super
|
|
end
|
|
end
|