All files / app/service login.service.ts

68.75% Statements 11/16
75% Branches 9/12
60% Functions 3/5
66.66% Lines 6/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28  138x                 243x     243x 243x       27x           27x      
import { HttpErrorResponse } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { runInAction } from 'mobx';
import { throwError } from 'rxjs';
import { Store } from '../store/store';
import { ConfigService } from './config.service';
 
@Injectable({
  providedIn: 'root'
})
export class LoginService {
 
  constructor(
    private config: ConfigService,
    private store: Store,
  ) { }
 
  handleHttpError(res: HttpErrorResponse) {
    Iif (!this.config.electron && navigator.onLine && this.store.account.signedIn) {
      if (res.status === 401) {
        runInAction(() => this.store.account.authError = true);
        return throwError(() => ({ message: 'Please log in again.' }));
      }
    }
    return throwError(() => res);
  }
}