Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

143
Views
How To Prevent Timer From Being Exploited By User in Javascript

I'm Trying To Make A Quiz App Using Firebase As My Backend And Modular JavaScript As Client Side Script And I Came Across A Problem Recently.
So I Wanted To Make A Timer which shows the user how much time is left before the test ends and gets auto-submitted. But how do I implement it in such a way that the end user doesn't use the Debugger or Other Tools to manipulate this timer. Also In Firebase Rules i have ensured Write Access is disabled after the "time slot" for attempting is over.

For Example: Lets Say Test 1 is Active from 1:00pm - 12:00pm(Timeslot) and you can attempt it for 60mins for any time in this time slot. How Can I Make Sure That The Client Attempts Test For Only 60 mins and not like if he starts from 1:00 and he manipulates the time to write till 12:00pm.

How Can I Implement This? Do I Need Server Side Support Like Cloud Functions? I Didn't Want To Use Them Till Now As Sending A Request Every 1 second or 5 seconds Uses Up A Lot Of The Data Resources When This App Scales to More People. (Also That I'm Building It On Spark Plan)

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You need to check this server side. You can't efficiently prevent someone to perform client-side editing.

  1. Have the client send a request to the server when the test starts, and save the server time as startTime.
  2. Have the client send another request when the test ends, and save the server time as endTime.
  3. Make sure endTime - startTime <= 60 mins
  4. Bonus:
  • Have the client send requests periodically to save user progress and enforce time sync. You don't want the user to fail the test or lose his progress because the browser crashed.
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!