How to sign up as admin
How to add a admin, from the form in short
That is my question
Can't find anything on the docs
Thanks in advance!
11 Replies
You should create a user as normal, by logging in, then in your db you can change the role from
user
to admin
It's outlined here: https://www.better-auth.com/docs/plugins/admin#usage
Admin | Better Auth
Admin plugin for Better Auth
smthg like below is not possible ? @D3vision
this doesn't work
I'm unsure but you can always give it a try
For my own project I just changed the role in the database
i tried to do that
can u pls share ur repo
i can take it for reference
Add the role field to the database schema and to the additional fields in better-auth
for your case
auth.ts
in auth client we add the inferAdditionalFields
so that better-auth knows about the additional fields you added
auth-client.ts
this way you will be able to add role to the authClient.signUp
and authClient.updateUser
functionsOhh I see
Really thx for the help
Afk right now, will try it out tmrw
Alright ^, tell me if it works for you when you implement it!
Sure, thx again
the role is still not changing @Kazz
in db it's default to user only
my
auth.ts
file
auth-client.ts
Unknown User•9mo ago
Message Not Public
Sign In & Join Server To View
doesn't work @rizvan
it doesn't get updated in the mongo db
but i can see the role changes in prisma studio @Kazz
the role doesn't change, when i try to do smthg
teacher
, it doesn't update
it works fine, i have added another attirbute called UserRole
and it works fine
thx a lot