diff --git a/decidim-user_extension/app/commands/concerns/decidim/user_extension/create_omniauth_commands_overrides.rb b/decidim-user_extension/app/commands/concerns/decidim/user_extension/create_omniauth_commands_overrides.rb index b4372afb38..579a723ae3 100644 --- a/decidim-user_extension/app/commands/concerns/decidim/user_extension/create_omniauth_commands_overrides.rb +++ b/decidim-user_extension/app/commands/concerns/decidim/user_extension/create_omniauth_commands_overrides.rb @@ -11,8 +11,6 @@ module CreateOmniauthCommandsOverrides private def create_or_find_user - generated_password = SecureRandom.hex - @user = User.find_or_initialize_by( email: verified_email, organization: organization @@ -24,14 +22,21 @@ def create_or_find_user # to be marked confirmed. @user.skip_confirmation! if !@user.confirmed? && @user.email == verified_email else + generated_password = SecureRandom.hex + @user.email = (verified_email || form.email) @user.name = form.name @user.nickname = form.normalized_nickname @user.newsletter_notifications_at = nil - @user.email_on_notification = true @user.password = generated_password @user.password_confirmation = generated_password @user.remote_avatar_url = form.avatar_url if form.avatar_url.present? + if form.avatar_url.present? + url = URI.parse(form.avatar_url) + filename = File.basename(url.path) + file = url.open + @user.avatar.attach(io: file, filename: filename) + end @user.skip_confirmation! if verified_email end diff --git a/decidim-user_extension/app/commands/concerns/decidim/user_extension/update_commands_overrides.rb b/decidim-user_extension/app/commands/concerns/decidim/user_extension/update_commands_overrides.rb index d35f5d7598..90ba76cdf1 100644 --- a/decidim-user_extension/app/commands/concerns/decidim/user_extension/update_commands_overrides.rb +++ b/decidim-user_extension/app/commands/concerns/decidim/user_extension/update_commands_overrides.rb @@ -21,7 +21,9 @@ def call notify_followers broadcast(:ok, @user.unconfirmed_email.present?) else - @form.errors.add :avatar, @user.errors[:avatar] if @user.errors.has_key? :avatar + [:avatar, :password, :password_confirmation].each do |key| + @form.errors.add key, @user.errors[key] if @user.errors.has_key? key + end broadcast(:invalid) end end diff --git a/decidim-user_extension/app/views/decidim/devise/registrations/new.html.erb b/decidim-user_extension/app/views/decidim/devise/registrations/new.html.erb index ffa96ae3d5..4c1cd5bc7a 100644 --- a/decidim-user_extension/app/views/decidim/devise/registrations/new.html.erb +++ b/decidim-user_extension/app/views/decidim/devise/registrations/new.html.erb @@ -34,28 +34,28 @@
<%= t(".nickname_notice") %>