My problem is when I send nil as value in some of users attributes it doesnt remove that attribute on auth0 side. On the auth menagement api if I use null as value in User update jason it removes that user field.
def self.auth0_update_user user, user_id
Auth0M2MClient.instance.with_client do |client|
auth0_user = client.user(user_id)
content = user_update_details(user, auth0_user)
client.update_user(user_id, content)
end
end
this is my json and if I put any string there it update user attribute on auth0
(byebug) content
{“family_name”=>nil, “given_name”=>nil, “email”=>“user328@user.com”}
I can confirm, passing a null value to the API should remove the existing value for the field.
This leads me to believe this is either a bug in the SDK, or an issue with the request. What is the response if you were to pass {“family_name”=>nil} to the update user function?
Hey Dan, thank you for quick replay. Here is a sample in ruby console for you question, its responds with ‘fields required, and it also mentioning that family_name her so it looks like it doesnt reach the API, neither’:
Hey Dan, thank you for your replay. Here is my code:
def self.auth0_update_user user, user_id
Auth0M2MClient.instance.with_client do |client|
content = user_update_details(user)
client.update_user(user_id, content)
# user_update_details method above generating hash or you can use this below:
# in example I am setting given_name as nil and that should remove users attributes on auth0
# client.update_user(user_id, {
# "email": user.email,
# "given_name": nil,
# "family_name": user.family_name
# })
end
end
def self.user_update_details user
['family_name', 'given_name', 'email'].inject({}) do |res, field|
case field
when 'email'
res.merge!({ field => set_email(user) })
else
if user.send(field).present?
res.merge!({ field => user.send(field) })
else
#here I am adding nil to keys/attributes who doesnt have a value
res.merge!({ field => nil })
end
end
end
end
As I mention this is on update user. I hope this is enough for testing if not please ping me.