98. Login service call (#12)

This commit is contained in:
Art
2021-09-12 11:33:40 +03:00
parent 92ecc595f0
commit fa5c69952c
4 changed files with 26 additions and 1 deletions

View File

@ -0,0 +1,7 @@
import {UserLogin} from './user-login';
describe('UserLogin', () => {
it('should create an instance', () => {
expect(new UserLogin()).toBeTruthy();
});
});

View File

@ -0,0 +1,4 @@
export class UserLogin {
username: string;
password: string;
}

View File

@ -1,9 +1,22 @@
import {Injectable} from '@angular/core';
import {environment} from "../../environments/environment";
import {HttpClient, HttpErrorResponse, HttpResponse} from "@angular/common/http";
import {UserLogin} from "../dto/user-login";
import {Observable} from "rxjs";
@Injectable({
providedIn: 'root'
})
export class AuthenticationService {
constructor() { }
private host: string = environment.apiUrl;
constructor(private httpClient: HttpClient) {
}
public login(userDto: UserLogin): Observable<HttpResponse<any> | HttpErrorResponse> {
return this.httpClient.post<HttpResponse<any> | HttpErrorResponse>(`${this.host}/user/login`, userDto, {observe: 'response'});
}
}

View File

@ -6,6 +6,7 @@
"outDir": "./dist/out-tsc",
"forceConsistentCasingInFileNames": true,
"strict": true,
"strictPropertyInitialization": false,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"sourceMap": true,