Skip to content

Commit

Permalink
Update Decidim::UserExtension::CreateOmniauthCommandsOverrides
Browse files Browse the repository at this point in the history
  • Loading branch information
takahashim committed Feb 26, 2024
1 parent b205e9f commit d2e4bc8
Showing 1 changed file with 8 additions and 3 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

0 comments on commit d2e4bc8

Please sign in to comment.