Sha256: 75e7be62353a3005ccc44228ff7dd3daa3b3dbb2df3be796b1a93f7a363f9908

Contents?: true

Size: 1.63 KB

Versions: 53

Compression:

Stored size: 1.63 KB

Contents

= OAuth

Decidim is both and OAuth client (via https://github.com/omniauth/omniauth[omniauth]) and an OAuth provider (via https://github.com/doorkeeper-gem/doorkeeper[doorkeeper]).

Check the xref:services:social_providers.adoc[Social Providers] document to check the provider and client configurations.

== Performing more actions on omniauth registration

Some times, there is the need to perform more actions than just creating a user on registration, this is why `CreateOmniauthRegistration` command publishes a `"decidim.user.omniauth_registration` event after registration so that developers can subscribe to it and perform other actions like user verification or alike.

This event comes with the following payload:

* user_id: The id for the registered User.
* identity_id: The id for the social Identity.
* provider: The name for the social provider.
* uid: OAuth's uid
* email: User's email.
* name: User's name.
* nickname: User's nickname after being normalized.
* avatar_url: Avatar's url, if any.
* raw_data: The raw hash received directly from the Omniauth gem.

To be notified after a registration one should subscribe to the event, in the passed block the after registration code should be implemented:

[source,ruby]
----
ActiveSupport::Notifications.subscribe "decidim.user.omniauth_registration" do |name, started, finished, unique_id, data|
  puts "the data: #{data.inspect}"
  IdCatMobilVerificationJob.perform_later(data[:raw_data])
end
----

It is a good practice to delegate the required implementation to a Job to bring a fastest response to the user, also it will avoid that crashes in this code to propagate to the registration process.

Version data entries

53 entries across 53 versions & 1 rubygems

Version Path
decidim-0.30.0.rc2 docs/modules/customize/pages/oauth.adoc
decidim-0.30.0.rc1 docs/modules/customize/pages/oauth.adoc
decidim-0.29.2 docs/modules/customize/pages/oauth.adoc
decidim-0.28.5 docs/modules/customize/pages/oauth.adoc
decidim-0.29.1 docs/modules/customize/pages/oauth.adoc
decidim-0.28.4 docs/modules/customize/pages/oauth.adoc
decidim-0.27.9 docs/modules/customize/pages/oauth.adoc
decidim-0.29.0 docs/modules/customize/pages/oauth.adoc
decidim-0.28.3 docs/modules/customize/pages/oauth.adoc
decidim-0.27.8 docs/modules/customize/pages/oauth.adoc
decidim-0.29.0.rc4 docs/modules/customize/pages/oauth.adoc
decidim-0.29.0.rc3 docs/modules/customize/pages/oauth.adoc
decidim-0.29.0.rc2 docs/modules/customize/pages/oauth.adoc
decidim-0.29.0.rc1 docs/modules/customize/pages/oauth.adoc
decidim-0.28.2 docs/modules/customize/pages/oauth.adoc
decidim-0.27.7 docs/modules/customize/pages/oauth.adoc
decidim-0.28.1 docs/modules/customize/pages/oauth.adoc
decidim-0.27.6 docs/modules/customize/pages/oauth.adoc
decidim-0.26.10 docs/modules/customize/pages/oauth.adoc
decidim-0.26.9 docs/modules/customize/pages/oauth.adoc