Skip to content

Commit

Permalink
Merge pull request codeforjapan#594 from codeforjapan/update-decidim-…
Browse files Browse the repository at this point in the history
…view

decidim-user_extensionをv0.27.4に合わせて更新
  • Loading branch information
ayuki-joto authored Feb 27, 2024
2 parents 53252ff + 3a23f65 commit 54a1f52
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,28 +34,28 @@

<div class="user-person">
<div class="field">
<%= 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") %>
</div>
</div>

<div class="user-nickname">
<div class="field">
<%= 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") %>
</div>
</div>

<p class="text-small"><%= t(".nickname_notice") %></p>

<div class="field">
<%= f.email_field :email %>
<%= f.email_field :email, autocomplete: "email" %>
</div>

<div class="field">
<%= 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) %>
</div>

<div class="field">
<%= f.password_field :password_confirmation %>
<%= f.password_field :password_confirmation, password_field_options_for(:user).except(:help_text) %>
</div>

<!-- extension begin -->
Expand Down

0 comments on commit 54a1f52

Please sign in to comment.