-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Misc] Admin panel unlink accounts #4198
[Misc] Admin panel unlink accounts #4198
Conversation
…02/pokerogue into admin-panel-unlink-update
…code before it decides to stop working again
… and added updated icons
PR with code cleanup suggestions: Opaque02#3 |
Cleanup FormUiHandler a little
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Mostly doc + scope change suggestions
The most important doc is in FormModalUiHandler
since it'll help future devs who want to extend the class understand what they need to do. These and more generally doc for anything that is not private should use /** */ style comment so that the IDE picks up on it (within reason of course, we don't want to comment every single thing if they are self explanatory)
Not asking to change it but in general I think it would be better if the inline comments were on their own line unless they are really short. Some of these are too long to show in a single line so it makes things harder to read
Moka review changes Co-authored-by: MokaStitcher <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might as well so it's not forgotten
Full discussion in discord UI thread, but we also may want a specific error message if a discord/google id is already linked to another account
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, meant to request changes 💀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ship it 👀
oh I didn't even noticed that earlier. For reference the various error messages were already too long in some languages before adding those error codes. And I'm pretty sure I've seen a PR before to handle that by resizing the text if needed or something? But I can't find it so who knows lol |
a341b52
Why am I making these changes?
Walker wanted it

This has been requested because with the current admin linking panel, sometimes people would give us the wrong username to link to, so having the ability to unlink would be helpful. However, we also wanted to add the ability to find out when the last time a user played was for further verification reasons, so we've now added a new admin panel which shows the username, the linked discord/google (if they have one), the last time played and the date registered, allowing discord helpers to more easily verify users
What are the changes from a developer perspective?
A lot of stuff
getInputFieldConfigs(args: any)
) that allows you create an array of a new interface (InputFieldConfigs
) that lets you have specific info about a field in a form modal. It currently has support for the label, whether it's a password field, and whether the field is read only or not. Due to this, everything that extends form-modal-ui-handler (the admin panel, renaming panel, login form, registration form and test dialogue panel) have had their own version ofgetInputFieldConfigs()
implementedThings to note
There's a weird ui issue still happening that we can't figure out why it's happening. When using the admin panel, it will always have text to return - sometimes it's the username/discord id (in the case of the linking panel), and sometimes it's the admin info details (username, discord, google, last logged in date and registered date). For some reason, when there's text being returned that are from input text fields, there's 3-4 frames during the loading part of the admin panel where the text appears in the top left corner of the screen, before disappearing and showing up in the correct space on the admin panel. We couldn't figure out why this is happening, but it's minor and still works, and since such a small number of people (non-players) see this panel anyway I thought it'd be ok to leave as is, though I'm open to discussion about it to try and fix it. Walker said it should be fine, but if we happen to figure out why it's happening and how to fix it, I can update things.
Screenshots/Videos
Please note that for these screenshots/videos, the discord/google ids used are fake and won't actually work. They are just used to show updates to the DB rather than actually logging in with google/discord
Login panel updates:
No save file (PO1) error
Too many save files (PO2) error
For these errors, the translation team has been made aware that this is now too long for the panel and they are in the process of updating things
No error messages
Test Dialogue:
Here is a video of me opening the test dialogue for testing
2024-10-14.09-18-35.mp4
Admin panel stuff:
The Linking Panel (this functionality should be unchanged):
DB before
Video of changes (notice the new success message and the fact that the username and discord are now shown after linking so you can see what you've done)
2024-10-14.09-46-12.mp4
DB after
Here's screenshot of me filling out the linking panel with a username that isn't in the database
Since the username/discord ID are kept after hitting link, here's an example of using the linking panel with just a username and no discord ID - you can see that the error still says that a discord ID is needed, but the username is already filled for you so you can use it again
Similarly, if we just have a discord ID and no username, you get the same error but about username missing instead
Username Search/Admin Panel:
Here's a video of the process of going through a username search and opening the admin panel
2024-10-14.09-56-12.mp4
Because this user already has a discord and google ID, we have the option to unlink those from the DB by pressing the icon to the right of the discord/google fields.
In the below example, we can see a different user who only has their discord linked, and which we will unlink (and see the success message), and then we can link a google account to their user (and see the success message for that):
Also worth noting is that for the discord ID (and the google one once linked), because that comes from the server, it is a readonly value and can't be edited. This is to prevent accidental changes. To change a user's discord/google ID, you would need to unlink it first, then enter the new details and then link it again.
Here's the DB before
And after
Admin panel error codes:
Here's what happens when you don't have a username in the search bar for the admin panel
Here's what happens when you try to link a discord/google ID without filling in the field
How to test the changes?
This first part is copied from the server PR so you can reference how to get the server working properly
You need to set up your own server and pull this PR. Any questions with that, ask me in discord, or ask Walker, though we have this thread in discord that we used to get things set up - it's a lot of info but it should have a lot of troubleshooting steps that we did to get it working.
Once your server is set up, make sure you also have access to the DB. I'm using MySQLWorkbench to let me see the db, but you can use anything as long as it can connect to a maria DB instance.
Once everything is set up, in your server, you'll need to change the some files. If you would like to see any of these in action, you can check some previous commits to see what I used to have for my testing, since I committed my testing changes:
First there's a file called beta.env in the main project folder that looks like this:
Here I've used {serverIP} in a few places and {devMachineIP} for the gameurl - for me, my server machine and my dev machine are two different machines, so my gameurl is a different IP compared to my server IP. However, if this is not the case, you should be able to use your dev machine's IP for all cases of devMachineIP and serverIP instead.
Next, in your docker-compose.Example.yml, under services->server add the following code:
This makes the game use your beta.env file from above, and also makes sure to pull the edited version of rogueserver instead of master branch. Finally, add the following to services->db:
This makes sure the DB is using the right port.
To run it, open a cmd at the location of your rogueserver folder and run this code:
This will build the server using the code provided. Once that's done, use this code to set everything up using the docker-compose file we updated before:
Hopefully if you go to run it, all 3 parts will be good, and going into the server to see the logs will show you the daily seed (see below):
This part is new and not in the rogueserver PR
Once that's all done, you can now go to the pokerogue repo and get that up and running by changing a couple of files. Firstly, change your .env.development file by changing the first line (
VITE_BYPASS_LOGIN=1
) to beVITE_BYPASS_LOGIN=0
instead, and change line 3 (VITE_SERVER_URL=http://localhost:8001
) to have your server url from above. For example, I usedVITE_SERVER_URL=http://192.168.1.101:8001
since my server was running at 192.168.1.101Next in the utils.ts file, lines 285, 290, 293 and 294 all have cookie related stuff for them. Within each of those lines is "Secure;" - you want to remove it from all of the cookie related lines - this means you'll be changing this:
To this:
Make sure to remove the ; when removing "Secure" so you don't end up with double ;
Now that everything's done, you should be able to start the game up. Once the game is up, you should be able to register an account and log in. Once that's done, log out and make a few accounts - this will let you test things much easier for this PR.
Once that's done, you'll need an admin discord account. I made an account with my pokerogue name (Opaquer) and linked that to my discord ID, which I then used throughout testing. You'll need to link your discord ID to your server account (manually or otherwise). To do that through the DB, you can use something like (make sure to remove the {} when entering values):
Note that the discordId should be an 18 char string of numbers in the real world, but you can use anything for testing. Your username should be whatever username you want your admin account to be for the server. As an example, this is what my code looked like:
Back in the server code, /api/account/discord.go change this function to immediately return true for your discord ID that's now linked to your server admin account. I did it by doing this:
Where the discordID should be what you used before. In my case, that second line would be
return discordId == "256000469158068224", nil
. Again make sure to remove the {} when entering valuesNow that this is all done, you should be good to test everything! Here's the best way to test various things
Checklist
beta
as my base branchnpm run test
)