Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

146
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda