supabase-community / gotrue-csharp

C# implementation of Supabase's GoTrue
https://supabase-community.github.io/gotrue-csharp/api/Supabase.Gotrue.Client.html
MIT License
39 stars 27 forks source link

Session.Expired is always true #79

Closed Dayjay closed 1 year ago

Dayjay commented 1 year ago

Bug report

Describe the bug

Hello,

I am using Blazor WASM with Azure.

So far everything is fine except that Session.Expired() always returns true for me. I checked what Expired() actually does and recreated it when I load and save the session:

//638325369830100000 (2023-10-10​T12:16:23.009Z)
session.CreatedAt.Ticks
//3600
session.ExpiresIn
//10.10.2023 11:16:23 (ExpiredAt) - What happend here?
new DateTime(session.CreatedAt.Ticks).AddSeconds(session.ExpiresIn).ToUniversalTime())
//10.10.2023 12:19:15 (Now)
DateTime.UtcNow

The session should really just expire @ 13:16:22 UTC.

Screenshot 2023-10-10 144411

Since Expired() just checks if ExpiredAt < Now it always returns true for me. If I remove the check it works as intended. Might be a problem with UTC time conversion? If I use DateTimeOffset(session.CreatedAt) instead of DateTime(session.CreatedAt.Ticks) I get the expected result.

Additional context

Might be a problem with just Azure? I have used Supabase before not never the auth part. Let me know if I need to provide more info.

wiverson commented 1 year ago

Makes sense to me. Want to send a PR?

acupofjose commented 1 year ago

Available in 4.2.3 - thanks @Dayjay!