listUsers from admin plugin with no session?

Can i run
const users = await authClient.admin.listUsers({
query: {
filterField: "role",
filterOperator: "eq",
filterValue: "admin",
},
});
const users = await authClient.admin.listUsers({
query: {
filterField: "role",
filterOperator: "eq",
filterValue: "admin",
},
});
with no authenticated session? It might be called on server as well, I just want to see if there are any admins.
2 Replies
style
styleOP3mo ago
and same question for creating user
Ping
Ping3mo ago
With listUsers, it's required to have an admin session. With createUser, you must use auth.api.createUser in order to do so without an admin session

Did you find this page helpful?