internal ExportedUserRecord(GetAccountInfoResponse.User user) : base(user) { // If the password hash is redacted (probably due to missing permissions) then clear it // out, similar to how the salt is returned. (Otherwise, it *looks* like a b64-encoded // hash is present, which is confusing.) this.PasswordHash = user.PasswordHash == B64Redacted ? null : user.PasswordHash; this.PasswordSalt = user.PasswordSalt; }
/// <summary> /// Initializes a new instance of the <see cref="UserRecord"/> class from an existing /// instance of the <see cref="GetAccountInfoResponse.User"/> class. /// </summary> /// <param name="user">The <see cref="GetAccountInfoResponse.User"/> instance to copy /// the user's data from.</param> internal UserRecord(GetAccountInfoResponse.User user) { if (user == null) { throw new ArgumentException("User object must not be null or empty."); } else if (string.IsNullOrEmpty(user.UserId)) { throw new ArgumentException("User ID must not be null or empty."); } this.Uid = user.UserId; this.Email = user.Email; this.PhoneNumber = user.PhoneNumber; this.EmailVerified = user.EmailVerified; this.DisplayName = user.DisplayName; this.PhotoUrl = user.PhotoUrl; this.Disabled = user.Disabled; if (user.Providers == null || user.Providers.Count == 0) { this.ProviderData = new IUserInfo[0]; } else { var count = user.Providers.Count; this.ProviderData = new IUserInfo[count]; for (int i = 0; i < count; i++) { this.ProviderData[i] = new ProviderUserInfo(user.Providers[i]); } } this.validSinceTimestampInSeconds = user.ValidSince; // newtonsoft's json deserializer will convert an iso8601 format // string to a (non-null) DateTime, returning 0001-01-01 if it's not // present in the proto. We'll compare against the epoch and only // use the deserialized value if it's bigger. DateTime?lastRefreshAt = null; if (user.LastRefreshAt > UnixEpoch) { lastRefreshAt = user.LastRefreshAt; } this.UserMetaData = new UserMetadata(user.CreatedAt, user.LastLoginAt, lastRefreshAt); this.CustomClaims = UserRecord.ParseCustomClaims(user.CustomClaims); this.TenantId = user.TenantId; }
/// <summary> /// Initializes a new instance of the <see cref="UserRecord"/> class from an existing instance of the <see cref="GetAccountInfoResponse.User"/> class. /// </summary> /// <param name="user">The <see cref="GetAccountInfoResponse.User"/> instance to copy the user's data from.</param> internal UserRecord(GetAccountInfoResponse.User user) { if (user == null) { throw new ArgumentException("User object must not be null or empty."); } else if (string.IsNullOrEmpty(user.UserId)) { throw new ArgumentException("User ID must not be null or empty."); } this.uid = user.UserId; this.email = user.Email; this.phoneNumber = user.PhoneNumber; this.emailVerified = user.EmailVerified; this.displayName = user.DisplayName; this.photoUrl = user.PhotoUrl; this.disabled = user.Disabled; if (user.Providers == null || user.Providers.Count == 0) { this.providers = new List <ProviderUserInfo>(); } else { var count = user.Providers.Count; this.providers = new List <ProviderUserInfo>(count); for (int i = 0; i < count; i++) { this.providers.Add(new ProviderUserInfo(user.Providers[i])); } } this.tokensValidAfterTimestamp = user.ValidSince * 1000; this.userMetaData = new UserMetadata(user.CreatedAt, user.LastLoginAt); this.customClaims = UserRecord.ParseCustomClaims(user.CustomClaims); }
/// <summary> /// Initializes a new instance of the <see cref="UserRecord"/> class from an existing instance of the /// <see cref="GetAccountInfoResponse.User"/> class. /// </summary> /// <param name="user">The <see cref="GetAccountInfoResponse.User"/> instance to copy the user's data /// from.</param> internal UserRecord(GetAccountInfoResponse.User user) { if (user == null) { throw new ArgumentException("User object must not be null or empty."); } else if (string.IsNullOrEmpty(user.UserId)) { throw new ArgumentException("User ID must not be null or empty."); } this.Uid = user.UserId; this.Email = user.Email; this.PhoneNumber = user.PhoneNumber; this.EmailVerified = user.EmailVerified; this.DisplayName = user.DisplayName; this.PhotoUrl = user.PhotoUrl; this.Disabled = user.Disabled; if (user.Providers == null || user.Providers.Count == 0) { this.ProviderData = new IUserInfo[0]; } else { var count = user.Providers.Count; this.ProviderData = new IUserInfo[count]; for (int i = 0; i < count; i++) { this.ProviderData[i] = new ProviderUserInfo(user.Providers[i]); } } this.validSinceTimestampInSeconds = user.ValidSince; this.UserMetaData = new UserMetadata(user.CreatedAt, user.LastLoginAt); this.CustomClaims = UserRecord.ParseCustomClaims(user.CustomClaims); }