Confused on adding custom roles
Hello! Apologies if this has been answered elsewhere. I've searched through these forums and haven't found a thing, though.
I have, in fact, read the docs! Also searched on Google, didn't find a thing.
I'm using Next.js, React, better-auth, a few other plugins, all latest version. I'm trying to give someone, say, the "Member" role, or "Admin" (capitalized A). However, when I try to do this (clientside, on a webpage):
it pops up with the error
Type '"[whichever role I want to add]"' is not assignable to type '"user" | "admin" | ("user" | "admin")[]'. Did you mean '"admin"'?
Now I'm confused because, in the docs, it says setRole
takes string | string[]
, but here, it says role
is "user" | "admin" | ("user" | "admin")[]
. Now, the function still works, strangely enough. But the red text indicates there's a problem, and if I ignore it, I'll inevitably run into it later.
I've tried reading the docs on access control, and have the below pastebin as my permissions.ts
(based off of the docs, because I'm just testing):
https://pastebin.com/2kbGaPxD (not that long, but it takes up a lot of vertical space)
-# (I know the casing is off, just trying to see if that makes a difference in how I can spell it in my setRole function)
Then, I import it and add it to my admin stuff:
However, this hasn't done anything to solve the red-text error, at least not in its current configuration... which is what brings me here!
If anyone could help, that would be greatly appreciated! Please ping when you do.0 Replies