EDE in API endpoint set-active

API endpoint to set active org -> Is showing alot of information
{
"id": "RbK9SjPZKhd-laZiqO_dS",
"name": "xxxxx",
"slug": "xxx",
"logo": "xxxx",
"createdAt": "2024-11-13T22:41:58.099Z",
"invitations": [],
"members": [
{
"id": "HBPdjO-To6nXxD3uRmSXr",
"organizationId": "RbK9SjPZKhd-laZiqO_dS",
"userId": "wcfOn5-iM9zyynNRY7gtp",
"role": "owner",
"createdAt": "2024-11-13T22:41:58.162Z",
"user": {
"id": "wcfOn5-iM9zyynNRY7gtp",
"name": "xxxxx",
"email": "xxxx",
{
"id": "RbK9SjPZKhd-laZiqO_dS",
"name": "xxxxx",
"slug": "xxx",
"logo": "xxxx",
"createdAt": "2024-11-13T22:41:58.099Z",
"invitations": [],
"members": [
{
"id": "HBPdjO-To6nXxD3uRmSXr",
"organizationId": "RbK9SjPZKhd-laZiqO_dS",
"userId": "wcfOn5-iM9zyynNRY7gtp",
"role": "owner",
"createdAt": "2024-11-13T22:41:58.162Z",
"user": {
"id": "wcfOn5-iM9zyynNRY7gtp",
"name": "xxxxx",
"email": "xxxx",
It drops the entire tables out back to the user just for setting active - Where API endpoint get-full-org is pulled right after. I think ths API endpoint should return false/true if its set, and not return the whole objects.
17 Replies
kaas
kaasOP4mo ago
Furthermore, the documentation does not really go through on how to use the permissions: https://www.better-auth.com/docs/plugins/organization Would someone be able to explain how to actually use these roles somewhere? E.g On a dashboard page - If I Create a permission on member called "canviewstats" -> How would this go through
Organization | Better Auth
The organization plugin allows you to manage your organization's members and teams.
kaas
kaasOP4mo ago
It also seems like: Using
const { data: activeOrganization } = authClient.useActiveOrganization()
const { data: activeOrganization } = authClient.useActiveOrganization()
Actually hits endpoint
http://localhost:3000/api/auth/organization/get-full-organization?currentURL=http%3A%2F%2Flocalhost%3A3000%2Fdashboard
http://localhost:3000/api/auth/organization/get-full-organization?currentURL=http%3A%2F%2Flocalhost%3A3000%2Fdashboard
Instead of the intended endpoint.
(property) useActiveOrganization: () => {
data: Prettify<{
id: string;
name: string;
slug: string;
createdAt: Date;
logo?: string | null | undefined;
metadata?: any;
} & {
members: (Member & {
user: {
id: string;
name: string;
email: string;
image: string | undefined;
};
})[];
invitations: Invitation[];
}> | null;
error: null | BetterFetchError;
isPending: boolean;
isRefetching: boolean;
}
(property) useActiveOrganization: () => {
data: Prettify<{
id: string;
name: string;
slug: string;
createdAt: Date;
logo?: string | null | undefined;
metadata?: any;
} & {
members: (Member & {
user: {
id: string;
name: string;
email: string;
image: string | undefined;
};
})[];
invitations: Invitation[];
}> | null;
error: null | BetterFetchError;
isPending: boolean;
isRefetching: boolean;
}
== client.organization.getFullOrganization
bekacru
bekacru4mo ago
this is the right path, no? we should have the ac plugin done tomrrow. It should be much more robust and well documented.
kaas
kaasOP4mo ago
No. Useactiveorg hits Get-full-org
bekacru
bekacru4mo ago
if you have two instance of better auth make sure to update both of them meaning one for the client one for the server
kaas
kaasOP4mo ago
I dont I think issue is deeper than config
bekacru
bekacru4mo ago
it should be hitting organization/get-full-organization not sure why yours isnt what do you mean?
kaas
kaasOP4mo ago
So when using "useactiveorg" it is correct it should be hitting get-full-org endpoint? which is the same api endpoint it hits when using
No description
kaas
kaasOP4mo ago
sorry if I am not clear but these two hit the same API endpoint which I think is a mistake
bekacru
bekacru4mo ago
no it's not a mistake the difference between those two is being a reactive hook or not
kaas
kaasOP4mo ago
Oh wow. Im clearly stupid then! Anyhow, circling back to my first message. Is this meant to expose all of this info when setting active org And is there an option to call to fetch information about the users role in the org etc and not dropping the whole members with it?
bekacru
bekacru4mo ago
Organization | Better Auth
The organization plugin allows you to manage your organization's members and teams.
kaas
kaasOP4mo ago
Would this also return the role of the user?
bekacru
bekacru4mo ago
yeah
kaas
kaasOP4mo ago
But to make sure, the "set-active" is meant to return the entire org object, and not simply a true/false value?
bekacru
bekacru4mo ago
yes
kaas
kaasOP4mo ago
https://www.better-auth.com/docs/plugins/organization Will there ever be a way to only fetch the current id/name of the org, instead of outputting everything with "use active org" -> Still dumping all the members on each request seems to be too much info
Organization | Better Auth
The organization plugin allows you to manage your organization's members and teams.

Did you find this page helpful?