lucia-auth / lucia

Authentication, simple and clean
https://lucia-auth.com
MIT License
8.32k stars 447 forks source link

[Bug]: the default type of expires_at attribute in sessions is Date, but I require String. #1607

Closed karthiktechhub closed 1 week ago

karthiktechhub commented 1 week ago

Package

lucia

Describe the bug

supabase always stores dates as string, which is causing issues, I want the expires_at attribute to be of type string by default, how should I implement it, is it even possible since its already defined in the lucia library, I'm no expert, pls help to fix this issue.

Kawba commented 1 week ago

This is not really a bug its just the way the library / the adapters work. There is a way to get this to work though, you could build a custom adapter for your database / database structure or take the code of an existing one and modify if there is one that works with supabase (maybe postgres? sorry have never used supabase) that maps to a different object.

We built a dynamodb adapter (see here https://github.com/gnk-softworks/lucia-dynamodb-adapter) and to save the session into the database we first map to our own object that is better suited to the technology (has date as string and a ttl property) you would also need to make sure when the date is loaded back out of the database it is converted back to a date for the library to use.

Hope this helps.

karthiktechhub commented 1 week ago

I understood your approach to solve this issue, I will be closing this issue.

thanks for the help.