Sha256: 84a01cf5ed12e0ce4b4641096e6df174fc3000f422b7efe211b397e9468af499
Contents?: true
Size: 1.36 KB
Versions: 2
Compression:
Stored size: 1.36 KB
Contents
module InfinumId module Api class WebhooksController < Api::BaseController def upsert_resource_callback intent, resource = upsert InfinumId::AfterResourceUpsert.call(resource, params[:user], intent) render json: { resource_name.underscore => 'updated' } end def update_resource_callback return head :not_found if resource.blank? intent, resource = update InfinumId::AfterResourceUpsert.call(resource, params[:user], intent) render json: { resource_name.underscore => 'updated' } end private def user_params params.require(:user) .permit(InfinumId.resource_attributes) .merge(provider: params[:provider]) end def resource @resource ||= resource_class.find_by(uid: user_params[:uid], provider: params[:provider]) || resource_class.find_by(email: user_params[:email]) end def update resource.update(user_params) [InfinumId::AfterResourceIntent::UPDATE, resource] end def upsert if resource resource.update(user_params) [InfinumId::AfterResourceIntent::UPDATE, resource] else @resource = resource_class.create(user_params) [InfinumId::AfterResourceIntent::CREATE, resource] end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
infinum_id-2.2.0 | app/controllers/infinum_id/api/webhooks_controller.rb |
infinum_id-2.1.0 | app/controllers/infinum_id/api/webhooks_controller.rb |