Skip to content

Commit 811765a

Browse files
authored
add method to updates User email (#132)
1 parent f21c952 commit 811765a

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/Firebase.Auth/FirebaseAuthProvider.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,19 @@ public async Task<FirebaseAuthLink> ChangeUserPassword(string idToken, string pa
199199
return await this.ExecuteWithPostContentAsync(GoogleUpdateUserPassword, content).ConfigureAwait(false);
200200
}
201201

202+
/// <summary>
203+
/// Change a email from an user with his token.
204+
/// </summary>
205+
/// <param name="idToken"> The Token from an user. </param>
206+
/// <param name="newEmail"> The new email. </param>
207+
/// <returns> The <see cref="FirebaseAuth"/>. </returns>
208+
public async Task<FirebaseAuthLink> ChangeUserEmail(string idToken, string newEmail)
209+
{
210+
var content = $"{{\"idToken\":\"{idToken}\",\"email\":\"{newEmail}\",\"returnSecureToken\":true}}";
202211

212+
return await this.ExecuteWithPostContentAsync(GoogleUpdateUserPassword, content).ConfigureAwait(false);
213+
}
214+
203215
/// <summary>
204216
/// Creates new user with given credentials.
205217
/// </summary>

src/Firebase.Auth/IFirebaseAuthProvider.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,14 @@ public interface IFirebaseAuthProvider
5454
/// <returns> The <see cref="FirebaseAuth"/>. </returns>
5555
Task<FirebaseAuthLink> SignInWithCustomTokenAsync(string customToken);
5656

57+
/// <summary>
58+
/// Updates the User email.
59+
/// </summary>
60+
/// <param name="idToken"> The idToken of an authenticated user. </param>
61+
/// <param name="newEmail"> The new email</param>
62+
/// <returns></returns>
63+
Task<FirebaseAuthLink> ChangeUserEmail(string idToken, string newEmail);
64+
5765
/// <summary>
5866
/// Updates profile (displayName and photoUrl) of user tied to given user token.
5967
/// </summary>

0 commit comments

Comments
 (0)