janusanus
janusanus
BABetter Auth
Created by janusanus on 2/19/2025 in #help
Next.js [Admin] [Username] listUsers() returns UserWithRole[] missing property `username`
I'm using two plugins, Admin and Username. I'm currently building my admin dashboard and I'm listing all users in a server action like this:
const response = await authClient.admin.listUsers(
{
query: {
limit: 100
}
},
{ headers: headers() }
)
const response = await authClient.admin.listUsers(
{
query: {
limit: 100
}
},
{ headers: headers() }
)
This works but returns the data with the type UserWithRole[] and is missing property username I read something about infering types, but I don't know if that's the right way. I would appreciate any help. ty
6 replies
BABetter Auth
Created by janusanus on 2/14/2025 in #help
setRole doesn't work
I'm using NextJS@14. Hello, I'm trying to give a user the admin role, but it's not working and I am not getting an error message/code. here is my code (a server action):
export async function setAdmin(id: string) {
const updatedUser = await authClient.admin.setRole(
{
userId: id,
role: "admin",
},
{ headers: headers() }
)

console.log("User is now an admin", updatedUser, id)
}
export async function setAdmin(id: string) {
const updatedUser = await authClient.admin.setRole(
{
userId: id,
role: "admin",
},
{ headers: headers() }
)

console.log("User is now an admin", updatedUser, id)
}
The response i get:
User is now an admin { data: null, error: { status: 0, statusText: '' } } ZFgfmRxHcP8Exszk07b9CZOsteXMiQ62
User is now an admin { data: null, error: { status: 0, statusText: '' } } ZFgfmRxHcP8Exszk07b9CZOsteXMiQ62
If you have an Idea of what went wrong please let me know. Any help is appreciated 🙌
4 replies