-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
omniauth: prevent sending a verification email
`omniauth_registrations_controller.rb` fails to create an account when the provider doesn't include a required field. This results in the form being re-rendered leading to a second `#create` call and the creation of a new `request.env`, causing the loss of data populated by OAuth and triggering an email confirmation. See: https://github.com/decidim/decidim/blob/release/0.26-stable/decidim-core/app/commands/decidim/create_omniauth_registration.rb#L75 This patch relies on the `params` to get the `verified_email`. Closes: #147
- Loading branch information
samanera
committed
Nov 3, 2023
1 parent
23ebd01
commit f60ceea
Showing
3 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
app/overrides/controllers/decidim/devise/omniauth_registrations_controller_override.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Decidim::Devise::OmniauthRegistrationsController.class_eval do | ||
private | ||
|
||
def verified_email | ||
@verified_email ||= oauth_data.dig(:info, :email) || params.dig(:user, :email) | ||
end | ||
end |
46 changes: 46 additions & 0 deletions
46
app/views/decidim/devise/omniauth_registrations/new.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<div class="wrapper"> | ||
<div class="row collapse"> | ||
<div class="row collapse"> | ||
<div class="columns large-8 large-centered text-center page-title"> | ||
<h1><%= t(".sign_up") %></h1> | ||
<p> | ||
<%= t(".subtitle") %> | ||
</p> | ||
</div> | ||
</div> | ||
|
||
<div class="row"> | ||
<div class="columns large-6 medium-10 medium-centered"> | ||
<div class="card"> | ||
<div class="card__content"> | ||
<%= decidim_form_for(@form, namespace: "registration", as: resource_name, url: omniauth_registrations_path(resource_name), html: { class: "register-form new_user" }) do |f| %> | ||
<%= form_required_explanation %> | ||
|
||
<div class="user-person"> | ||
<div class="field"> | ||
<%= f.text_field :name, help_text: t(".username_help") %> | ||
</div> | ||
</div> | ||
|
||
<div class="user-person"> | ||
<div class="field"> | ||
<% @form.nickname = nil %> | ||
<%= f.text_field :nickname, help_text: t(".nickname_help", organization: current_organization.name) %> | ||
</div> | ||
</div> | ||
|
||
<%= f.hidden_field :email %> | ||
<%= f.hidden_field :uid %> | ||
<%= f.hidden_field :provider %> | ||
<%= f.hidden_field :oauth_signature %> | ||
|
||
<div class="actions"> | ||
<%= f.submit t(".complete_profile"), class: "button expanded" %> | ||
</div> | ||
<% end %> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |