janusanus
janusanus
BABetter Auth
Created by janusanus on 2/19/2025 in #help
Next.js [Admin] [Username] listUsers() returns UserWithRole[] missing property `username`
thanks for the reply, i tried switching them up, but it still doesn't work here is the UserWithRole if it helps
type UserWithRole = {
id: string;
email: string;
emailVerified: boolean;
name: string;
createdAt: Date;
updatedAt: Date;
image?: string | null | undefined;
role?: string | null;
banned?: boolean | null;
banReason?: string | null;
banExpires?: Date | null;
}
type UserWithRole = {
id: string;
email: string;
emailVerified: boolean;
name: string;
createdAt: Date;
updatedAt: Date;
image?: string | null | undefined;
role?: string | null;
banned?: boolean | null;
banReason?: string | null;
banExpires?: Date | null;
}
6 replies
BABetter Auth
Created by janusanus on 2/14/2025 in #help
setRole doesn't work
here is the working code:
export async function setAdmin(id: string) {
const updatedUser = await auth.api.setRole({
body: {
userId: id,
role: "admin"
},
headers: headers()
})

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

console.log("User is now an admin", updatedUser, id)
}
4 replies
BABetter Auth
Created by janusanus on 2/14/2025 in #help
setRole doesn't work
I forgot i had to use the auth.api instead of the authClient, because it's a server action.
4 replies
BABetter Auth
Created by janusanus on 2/14/2025 in #help
setRole doesn't work
I fixed it, after looking at some other posts
4 replies
BABetter Auth
Created by bwhitney on 2/12/2025 in #help
Admin Plugin - access "role" client side
that's not getSession() that's useSession
5 replies