Issue
So I am working on a voting application. The application have an admin and users.
I want the voting campaign to start when the admin clicks on start button.
I want to redirect all users to another page when the admin start the voting.
Any suggestions ? How can I implement this without sending a request to the database.
Technologies used : Angular and Java (spring boot), mysql DB
( Edit : my app is like poker planning (scrum planning) websites, for example : **https://www.planningpoker.com/ )
Solution
You haven't provided any code for us to solve a coding issue, but in theory if you were using JWT and you set a token expiry of say 5 seconds, then your app would have to re-authenticate the token every 5 seconds. You could include logic/code in the token refresh to test if the a vote was required, if it was redirect user to this page.
You cannot do this without sending a request to the DB, as each client is agnostic of another client, so using a global service will only store data in the clients browser.
So:
- Admin, sets "vote" triggers a change in back end DB
- JWT login token is refreshed every 5/10seconds (or whatever)
- as part of refresh cycle, test to see if database has a vote value
- if true, re-direct user to vote page.
Answered By - crooksey
Answer Checked By - Pedro (JavaFixing Volunteer)