-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🐛 Bug Report: Bug acquiring users on server side #30
Comments
Discussion on Discord: https://discord.com/channels/564160730845151244/564160731327758347/1192519235017113600 |
My quick fix was this on User.cs. Open to better solution. I only identified as potential "nulls" password, hash and hashOptions. I don't know whether all other fields are always populated for every user account. private static object? getFromMap(Dictionary<string, object> map, string key) |
Thanks for your quick fix, but I think your map.TryGetValue(key,out val); A more compact version would be: private static object? getFromMap(Dictionary<string, object> map, string key)
{
return map.TryGetValue(key, out var val) ? val.toString() : null;
} |
My suggestion would probably be to change it inline as follows: public static User From(Dictionary<string, object> map)
{
return new User(
id: map["$id"].ToString(),
createdAt: map["$createdAt"].ToString(),
updatedAt: map["$updatedAt"].ToString(),
name: map["name"].ToString(),
password: map.TryGetValue("password", out var password) ? password.ToString() : null,
hash: map.TryGetValue("hash", out var hash) ? hash.ToString() : null,
hashOptions: map.TryGetValue("hashOptions", out var hashOptions) ? hashOptions.ToString() : null,
registration: map["registration"].ToString(),
status: (bool)map["status"],
labels: ((JArray)map["labels"]).ToObject<List<object>>(),
passwordUpdate: map["passwordUpdate"].ToString(),
email: map["email"].ToString(),
phone: map["phone"].ToString(),
emailVerification: (bool)map["emailVerification"],
phoneVerification: (bool)map["phoneVerification"],
prefs: Preferences.From(((JObject)map["prefs"]).ToObject<Dictionary<string, object>>()),
accessedAt: map["accessedAt"].ToString());
} So we would not need to add an extra function. And I would use named parameters when creating the |
yep, I hardcoded for testing "password" and forgot to remove it. Glad there is a fix already on the way. |
👟 Reproduction steps
this method:
sdk-for-dotnet/src/Appwrite/Models/User.cs
Lines 102 to 120 in 5c20443
the issue is that when you do this on the server from the JWT token:
The way it does this internally is that Get() makes an api call, retrieves a dictionary and then calls the User.From
since the dictionary does not retrieve the password, you get an exception with Key not found "password" and it crashes
meaning you can never retrieve a user on the server side, never
exact exception details details
👍 Expected behavior
it should create an user instance with the missing information (no password)
👎 Actual Behavior
exception as explained, and no user created
🎲 Appwrite version
Version 0.10.x
💻 Operating system
Windows
🧱 Your Environment
No response
👀 Have you spent some time to check if this issue has been raised before?
🏢 Have you read the Code of Conduct?
The text was updated successfully, but these errors were encountered: