title: user login but token not changing before refresh with JWT auth in angular
body: <p>i create auth with jwt in angular</p>
  <p>in my service api</p>
  <pre><code>login(body: any) {
    return this._http.post(this.apiURL + 'login', body, {
      observe: 'body',
    }
  }
  </code></pre>
  <p>in my login function</p>
  <pre><code>login() {
      this.loading = true;
      setTimeout(() =&gt; {
        this.auth.login(this.loginForm.value)
        .subscribe(
          data =&gt; {
            localStorage.setItem('userData', JSON.stringify(data));
            console.log(data);
            this.successMessage = data;
            this.userService.getUserName().subscribe(
              (data: any) =&gt; {
                this.userChange.next(data.data);
                localStorage.setItem('displayName', data.data.displayName);
                if (data.data.emailVerified != true) {
                  this.router.navigateByUrl('/auth/email-verification');
                }
                if (data.data.kewirusType == 'user') {
                  this.router.navigateByUrl('/pages/projects/all-project')
                } else if (data.data.kewirusType == 'admin') {
                  localStorage.setItem('kewirusType', data.data.kewirusType);
                  console.log(localStorage.getItem('kewirusType'));
                  this.router.navigateByUrl('/pages/admin/users-list');
                }
              },
            )
          },
          error =&gt; {
            this.loading = false
            console.log(error.error.message[0]);
            this.errorMessage = error.error.message[0];
          }
        )});
      
    }
  </code></pre>
  <p>so when i first login, let's say i use admin account, then i logout, and then i login with user account, it gives admin account not user account. and the token</p>
  <p>here's admin token before logout</p>
  <p><a href="https://i.stack.imgur.com/8jaGx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8jaGx.png" alt="enter image description here" /></a></p>
  <p>here's user account after login, it return the same token</p>
  <p><a href="https://i.stack.imgur.com/1DbfH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1DbfH.png" alt="enter image description here" /></a></p>
  <p>here's after i refresh the page, the token changing</p>
  <p><a href="https://i.stack.imgur.com/cT2at.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cT2at.png" alt="enter image description here" /></a></p>
  <p>i have talked to my backend, but he said that it's from my code on frontend not his, but i can't find the problem, does anyone knows why this is happening?</p>
  <p>EDIT</p>
  <p>here's my api calls for user detail</p>
  <pre><code> getUserName() {
      return this._http.get&lt;User[]&gt;(this.apiURL + 'auth/user')
    }
  </code></pre>
  <p>after couple hours looking for the problems, i believe that this has to do with changing header authorization token, cause it's not changing after user is logout using their other account. is there any way to refresh the headers while logout?</p>