title: Angular interceptor does not resubmit failed request
body: <p>I am using Angular 7.2 MatDialog from Angular Material and rxjs 6. after the token expires, on the next http request, it brings the dialog up, but it does not submit the failed http request again.
  Although these suggestions are slightly different than what I need, I have tried <a href="https://gist.github.com/Gribanov/c6cce5a563ca0ba55591f15a96312db5" rel="nofollow noreferrer">this</a> and <a href="https://stackoverflow.com/questions/45202208/angular-4-interceptor-retry-requests-after-token-refresh">this</a> without luck.
  All that I need is that after the dialog closes, that it submit the failed request again, which is not happening at the moment.
  Can someone assist in finding what I am missing?</p>
  
  <pre><code>private refreshingToken: boolean = false;
  
  intercept(request: HttpRequest&lt;any&gt;, next: HttpHandler): Observable&lt;HttpEvent&lt;any&gt;&gt; {
  
      return next.handle(this.setAuthorizationHeader(request))
          .pipe(
              catchError((error, caught) =&gt; {
                  if (error instanceof HttpErrorResponse) {
                      if (error.status == 401) {
                          if (this.refreshingToken) {
                              return empty();
                          } else {
                              this.refreshingToken = true;
                              setTimeout(() =&gt; {
                                  const dialog = this.authenticationService.OpenLoginDialog();
                                  if (dialog) {
                                      const afterClosed$: Subscription = dialog
                                          .afterClosed()
                                          .pipe(
                                              switchMap(() =&gt; {
                                                  return this.store.select(state =&gt; state.AccountState)
                                                  .pipe(
                                                      map(data =&gt; data.accountLoggedIn)
                                                  )
                                              }),
                                              switchMap((accountLoggedIn: boolean) =&gt; {
                                                  if (accountLoggedIn) {
                                                      return next.handle(this.setAuthorizationHeader(request));
                                                  }
                                              }),
                                              finalize(() =&gt; {
                                                  this.refreshingToken = false;
                                                  if (afterClosed$)
                                                  afterClosed$.unsubscribe();
                                              })
                                          )
                                          .subscribe(afterClosedsubscribe =&gt; {
                                              console.log({afterClosedsubscribe: afterClosedsubscribe});
                                          });
                                  }
                              });
                          }
  
                      }
                  }
                  return caught;
              })
          );
  }
  
  private setAuthorizationHeader(request: HttpRequest&lt;any&gt;): HttpRequest&lt;any&gt; {
      const token = this.tokenService.Get();
      if (token != null) {
          request = request.clone({
              setHeaders: {
                  Authorization: `${token.tokenType} ${token.accessToken}`
              }
          });
      }
      return request;
  }
  </code></pre>