Page 1 of 1

Handling Frontend Robustness

Posted: 24 December 2020, 08:46
by HumanBot
How do people deal with DOM modifications? I feel like its really easy for people to change an element's id or class and it could potentially break the code. I'm curious how other developers handle this issue generally. Do you guys just use a bunch of checks for each clickable feature or is there a general standard to follow such as never using element classes to determine game state? Or is this not really a big issue and something that we can ignore?

Re: Handling Frontend Robustness

Posted: 24 December 2020, 09:17
by Tisaac
I try to separate logic from layout. So I never rely on css class and instead use some closure for instance to have specific hook that I then check when clicked.
But even that is not enough since a user can change the js code and/or the ajax calls so the most important part is to check on server side (you can do that in a smart way if you have a nice front/back interface, but looking if action arg was présent in state args)

Re: Handling Frontend Robustness

Posted: 24 December 2020, 11:23
by RicardoRix
Why care about the client hacks?
All checks have to be done server side, just assume the client could send you anything through the designated ajax calls - it's up to the server to verify if that's a valid move.
I tend to use BgaUserExceptions with clienttranslate for genuine client requests, and feException for potential hacks/cheaters/coding_errors.

Re: Handling Frontend Robustness

Posted: 25 December 2020, 00:26
by HumanBot
Okay thanks. What you guys said makes a lot of sense