From eeb339b1faba5c5588f01f650312c7c7d7504580 Mon Sep 17 00:00:00 2001 From: Max Date: Thu, 17 Oct 2019 14:07:02 +0200 Subject: [PATCH] response data gets saved now JO --- src/app/app.component.ts | 5 ++++- src/app/components/login/login.component.ts | 3 +-- src/app/services/login/login.service.ts | 18 ++++++++++++++++-- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 8a9f97e..35e899d 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -27,6 +27,9 @@ export class AppComponent implements OnInit { requestIDs : number[]; ngOnInit() { - this.data.currentUserInfo.subscribe(user => this.userInfo = user) + this.data.currentUserInfo.subscribe(user => { + this.userInfo = user; + console.log(this.userInfo); + }) } } diff --git a/src/app/components/login/login.component.ts b/src/app/components/login/login.component.ts index 8a2c5b0..40d6725 100644 --- a/src/app/components/login/login.component.ts +++ b/src/app/components/login/login.component.ts @@ -8,8 +8,7 @@ import { LoginService } from 'src/app/services/login/login.service'; styleUrls: ['./login.component.sass'] }) export class LoginComponent implements OnInit { - login: Login - user: User + login: Login constructor(private loginService: LoginService) { this.login = {passwordHash: null, email: null}; diff --git a/src/app/services/login/login.service.ts b/src/app/services/login/login.service.ts index 42d4ce7..8276696 100644 --- a/src/app/services/login/login.service.ts +++ b/src/app/services/login/login.service.ts @@ -3,6 +3,7 @@ import {Http, URLSearchParams, Headers} from '@angular/http'; import { Login } from '../../models/login'; import { User } from 'src/app/models/user'; import { DatasharingService } from '../datasharing.service'; +import { userInfo } from 'os'; @Injectable({ providedIn: 'root' @@ -26,8 +27,21 @@ export class LoginService { }); } - public updateUserInfo(pUserInfo : User){ - this.data.changeUserInfo(pUserInfo) + public updateUserInfo(response : any){ + const user: User = new User(); + user.loggedIn = true; + user.userID = response.data.login.id; + user.username = response.data.login.name; + user.handle = response.data.login.handle; + user.email = response.data.login.email; + user.points = response.data.login.points; + user.level = response.data.login.level; + user.friendIDs = response.data.login.friends; + user.groupIDs = response.data.login.groups; + user.chatIDs = response.data.login.chats; + user.requestIDs = response.data.login.requests; + + this.data.changeUserInfo(user) }