From c734e57e88280d7b05f46f7630b691b5b45c926b Mon Sep 17 00:00:00 2001 From: Sonja Galovic Date: Tue, 22 Mar 2022 19:53:56 +0100 Subject: MyProfile stranica korisnika v1. Servis user-info za dobavljanje i izmenu podataka o korisniku. Dodata klasa User. --- frontend/src/app/_services/user-info.service.ts | 26 +++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 frontend/src/app/_services/user-info.service.ts (limited to 'frontend/src/app/_services/user-info.service.ts') diff --git a/frontend/src/app/_services/user-info.service.ts b/frontend/src/app/_services/user-info.service.ts new file mode 100644 index 00000000..b66a73e1 --- /dev/null +++ b/frontend/src/app/_services/user-info.service.ts @@ -0,0 +1,26 @@ +import { HttpClient } from '@angular/common/http'; +import { Injectable } from '@angular/core'; +import { Observable } from 'rxjs'; +import { API_SETTINGS } from 'src/config'; +import User from '../_data/User'; +import { AuthService } from './auth.service'; + +@Injectable({ + providedIn: 'root' +}) +export class UserInfoService { + + constructor(private http: HttpClient, private authService: AuthService) { } + + getUsersInfo(): Observable { + return this.http.get(`${API_SETTINGS.apiURL}/user/myprofile`, { headers: this.authService.authHeader() }); + } + + changeUserInfo(user: User): any { + return this.http.put(`${API_SETTINGS.apiURL}/user/${user._id}`, user, { headers: this.authService.authHeader() }); + } + + changeUserPassword(oldPassword: string, newPassword: string): Observable { + return this.http.put(`${API_SETTINGS.apiURL}/user/`, { oldPassword, newPassword }, { headers: this.authService.authHeader() }); + } +} -- cgit v1.2.3