import { HttpClient } from '@angular/common/http' ; import { Injectable } from '@angular/core' ; import { LoginModel } from '../models/loginModel' ; import { SingleResponseModel } from '../models/singleResponseModel' ; import { TokenModel } from '../models/tokenModel' ; @ Injectable ( { providedIn : 'root' } ) export class AuthService { apiUrl = 'https://localhost:44314/api/auth/' ; constructor ( private httpClient ) { } login ( loginModel ) { return this . httpClient . post < SingleResponseModel < TokenModel > > ( this . apiUrl + "login" , loginModel ) ; } isAuthenticated ( ) { if ( localStorage . getItem ( "token" ) ) { return true ; } else { return false ; } } }