Skip to content

Commit dc3ffe3

Browse files
author
Dominik Földi
committed
Make FirebaseUserManager constructor internal to be able to use it in tests and add error handling if the response of the update API contains incorrect data
1 parent 12fffc4 commit dc3ffe3

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

FirebaseAdmin/FirebaseAdmin/Auth/FirebaseUserManager.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ internal class FirebaseUserManager : IDisposable
3636
private readonly ConfigurableHttpClient _httpClient;
3737
private readonly string _baseUrl;
3838

39-
private FirebaseUserManager(FirebaseUserManagerArgs args)
39+
internal FirebaseUserManager(FirebaseUserManagerArgs args)
4040
{
4141
_httpClient = args.ClientFactory.CreateAuthorizedHttpClient(args.Credential);
4242
_baseUrl = string.Format(ID_TOOLKIT_URL, args.ProjectId);
@@ -52,8 +52,15 @@ public async Task UpdateUserAsync(UserRecord user)
5252
var updatePath = "/accounts:update";
5353
var resopnse = await PostAsync(updatePath, user);
5454

55-
var userResponse = resopnse.ToObject<UserRecord>();
56-
if (userResponse == null || userResponse.Uid != user.Uid)
55+
try
56+
{
57+
var userResponse = resopnse.ToObject<UserRecord>();
58+
if (userResponse.Uid != user.Uid)
59+
{
60+
throw new FirebaseException(INTERNAL_ERROR);
61+
}
62+
}
63+
catch (Exception)
5764
{
5865
throw new FirebaseException(INTERNAL_ERROR);
5966
}

0 commit comments

Comments
 (0)