From 699badbd3121037dbeb4df8216bac68a49fa762c Mon Sep 17 00:00:00 2001 From: Daniel Molkentin Date: Thu, 28 Mar 2024 15:00:28 +0100 Subject: [PATCH] fix(migrations): Set user password_digest only if it was received --- app/controllers/api/v1/migrations/external_controller.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/controllers/api/v1/migrations/external_controller.rb b/app/controllers/api/v1/migrations/external_controller.rb index 39ab29703d..ed11ebec6c 100644 --- a/app/controllers/api/v1/migrations/external_controller.rb +++ b/app/controllers/api/v1/migrations/external_controller.rb @@ -103,8 +103,13 @@ def create_user return render_error(status: :bad_request, errors: user&.errors&.to_a) unless user.save - user.password_digest = user_hash[:provider] == 'greenlight' ? user_hash[:password_digest] : nil - user.save(validations: false) + if user_hash[:provider] != 'greenlight' + user.password_digest = nil + user.save(validations: false) + elsif user_hash[:password_digest] + user.password_digest = user_hash[:password_digest] + user.save(validations: false) + end render_data status: :created end