C
C#•8mo ago
Alex

How to create first user (Admin)?

I have backend, users can create accounts, each account has role - admin or user. I want the first account to be Admin. Should I create it during database seeding or every time user register their account I check if it's first user and give him admin role? Or is there a better way? Aslo accounts must be verified to log in to it and only admin users can verify other user account.
6 Replies
SpReeD
SpReeD•8mo ago
I think both ways are very much practical. As seen before, a fresh installation gives you welcome screen where you create the first user account that'll be the superadmin. This approach ensures that they have to create an useraccount with their credentials and that there's no default superadmin credentials. - Once again, it depends on your application and use-case.
Jimmacle
Jimmacle•8mo ago
yeah i've used software that works both ways jenkins has a first run process where you have to grab an auto-generated secret it put on the filesystem to create the first account
Alex
AlexOP•8mo ago
Okay, then I'll check if account is the first one and give him admin role
Jimmacle
Jimmacle•8mo ago
keep in mind if the website is deployed publicly that might be an issue, since theoretically someone could get there first and make the account
SpReeD
SpReeD•8mo ago
Very unlikely, but possible. But, are we talking about a web-service or a desktop/mobile-app? 😄 On the latter you could use an Installation-Wizard/Manager.
Alex
AlexOP•8mo ago
It's just a small website for me and friends so it won't be a problem 😀
Want results from more Discord servers?
Add your server