Skip to content

Commit 28254a5

Browse files
authored
Merge pull request #92 from HeavyMachineGun/master
Change user password
2 parents ed86e04 + 4228145 commit 28254a5

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/Firebase.Auth/FirebaseAuthProvider.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ public class FirebaseAuthProvider : IDisposable, IFirebaseAuthProvider
2424
private const string GoogleGetConfirmationCodeUrl = "https://www.googleapis.com/identitytoolkit/v3/relyingparty/getOobConfirmationCode?key={0}";
2525
private const string GoogleSetAccountUrl = "https://www.googleapis.com/identitytoolkit/v3/relyingparty/setAccountInfo?key={0}";
2626
private const string GoogleCreateAuthUrl = "https://www.googleapis.com/identitytoolkit/v3/relyingparty/createAuthUri?key={0}";
27-
27+
private const string GoogleUpdateUserPassword = "https://identitytoolkit.googleapis.com/v1/accounts:update?key={0}";
28+
29+
2830
private const string ProfileDeleteDisplayName = "DISPLAY_NAME";
2931
private const string ProfileDeletePhotoUrl = "PHOTO_URL";
3032

@@ -140,7 +142,21 @@ public async Task<FirebaseAuthLink> SignInWithEmailAndPasswordAsync(string email
140142

141143
return await this.ExecuteWithPostContentAsync(GooglePasswordUrl, content).ConfigureAwait(false);
142144
}
145+
146+
/// <summary>
147+
/// Change a password from an user with his token.
148+
/// </summary>
149+
/// <param name="idToken"> The Token from an user. </param>
150+
/// <param name="password"> The new password. </param>
151+
/// <returns> The <see cref="FirebaseAuth"/>. </returns>
152+
public async Task<FirebaseAuthLink> ChangeUserPassword(string idToken, string password)
153+
{
154+
var content = $"{{\"idToken\":\"{idToken}\",\"password\":\"{password}\",\"returnSecureToken\":true}}";
143155

156+
return await this.ExecuteWithPostContentAsync(GoogleUpdateUserPassword, content).ConfigureAwait(false);
157+
}
158+
159+
144160
/// <summary>
145161
/// Creates new user with given credentials.
146162
/// </summary>

0 commit comments

Comments
 (0)