Class: Decidim::Devise::OmniauthRegistrationsController
Overview
This controller customizes the behaviour of Devise::Omniauthable.
Instance Method Summary
collapse
#check_user_block_status, #check_user_not_blocked
Instance Method Details
#action_missing(action_name) ⇒ Object
49
50
51
52
53
|
# File 'app/controllers/decidim/devise/omniauth_registrations_controller.rb', line 49
def action_missing(action_name)
return send(:create) if devise_mapping.omniauthable? && current_organization.enabled_omniauth_providers.keys.include?(action_name.to_sym)
raise AbstractController::ActionNotFound, "The action '#{action_name}' could not be found for Decidim::Devise::OmniauthCallbacksController"
end
|
#create ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'app/controllers/decidim/devise/omniauth_registrations_controller.rb', line 15
def create
form_params = user_params_from_oauth_hash || params[:user]
@form = form(OmniauthRegistrationForm).from_params(form_params)
@form.email ||= verified_email
CreateOmniauthRegistration.call(@form, verified_email) do
on(:ok) do |user|
if user.active_for_authentication?
sign_in_and_redirect user, event: :authentication
set_flash_message :notice, :success, kind: @form.provider.capitalize
else
expire_data_after_sign_in!
user.resend_confirmation_instructions unless user.confirmed?
redirect_to decidim.root_path
flash[:notice] = t("devise.registrations.signed_up_but_unconfirmed")
end
end
on(:invalid) do
set_flash_message :notice, :success, kind: @form.provider.capitalize
render :new
end
on(:error) do |user|
if user.errors[:email]
set_flash_message :alert, :failure, kind: @form.provider.capitalize, reason: t("decidim.devise.omniauth_registrations.create.email_already_exists")
end
render :new
end
end
end
|
#new ⇒ Object
11
12
13
|
# File 'app/controllers/decidim/devise/omniauth_registrations_controller.rb', line 11
def new
@form = form(OmniauthRegistrationForm).from_params(params[:user])
end
|