Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mirror ResetPasswordForEmail into StatelessClient #12

Merged
merged 1 commit into from
Dec 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions Gotrue/StatelessClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,26 @@ public static async Task<bool> InviteUserByEmail(string email, string jwt, State
}
}

/// <summary>
/// Sends a reset request to an email address.
/// </summary>
/// <param name="email"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public static async Task<bool> ResetPasswordForEmail(string email, StatelessClientOptions options)
{
try
{
var result = await GetApi(options).ResetPasswordForEmail(email);
result.ResponseMessage.EnsureSuccessStatusCode();
return true;
}
catch (RequestException ex)
{
throw ExceptionHandler.Parse(ex);
}
}

/// <summary>
/// Deletes a User.
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions GotrueTests/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,8 @@ public async Task ClientDeletesUser()
var result = await client.DeleteUser(uid, service_role_key);

Assert.IsTrue(result);
}
}

[TestMethod("Client: Sends Reset Password Email")]
public async Task ClientSendsResetPasswordForEmail()
{
Expand Down
11 changes: 9 additions & 2 deletions GotrueTests/StatelessClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ namespace GotrueTests
[TestClass]
public class StatelessClient
{
private Client client;

private string password = "I@M@SuperP@ssWord";

private static Random random = new Random();
Expand Down Expand Up @@ -221,5 +219,14 @@ public async Task DeletesUser()

Assert.IsTrue(result);
}

[TestMethod("StatelessClient: Sends Reset Password Email")]
public async Task ClientSendsResetPasswordForEmail()
{
var email = $"{RandomString(12)}@supabase.io";
await SignUp(email, password, options);
var result = await ResetPasswordForEmail(email, options);
Assert.IsTrue(result);
}
}
}