Netrifier
Netrifier
BABetter Auth
Created by MaveriX89 on 4/4/2025 in #help
Organization: Determine what team a user belongs to
The teamId conditional inference is inverted so it was being inferred when teams were not enabled and not inferred when teams were enabled I have made a pr to fix this https://github.com/better-auth/better-auth/pull/2133
11 replies
BABetter Auth
Created by MaveriX89 on 4/4/2025 in #help
Organization: Determine what team a user belongs to
can you check if the teams array of object is being inferenced in the returntype of getFullOrganization
11 replies
BABetter Auth
Created by MaveriX89 on 4/4/2025 in #help
Organization: Determine what team a user belongs to
The teamId is present in the db schema for the member and invitation tables, but the docs have not yet been updated to include this. You can reference the internal schema of the organization plugin here https://github.com/better-auth/better-auth/blob/main/packages/better-auth/src/plugins/organization/schema.ts I came across this pr which updates the teams schema https://github.com/better-auth/better-auth/pull/1640
11 replies
BABetter Auth
Created by elvince on 4/3/2025 in #bug-reports
Admin plugin : listUsers total is not correct
This pr relies on the count function of all db adapters to correctly filter based on the where clause. Mongodb and memory adapters currently does not filter count by where clause. Also the drizzle adapter has a bug where it returns res.count instead of res[0].count resulting in undefined being returned. I have fixed these in pr https://github.com/better-auth/better-auth/pull/1737
4 replies
BABetter Auth
Created by elvince on 4/3/2025 in #bug-reports
Admin plugin : listUsers total is not correct
4 replies
BABetter Auth
Created by bwhitney on 4/3/2025 in #bug-reports
BetterAuthError [BetterAuthError: Session data is too large
I did try modifying the get-session endpoint directly and then setting the cookie there with my modified data, but the internal getSession function is called in a lot of places which sets the cookie so that can't be changed as of now
8 replies
BABetter Auth
Created by bwhitney on 4/3/2025 in #bug-reports
BetterAuthError [BetterAuthError: Session data is too large
I don't think this is currently possible.
8 replies
BABetter Auth
Created by bwhitney on 4/3/2025 in #bug-reports
BetterAuthError [BetterAuthError: Session data is too large
The cookies have a limit of 4kb data that can be stored in them
8 replies
BABetter Auth
Created by mr0808. on 3/30/2025 in #help
Multiple roles per user in Admin plugin
You can pass multiple roles in the admin.createUser and admin.setRole functions by separating them with a comma.
const updatedUser = await authClient.admin.setRole({
userId: "user_id_here",
role: "admin,superadmin",
});
const updatedUser = await authClient.admin.setRole({
userId: "user_id_here",
role: "admin,superadmin",
});
But typescript will complain about this. I have a pr which adds support for passing multiple roles as an array with role inference
2 replies
BABetter Auth
Created by MaveriX89 on 3/11/2025 in #help
Admin + Organization Plugin: Role Columns
I have created this pr to add this to docs and add the typescript inference https://github.com/better-auth/better-auth/pull/1907
54 replies
BABetter Auth
Created by MaveriX89 on 3/11/2025 in #help
Admin + Organization Plugin: Role Columns
yes it does support it
const roles = (input.role || input.options?.defaultRole || "user").split(",");
const roles = (input.role || input.options?.defaultRole || "user").split(",");
I think the docs haven't been updated yet
54 replies
BABetter Auth
Created by yoyojoe on 3/13/2025 in #help
Admin Users Count
Hey, @bekacru @Ping could you take a look at this
29 replies
BABetter Auth
Created by yoyojoe on 3/13/2025 in #help
Admin Users Count
I had found this when I was adding tests to my pr https://github.com/better-auth/better-auth/pull/1737
29 replies
BABetter Auth
Created by yoyojoe on 3/13/2025 in #help
Admin Users Count
in the count function on the drizzle adapter there is a bug on the count function https://orm.drizzle.team/docs/guides/count-rows
async count(data) {
const { model, where } = data;
const schemaModel = getSchema(model);
const clause = where ? convertWhereClause(where, model) : [];
const res = await db
.select({ count: count() })
.from(schemaModel)
.where(...clause);
return res.count; // this is the bug, it should be res[0].count
},
async count(data) {
const { model, where } = data;
const schemaModel = getSchema(model);
const clause = where ? convertWhereClause(where, model) : [];
const res = await db
.select({ count: count() })
.from(schemaModel)
.where(...clause);
return res.count; // this is the bug, it should be res[0].count
},
29 replies
BABetter Auth
Created by yoyojoe on 3/13/2025 in #help
Admin Users Count
hey @yoyojoe I figured out what is causing it
29 replies
BABetter Auth
Created by yoyojoe on 3/13/2025 in #help
Admin Users Count
that is expected as it would return the limit only if the limit is present
29 replies
BABetter Auth
Created by yoyojoe on 3/13/2025 in #help
Admin Users Count
that would happen if the value of the total comes to be undefined, not sure why it is happening
29 replies
BABetter Auth
Created by yoyojoe on 3/13/2025 in #help
Admin Users Count
I do not know if this is the intended behaviour but I think the where clause should be passed to the countTotalUsers function
29 replies
BABetter Auth
Created by yoyojoe on 3/13/2025 in #help
Admin Users Count
const users = await ctx.context.internalAdapter.listUsers(
Number(ctx.query?.limit) || undefined,
Number(ctx.query?.offset) || undefined,
ctx.query?.sortBy
? {
field: ctx.query.sortBy,
direction: ctx.query.sortDirection || "asc",
}
: undefined,
where.length ? where : undefined,
);
const total = await ctx.context.internalAdapter.countTotalUsers();
const users = await ctx.context.internalAdapter.listUsers(
Number(ctx.query?.limit) || undefined,
Number(ctx.query?.offset) || undefined,
ctx.query?.sortBy
? {
field: ctx.query.sortBy,
direction: ctx.query.sortDirection || "asc",
}
: undefined,
where.length ? where : undefined,
);
const total = await ctx.context.internalAdapter.countTotalUsers();
29 replies
BABetter Auth
Created by yoyojoe on 3/13/2025 in #help
Admin Users Count
I took a look at the listUsers function and it returns the users and also counts the total users without any conditions
29 replies