From b205e9fc0fa6287bd8a3e00af301e0df265fb0d1 Mon Sep 17 00:00:00 2001 From: takahashim Date: Tue, 27 Feb 2024 00:14:55 +0900 Subject: [PATCH 1/3] Update registration view --- .../views/decidim/devise/registrations/new.html.erb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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 ffa96ae3d..4c1cd5bc7 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) %>
From d2e4bc826fb5c406dbdc63dc5b2095b96d52845e Mon Sep 17 00:00:00 2001 From: takahashim Date: Tue, 27 Feb 2024 01:53:30 +0900 Subject: [PATCH 2/3] Update Decidim::UserExtension::CreateOmniauthCommandsOverrides --- .../create_omniauth_commands_overrides.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) 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 b4372afb3..579a723ae 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 From 3a23f65979bff6a0166cf8e268ef00ea2d5ed1b6 Mon Sep 17 00:00:00 2001 From: takahashim Date: Tue, 27 Feb 2024 01:57:45 +0900 Subject: [PATCH 3/3] Update Decidim::UserExtension::UpdateCommandsOverrides --- .../decidim/user_extension/update_commands_overrides.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 d35f5d759..90ba76cdf 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