Skip to content

Commit

Permalink
Refresh Thread bug fixes, add offline support for stateful end user c…
Browse files Browse the repository at this point in the history
…lient. (#63)

* Add xml docs

* Move refresh logic to class. Fixes.

Moved refresh logic to another class. Now the thread gets turned on/off automatically per auth state changes. Commit looks noisy than should because of format tweaks, sorry. :/

* XML doc. Remove redundant auth state notification.

* xml doc

* Moved token refresh logic here.

* Add expired token test

* Add log in/log out test

* Add maximum refresh wait time

* Add utility to check if the session has expired

All of the calls to check for expiration in the current implementation were checking to see if the session had expired.

* Adding Unity samples

* Add support for online/offline

* Method name to match RetrieveSessionAsync();

* Added description of updates
  • Loading branch information
wiverson committed Jun 17, 2023
1 parent a52a332 commit 4ec3e3e
Show file tree
Hide file tree
Showing 22 changed files with 965 additions and 363 deletions.
10 changes: 10 additions & 0 deletions Gotrue/Api.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@

namespace Supabase.Gotrue
{
/// <summary>
/// The REST calls to the Gotrue API.
/// </summary>
public class Api : IGotrueApi<User, Session>
{
private string Url { get; }
Expand All @@ -25,6 +28,9 @@ public class Api : IGotrueApi<User, Session>
public Func<Dictionary<string, string>>? GetHeaders { get; set; }

private Dictionary<string, string> _headers;
/// <summary>
/// Headers to be sent with every request. These will be merged with any headers returned by GetHeaders.
/// </summary>
protected Dictionary<string, string> Headers
{
get => GetHeaders != null ? GetHeaders().MergeLeft(_headers) : _headers;
Expand Down Expand Up @@ -585,6 +591,10 @@ public Task<BaseResponse> DeleteUser(string uid, string jwt)
return Helpers.MakeRequest(HttpMethod.Delete, $"{Url}/admin/users/{uid}", data, CreateAuthedRequestHeaders(jwt));
}

/// <summary>
/// Calls the GoTrue server to get the settings (for example, if email auto confirmation is turned on)
/// </summary>
/// <returns></returns>
public Task<Settings?> Settings()
{
return Helpers.MakeRequest<Settings>(HttpMethod.Get, $"{Url}/settings", null, Headers);
Expand Down
Loading

0 comments on commit 4ec3e3e

Please sign in to comment.