Skip to content

Commit c12f0eb

Browse files
resolved all remarks
extending userrecord added password hash and salt trailing newlines in files class documentation renamed page-manager and service-request to match the API-method
1 parent 4aa3127 commit c12f0eb

File tree

10 files changed

+86
-72
lines changed

10 files changed

+86
-72
lines changed

FirebaseAdmin/FirebaseAdmin/Auth/ExportedUserRecord.cs

Lines changed: 58 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -15,81 +15,83 @@
1515
namespace FirebaseAdmin.Auth
1616
{
1717
/// <summary>
18-
/// Contains metadata associated with a Firebase user account.
18+
/// Contains metadata associated with a Firebase user account, along with password hash and salt.
19+
/// Instances of this class are immutable and thread safe.
1920
/// </summary>
20-
public sealed class ExportedUserRecord
21+
public sealed class ExportedUserRecord : UserRecord
2122
{
22-
/// <summary>
23-
/// Gets or sets the user's ID.
24-
/// </summary>
25-
public string UserId { get; set; }
26-
27-
/// <summary>
28-
/// Gets or sets the user's email address.
29-
/// </summary>
30-
public string Email { get; set; }
31-
32-
/// <summary>
33-
/// Gets or sets the user's phone number.
34-
/// </summary>
35-
public string PhoneNumber { get; set; }
36-
37-
/// <summary>
38-
/// Gets or sets a value indicating whether the user's email address is verified or not.
39-
/// </summary>
40-
public bool EmailVerified { get; set; }
23+
private readonly long createdAt;
24+
private readonly long lastLoginAt;
25+
private readonly long validSince;
26+
private readonly string passwordHash;
27+
private readonly string passwordSalt;
4128

42-
/// <summary>
43-
/// Gets or sets the user's display name.
44-
/// </summary>
45-
public string DisplayName { get; set; }
29+
internal ExportedUserRecord(string uid, long createdAt, long lastLoginAt, long validSince, string passwordHash, string passwordSalt)
30+
: base(uid)
31+
{
32+
this.createdAt = createdAt;
33+
this.lastLoginAt = lastLoginAt;
34+
this.validSince = validSince;
35+
this.passwordHash = passwordHash;
36+
this.passwordSalt = passwordSalt;
37+
}
4638

47-
/// <summary>
48-
/// Gets or sets the URL for the user's photo.
49-
/// </summary>
50-
public string PhotoUrl { get; set; }
39+
internal ExportedUserRecord(GetAccountInfoResponse.User user)
40+
: base(user)
41+
{
42+
this.createdAt = user.CreatedAt;
43+
this.lastLoginAt = user.LastLoginAt;
44+
this.validSince = user.ValidSince;
45+
this.passwordHash = user.PasswordHash;
46+
this.passwordSalt = user.PasswordSalt;
47+
}
5148

5249
/// <summary>
53-
/// Gets or sets a value indicating whether the user is disabled or not.
50+
/// Gets the timestamp representing the time that the user account was created.
5451
/// </summary>
55-
public bool Disabled { get; set; }
52+
public long CreatedAt
53+
{
54+
get => this.createdAt;
55+
}
5656

5757
/// <summary>
58-
/// Gets or sets the timestamp representing the time that the user account was created.
58+
/// Gets the timestamp representing the last time that the user has logged in.
5959
/// </summary>
60-
public long CreatedAt { get; set; }
60+
public long LastLoginAt
61+
{
62+
get => this.lastLoginAt;
63+
}
6164

6265
/// <summary>
63-
/// Gets or sets the timestamp representing the last time that the user has logged in.
66+
/// Gets the timestamp representing the time that the user account was first valid.
6467
/// </summary>
65-
public long LastLoginAt { get; set; }
68+
public long ValidSince
69+
{
70+
get => this.validSince;
71+
}
6672

6773
/// <summary>
68-
/// Gets or sets the timestamp representing the time that the user account was first valid.
74+
/// Gets the user's password hash as a base64-encoded string.
75+
/// If the Firebase Auth hashing algorithm (SCRYPT) was used to create the user account,
76+
/// returns the base64-encoded password hash of the user.If a different hashing algorithm was
77+
/// used to create this user, as is typical when migrating from another Auth system, returns
78+
/// an empty string. Returns null if no password is set.
6979
/// </summary>
70-
public long ValidSince { get; set; }
80+
public string PasswordHash
81+
{
82+
get => this.passwordHash;
83+
}
7184

7285
/// <summary>
73-
/// Gets or sets the user's custom claims.
86+
/// Gets the user's password salt as a base64-encoded string.
87+
/// If the Firebase Auth hashing algorithm (SCRYPT) was used to create the user account,
88+
/// returns the base64-encoded password salt of the user.If a different hashing algorithm was
89+
/// used to create this user, as is typical when migrating from another Auth system, returns
90+
/// an empty string. Returns null if no password is set.
7491
/// </summary>
75-
public string CustomClaims { get; set; }
76-
77-
internal static ExportedUserRecord CreateFrom(GetAccountInfoResponse.User userRecord)
92+
public string PasswordSalt
7893
{
79-
return new ExportedUserRecord
80-
{
81-
UserId = userRecord.UserId,
82-
Email = userRecord.Email,
83-
PhoneNumber = userRecord.PhoneNumber,
84-
EmailVerified = userRecord.EmailVerified,
85-
DisplayName = userRecord.DisplayName,
86-
PhotoUrl = userRecord.PhotoUrl,
87-
Disabled = userRecord.Disabled,
88-
CreatedAt = userRecord.CreatedAt,
89-
LastLoginAt = userRecord.LastLoginAt,
90-
ValidSince = userRecord.ValidSince,
91-
CustomClaims = userRecord.CustomClaims,
92-
};
94+
get => this.passwordSalt;
9395
}
9496
}
95-
}
97+
}

FirebaseAdmin/FirebaseAdmin/Auth/ExportedUserRecords.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ public sealed class ExportedUserRecords
3131
/// </summary>
3232
public List<ExportedUserRecord> Users { get; set; }
3333
}
34-
}
34+
}

FirebaseAdmin/FirebaseAdmin/Auth/FirebaseAuth.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,9 +357,9 @@ public PagedAsyncEnumerable<ExportedUserRecords, ExportedUserRecord> ListUsersAs
357357
{
358358
var userManager = this.IfNotDeleted(() => this.userManager.Value);
359359

360-
var restPagedAsyncEnumerable = new RestPagedAsyncEnumerable<UserRecordServiceRequest, ExportedUserRecords, ExportedUserRecord>(
360+
var restPagedAsyncEnumerable = new RestPagedAsyncEnumerable<ListUsersRequest, ExportedUserRecords, ExportedUserRecord>(
361361
() => userManager.CreateUserRecordServiceRequest(requestOptions),
362-
new UserRecordPageManager());
362+
new ListUsersPageManager());
363363

364364
return restPagedAsyncEnumerable;
365365
}

FirebaseAdmin/FirebaseAdmin/Auth/FirebaseUserManager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ public async Task<UserRecord> GetUserById(
9999
return new UserRecord(user);
100100
}
101101

102-
public UserRecordServiceRequest CreateUserRecordServiceRequest(ListUsersOptions requestOptions)
102+
public ListUsersRequest CreateUserRecordServiceRequest(ListUsersOptions requestOptions)
103103
{
104-
return new UserRecordServiceRequest(this.baseUrl, this.httpClient, requestOptions);
104+
return new ListUsersRequest(this.baseUrl, this.httpClient, requestOptions);
105105
}
106106

107107
/// <summary>

FirebaseAdmin/FirebaseAdmin/Auth/Internal/DownloadAccountResponse.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ internal class DownloadAccountResponse
3434
[JsonProperty("users")]
3535
public List<GetAccountInfoResponse.User> Users { get; set; }
3636
}
37-
}
37+
}

FirebaseAdmin/FirebaseAdmin/Auth/Internal/GetAccountInfoResponse.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,18 @@ internal sealed class User
3737
[JsonProperty(PropertyName = "email")]
3838
public string Email { get; set; }
3939

40+
/// <summary>
41+
/// Gets or sets the user's password hash.
42+
/// </summary>
43+
[JsonProperty(PropertyName = "passwordHash")]
44+
public string PasswordHash { get; set; }
45+
46+
/// <summary>
47+
/// Gets or sets the user's password salt.
48+
/// </summary>
49+
[JsonProperty(PropertyName = "salt")]
50+
public string PasswordSalt { get; set; }
51+
4052
/// <summary>
4153
/// Gets or sets the user's phone number.
4254
/// </summary>

FirebaseAdmin/FirebaseAdmin/Auth/ListUsersOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ public sealed class ListUsersOptions
3535
/// </summary>
3636
public string PageToken { get; set; }
3737
}
38-
}
38+
}

FirebaseAdmin/FirebaseAdmin/Auth/UserRecordPageManager.cs renamed to FirebaseAdmin/FirebaseAdmin/Auth/ListUsersPageManager.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@
1717

1818
namespace FirebaseAdmin.Auth
1919
{
20-
internal class UserRecordPageManager : IPageManager<UserRecordServiceRequest, ExportedUserRecords, ExportedUserRecord>
20+
internal class ListUsersPageManager : IPageManager<ListUsersRequest, ExportedUserRecords, ExportedUserRecord>
2121
{
22-
public void SetPageSize(UserRecordServiceRequest request, int pageSize)
22+
public void SetPageSize(ListUsersRequest request, int pageSize)
2323
{
2424
request.SetPageSize(pageSize);
2525
}
2626

27-
public void SetPageToken(UserRecordServiceRequest request, string pageToken)
27+
public void SetPageToken(ListUsersRequest request, string pageToken)
2828
{
2929
request.SetPageToken(pageToken);
3030
}
@@ -44,4 +44,4 @@ public string GetNextPageToken(ExportedUserRecords response)
4444
return string.IsNullOrEmpty(response.NextPageToken) ? null : response.NextPageToken;
4545
}
4646
}
47-
}
47+
}

FirebaseAdmin/FirebaseAdmin/Auth/UserRecordServiceRequest.cs renamed to FirebaseAdmin/FirebaseAdmin/Auth/ListUsersRequest.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@
2626

2727
namespace FirebaseAdmin.Auth
2828
{
29-
internal class UserRecordServiceRequest : IClientServiceRequest<ExportedUserRecords>
29+
internal class ListUsersRequest : IClientServiceRequest<ExportedUserRecords>
3030
{
3131
private readonly string baseUrl;
3232
private readonly HttpClient httpClient;
3333
private readonly ListUsersOptions requestOptions;
3434

35-
internal UserRecordServiceRequest(string baseUrl, HttpClient httpClient, ListUsersOptions requestOptions)
35+
internal ListUsersRequest(string baseUrl, HttpClient httpClient, ListUsersOptions requestOptions)
3636
{
3737
this.baseUrl = baseUrl;
3838
this.httpClient = httpClient;
@@ -113,7 +113,7 @@ public ExportedUserRecords Execute()
113113
private static ExportedUserRecords ConvertToExportedUserRecords(DownloadAccountResponse downloadAccountResponse)
114114
{
115115
var userRecords = new List<ExportedUserRecord>();
116-
downloadAccountResponse.Users?.ForEach(u => userRecords.Add(ExportedUserRecord.CreateFrom(u)));
116+
downloadAccountResponse.Users?.ForEach(u => userRecords.Add(new ExportedUserRecord(u)));
117117
return new ExportedUserRecords { NextPageToken = downloadAccountResponse.NextPageToken, Users = userRecords };
118118
}
119119

@@ -178,4 +178,4 @@ private void AddOrUpdate(string paramName, string value)
178178
}
179179
}
180180
}
181-
}
181+
}

FirebaseAdmin/FirebaseAdmin/Auth/UserRecord.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace FirebaseAdmin.Auth
2525
/// Contains metadata associated with a Firebase user account. Instances
2626
/// of this class are immutable and thread safe.
2727
/// </summary>
28-
public sealed class UserRecord : IUserInfo
28+
public class UserRecord : IUserInfo
2929
{
3030
private const string PROVIDERID = "firebase";
3131

0 commit comments

Comments
 (0)