tp-link-extender / MercuryCore

Self-hostable MMO game creation platform: build-your-own-Roblox
https://mercury2.com
The Unlicense
24 stars 8 forks source link

Make giving admin when registering optional #354

Closed dxfiscool closed 2 months ago

dxfiscool commented 2 months ago

Describe the problem

By default, when you register you get admin (this also applies to users registered after the first user). There is no clear indication of where to change this.

Describe the proposed solution

It would be great for this to be able to be easily toggled in a config file.

Heliodex commented 2 months ago

If users registering after the first also receive administrator-level permissions then this isn't intended behaviour, however I wasn't able to recreate this. At the moment there's no user-editable way to change permissions for any account, which there should be an option for in the Admin panel. Adding an option for this in the config file could work, but probably only if registration keys aren't enabled, as if they are you have to navigate to the admin panel to create one before any new accounts can be registered.

ui0ppk commented 2 months ago

you should instead make a cli utility that gives a user admin/mod by id or username

dxfiscool commented 2 months ago

If users registering after the first also receive administrator-level permissions then this isn't intended behaviour, however I wasn't able to recreate this. At the moment there's no user-editable way to change permissions for any account, which there should be an option for in the Admin panel. Adding an option for this in the config file could work, but probably only if registration keys aren't enabled, as if they are you have to navigate to the admin panel to create one before any new accounts can be registered.

I managed to fix this issue.

In the register route, this code is present:

        username,
        email,
        // I still love scrypt, though argon2 is better supported
        hashedPassword: Bun.password.hashSync(password),
        bodyColours: config.DefaultBodyColors,
        key,
    })

I simply replaced it with:


        admin: false,
        username,
        email,
        // I still love scrypt, though argon2 is better supported
        hashedPassword: Bun.password.hashSync(password),
        bodyColours: config.DefaultBodyColors,
        key,
    })```

    and it worked!
Heliodex commented 2 months ago

Well done on the fix, though I'm still unable to recreate the original issue and the change doesn't seem to do anything for me. Do you have any more information on your logs/tool versions/database info?

dxfiscool commented 2 months ago

Well done on the fix, though I'm still unable to recreate the original issue and the change doesn't seem to do anything for me. Do you have any more information on your logs/tool versions/database info?

I'm using Windows 10 Docker Desktop for the database and i'm using WSL 1.0 Ubuntu to host it. Not sure why the same issue isn't present for you. Don't really have any more information than that.