@@ -102,8 +102,8 @@ internal async Task<UserRecord> GetUserByIdAsync(
102102 var query = new UserQuery ( )
103103 {
104104 Field = "localId" ,
105- Value = uid ,
106- Label = "uid" ,
105+ Value = new string [ ] { uid } ,
106+ Description = "uid: " + uid ,
107107 } ;
108108 return await this . GetUserAsync ( query , cancellationToken )
109109 . ConfigureAwait ( false ) ;
@@ -127,7 +127,56 @@ internal async Task<UserRecord> GetUserByEmailAsync(
127127 var query = new UserQuery ( )
128128 {
129129 Field = "email" ,
130- Value = email ,
130+ Value = new string [ ] { email } ,
131+ Description = "email: " + email ,
132+ } ;
133+ return await this . GetUserAsync ( query , cancellationToken )
134+ . ConfigureAwait ( false ) ;
135+ }
136+
137+ /// <summary>
138+ /// Gets the user data corresponding to the given provider user identifer.
139+ /// </summary>
140+ /// <param name="providerId">Identifier for the given provider, for example,
141+ /// "google.com" for the Google provider.</param>
142+ /// <param name="providerUid">The user identifier with the given provider.</param>
143+ /// <param name="cancellationToken">A cancellation token to monitor the asynchronous
144+ /// operation.</param>
145+ /// <returns>A record of user with the queried provider user identifier if one exists.</returns>
146+ internal async Task < UserRecord > GetUserByProviderUidAsync (
147+ string providerId , string providerUid , CancellationToken cancellationToken = default ( CancellationToken ) )
148+ {
149+ if ( string . IsNullOrEmpty ( providerId ) )
150+ {
151+ throw new ArgumentException ( "providerId cannot be null or empty." ) ;
152+ }
153+
154+ if ( string . IsNullOrEmpty ( providerUid ) )
155+ {
156+ throw new ArgumentException ( "providerUid cannot be null or empty." ) ;
157+ }
158+
159+ if ( providerId . Equals ( "phone" ) )
160+ {
161+ return await this . GetUserByPhoneNumberAsync ( providerUid , cancellationToken ) ;
162+ }
163+
164+ if ( providerId . Equals ( "email" ) )
165+ {
166+ return await this . GetUserByEmailAsync ( providerUid , cancellationToken ) ;
167+ }
168+
169+ var federatedUserId = new Dictionary < string , object > ( )
170+ {
171+ { "rawId" , providerUid } ,
172+ { "providerId" , providerId } ,
173+ } ;
174+
175+ var query = new UserQuery ( )
176+ {
177+ Field = "federatedUserId" ,
178+ Value = new Dictionary < string , object > [ ] { federatedUserId } ,
179+ Description = "providerId: " + providerId + ", providerUid: " + providerUid ,
131180 } ;
132181 return await this . GetUserAsync ( query , cancellationToken )
133182 . ConfigureAwait ( false ) ;
@@ -151,8 +200,8 @@ internal async Task<UserRecord> GetUserByPhoneNumberAsync(
151200 var query = new UserQuery ( )
152201 {
153202 Field = "phoneNumber" ,
154- Value = phoneNumber ,
155- Label = "phone number" ,
203+ Value = new string [ ] { phoneNumber } ,
204+ Description = "phone number: " + phoneNumber ,
156205 } ;
157206 return await this . GetUserAsync ( query , cancellationToken )
158207 . ConfigureAwait ( false ) ;
@@ -301,37 +350,23 @@ internal sealed class Args
301350 /// <summary>
302351 /// Represents a query that can be executed against the Firebase Auth service to retrieve user records.
303352 /// A query mainly consists of a <see cref="UserQuery.Field"/> and a <see cref="UserQuery.Value"/> (e.g.
304- /// <c>Field = localId</c> and <c>Value = alice</c>). Additionally, a query may also specify a more
305- /// human-readable <see cref="UserQuery.Label "/> for the field , which will appear on any error messages
353+ /// <c>Field = localId</c> and <c>Value = alice</c>). Additionally, a query also specifies a more
354+ /// human-readable <see cref="UserQuery.Description "/> for the key-value , which will appear on any error messages
306355 /// produced by the query.
307356 /// </summary>
308357 private class UserQuery
309358 {
310359 internal string Field { get ; set ; }
311360
312- internal string Value { get ; set ; }
313-
314- internal string Label { get ; set ; }
361+ internal object Value { get ; set ; }
315362
316- internal string Description
317- {
318- get
319- {
320- var label = this . Label ;
321- if ( string . IsNullOrEmpty ( label ) )
322- {
323- label = this . Field ;
324- }
325-
326- return $ "{ label } : { this . Value } ";
327- }
328- }
363+ internal string Description { get ; set ; }
329364
330365 internal Dictionary < string , object > Build ( )
331366 {
332367 return new Dictionary < string , object > ( )
333368 {
334- { this . Field , new string [ ] { this . Value } } ,
369+ { this . Field , this . Value } ,
335370 } ;
336371 }
337372 }
0 commit comments