code0wl/Multiplayer-Phaser-game

Continuation of design - login to auth

csajedi opened this issue · 1 comments

Oscar,

I've finished the book, it was an excellent introduction and now I'm trying to build a simple multiplayer game to demonstrate my skills. The code here provides an excellent pattern but my current problem of having persistent accounts and allowing different human players to compete in sessions seemed at first easy but has proven hard. Have you encountered this problem, my current thinking is either to use something like PassportJS and JWT to authenticate sessions for single and multiplayer mode to prevent cheating, or to give up on server entirely and use facebook instant games (blech). Any guidance is appreciated... Maybe an idea for another book :)

@csajedi Thank you! Does me well that the book offered some assistance in your endeavors! 👍
Authentication is indeed a hard problem to solve. PassportJS would match perfectly as a guard. What you can do is create a new route. So index would be authentication and then game would be where the lobby/game might take place. Users would need to register to get some sort of unique token and it should be saved in the window.sessionStorage. You can let them authenticate with FB or twitter as well and use that auth token to access the game route as well. IF no access is permitted, the user would then be doomed for eternity to the index screen :D

I would recommend other books for authentication :D. Node JS the right way is highly recommended: https://www.amazon.com/Node-js-Right-Way-Server-Side-JavaScript/dp/1937785734

Next book I will write will be on neural networks and the recreation of Sim-ant using Machine learning for the ants
image
https://en.wikipedia.org/wiki/SimAnt