module InfinumId module Users class OmniauthCallbacksController < Devise::OmniauthCallbacksController def infinum_id user = InfinumId::Users::Finder.from_omniauth(omniauth) if user InfinumId::Users::Updater.call(omniauth['info'], user) flash[:notice] = I18n.t 'devise.omniauth_callbacks.success', kind: 'InfinumId' sign_in_and_redirect user, event: :authentication else flash[:notice] = 'You do not have permission to access this application.' redirect_to root_path end end def failure set_flash_message! :alert, :failure, kind: OmniAuth::Utils.camelize(failed_strategy.name), reason: failure_message redirect_to root_path end private def omniauth @omniauth ||= request.env['omniauth.auth'] end end end end