title: How to limit user login attempts Angular.js (typescript)
body: <h1>My code limits the user login attempts but when the page is refreshed it resets the user count.</h1>
  <pre><code>login() {
  /* Only attempt login if user has less than 5 login attempts */
  if (this.failedAttempts &lt; 4) {
  
  
    this.auth.login(this.credentials).subscribe(() =&gt; {
      this.router.navigateByUrl('/');
      this.alert.success('Welcome! Thanks for logging in!');
    }, (err) =&gt; {
      this.failedAttempts++;
      console.error(err);
      this.alert.error('Login failed. Invalid email or password.');
    });
    /*If user reaches 5 failed attempts refresh number of failed attempts after 5 minutes and disable submit button*/
  } else if (this.failedAttempts &lt; 4) {
  } else {
    /*increments number of times locked out */
    this.numLockedOut++;
  
    this.alert.error('Login failed. Invalid email or password. Locked out for ' + (this.numLockedOut * 300000) / 60000 + ' minutes');
    this.btnDisable = true;
    setTimeout(() =&gt; this.failedAttempts = 0, this.numLockedOut * 300000);
    setTimeout(() =&gt; this.btnDisable = false, this.numLockedOut * 300000);
  }
  </code></pre>
  <p>}</p>
  <p><strong>How do I <code>settimeout()</code> without restarting the clock on page refresh</strong>?</p>