aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/app/_services/user-info.service.ts
diff options
context:
space:
mode:
authorDanijel Andjelkovic <adanijel99@gmail.com>2022-03-22 22:49:29 +0100
committerDanijel Andjelkovic <adanijel99@gmail.com>2022-03-22 22:49:29 +0100
commit1e945887ec22158c517c33afab0a38cb713eb144 (patch)
tree2ed31144dfe52de50813e1a8cd105c0cb0573214 /frontend/src/app/_services/user-info.service.ts
parent480bd1db98f08266fcc3c8f499eaea0365bde6b5 (diff)
parent2d02d336687d7780cd3c122f10933a772a0a3d1a (diff)
Merge branch 'dev' of http://gitlab.pmf.kg.ac.rs/igrannonica/neuronstellar into dev
Diffstat (limited to 'frontend/src/app/_services/user-info.service.ts')
-rw-r--r--frontend/src/app/_services/user-info.service.ts26
1 files changed, 26 insertions, 0 deletions
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<User> {
+ return this.http.get<User>(`${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<User> {
+ return this.http.put<User>(`${API_SETTINGS.apiURL}/user/`, { oldPassword, newPassword }, { headers: this.authService.authHeader() });
+ }
+}