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 @@
- <%= f.text_field :name, help_text: t(".username_help"), placeholder: t(".username_placeholder") %> + <%= f.text_field :name, help_text: t(".username_help"), autocomplete: "name", placeholder: t(".username_placeholder") %>
- <%= f.text_field :nickname, help_text: t(".nickname_help", organization: current_organization.name), prefix: { value: "@", small: 1, large: 1 }, placeholder: t(".nickname_placeholder") %> + <%= f.text_field :nickname, help_text: t(".nickname_help", organization: current_organization.name), prefix: { value: "@", small: 1, large: 1 }, autocomplete: "nickname", placeholder: t(".nickname_placeholder") %>

<%= t(".nickname_notice") %>

- <%= f.email_field :email %> + <%= f.email_field :email, autocomplete: "email" %>
- <%= f.password_field :password, help_text: t(".password_help", minimun_characters: ::PasswordValidator::MINIMUM_LENGTH), autocomplete: "off" %> + <%= f.password_field :password, password_field_options_for(:user) %>
- <%= f.password_field :password_confirmation %> + <%= f.password_field :password_confirmation, password_field_options_for(:user).except(:help_text) %>