Skip to content

Commit

Permalink
feat(migrations): Import password digests from Greenlight2 (#5507)
Browse files Browse the repository at this point in the history
* feat(migrations): Import password digests from Greenlight2

* Update external_controller.rb

* Update external_controller.rb

---------

Co-authored-by: Ahmad Farhat <[email protected]>
Co-authored-by: Ahmad Farhat <[email protected]>
  • Loading branch information
3 people authored Nov 20, 2023
1 parent a21088d commit 6227a46
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions app/controllers/api/v1/migrations/external_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def create_role
end

# POST /api/v1/migrations/users.json
# Expects: { user: { :name, :email, :external_id, :language, :role } }
# Expects: { user: { :name, :email, :password_digest, :provider, :external_id, :language, :role } }
# Returns: { data: Array[serializable objects] , errors: Array[String] }
# Does: Creates a user.
def create_user
Expand Down Expand Up @@ -103,10 +103,8 @@ def create_user

return render_error(status: :bad_request, errors: user&.errors&.to_a) unless user.save

if user_hash[:provider] != 'greenlight'
user.password_digest = nil
user.save(validations: false)
end
user.password_digest = user_hash[:provider] == 'greenlight' ? user_hash[:password_digest] : nil
user.save(validations: false)

render_data status: :created
end
Expand Down Expand Up @@ -228,7 +226,7 @@ def role_params
end

def user_params
decrypted_params.require(:user).permit(:name, :email, :provider, :external_id, :language, :role, :created_at)
decrypted_params.require(:user).permit(:name, :email, :password_digest, :provider, :external_id, :language, :role, :created_at)
end

def room_params
Expand Down

0 comments on commit 6227a46

Please sign in to comment.