Kazz
Explore posts from serversBABetter Auth
•Created by Kazz on 2/22/2025 in #bug-reports
Organization Plugin: Empty invitation handling
After implementing organization invitation in my project, I discovered that I can send an empty email in the
organization.inviteMember
And the function would work correctly.
Example of the bug:
- User sends an invitation to the organization for an empty string email ""
- The function takes it normally without throwing an error and stores it in database with email = ""
Expected behavior:
- User tries sending invitation to an empty email string
- Error return saying that the email must be valid or something like this
I know that I need to add validation for the email before giving it to the function, but I still think the validation should be implemented in this. I don't know if other functions that accept emails do the same thing as well. Might be something to look into.2 replies
TTCTheo's Typesafe Cult
•Created by Kazz on 2/21/2025 in #questions
UploadThing file accept type restriction
I'm trying to find how I can allow the
<UploadButton />
to only accept images for example with extensions of (.png
, .jpg
...etc).
Because currently my users are able to upload .gif
for example and I don't want to allow that.
I searched the docs but there is nothing regarding image type restriction or acceptation. Unless I missed something...5 replies
BABetter Auth
•Created by Kazz on 2/3/2025 in #help
Organization haPermission and checkRolePermissions help
Shouldn't
auth.api.hasPermission
body include organizationId
/ organizationSlug
? This is so that if we don't want to use the activeOrganiztionId
since hasPermission
only defaults to that.
Why am I not using activeOrganizationId?
I'm using the organization slug in the URL instead and checking if it exists, found it better than making the user wait around 500ms more to set the new active organization3 replies
BABetter Auth
•Created by Kazz on 12/27/2024 in #help
Secure cookies not working in production
I'm using Nextjs 15 with React 19 and latest version of better-auth 1.1.4
My production is not using the secure better auth cookies and when i add the
useSecureCookies: true
in my auth config no cookies get stored and I'm not able to login.
I'm using the Organization
plugin, Magic Link
plugin, nextCookies
plugin, as well as session cookie cache
enabled
2 replies
BABetter Auth
•Created by Kazz on 12/23/2024 in #bug-reports
Session Cache disappearing in Next.js
Expected behavior:
Cached session refreshes in cookies every
30 seconds
Current behavior:
Cached session disappears after 30 seconds
and never gets refreshed, leaving better-auth to default back to bringing the session from the database.
Better-Auth version
v1.1.3 (Latest)
Bug Details:
I started testing out session cache in my project, set the cache to 30 seconds
and tried using it.
After logging in, the cached session better-auth.session_data
stays in my cookies for 30 seconds and then disappears, never to return. Better-auth then defaults back to bringing the session from the database.
The only way I found to get the cached session back is to update the user, but then same loop happens, wait 30 seconds, disappear without being.
This is some of my auth options for reference. I'm also using the Oragnization
plugin
27 replies
BABetter Auth
•Created by Kazz on 12/9/2024 in #help
Build error after migrating to React 19 and Next.js 15
Getting this error after migrating to react 19 and nextjs 15.
As well as an error making me download the
oslo
package
Here are the dependencies I updated:
9 replies
BABetter Auth
•Created by Kazz on 12/2/2024 in #bug-reports
Updating organization metadata
Currently, after updating organization metadata, the metadata gets stringified twice, causing the data to be stored as '[object object]'
This should solve the problem theoretically by checking if the metadata already a string or not and stringifiying it based on that. I didn't have time to create a PR and clone the project so i just drafted this quickly from what I saw in the file
File path:
packages/better-auth/src/plugins/organization/adapter.ts
Untested Code:
6 replies
BABetter Auth
•Created by Kazz on 11/30/2024 in #bug-reports
Typescript additional fields date type error
Jumping straight to example:
Add additional fields in the db schema and in the auth config
user: {
additionalFields: {
birthday: { type: 'string', default: null },
dob: { type: 'date', default: null },
},
},
Expected behavior
await updateUser({
birthday: values.birthday?.toISOString(),
dob: values.birthday && values.birthday,
})
Error I'm getting:
Type 'Date | undefined' is not assignable to type 'undefined'. (dob field)
It is reading date types as undefined in better-auth
This error only occurs with type date, any other type in better-auth config is read correctly3 replies