response data gets saved now JO

master
Max 5 years ago
parent 0b9f9cbbcb
commit eeb339b1fa

@ -27,6 +27,9 @@ export class AppComponent implements OnInit {
requestIDs : number[]; requestIDs : number[];
ngOnInit() { ngOnInit() {
this.data.currentUserInfo.subscribe(user => this.userInfo = user) this.data.currentUserInfo.subscribe(user => {
this.userInfo = user;
console.log(this.userInfo);
})
} }
} }

@ -8,8 +8,7 @@ import { LoginService } from 'src/app/services/login/login.service';
styleUrls: ['./login.component.sass'] styleUrls: ['./login.component.sass']
}) })
export class LoginComponent implements OnInit { export class LoginComponent implements OnInit {
login: Login login: Login
user: User
constructor(private loginService: LoginService) { constructor(private loginService: LoginService) {
this.login = {passwordHash: null, email: null}; this.login = {passwordHash: null, email: null};

@ -3,6 +3,7 @@ import {Http, URLSearchParams, Headers} from '@angular/http';
import { Login } from '../../models/login'; import { Login } from '../../models/login';
import { User } from 'src/app/models/user'; import { User } from 'src/app/models/user';
import { DatasharingService } from '../datasharing.service'; import { DatasharingService } from '../datasharing.service';
import { userInfo } from 'os';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
@ -26,8 +27,21 @@ export class LoginService {
}); });
} }
public updateUserInfo(pUserInfo : User){ public updateUserInfo(response : any){
this.data.changeUserInfo(pUserInfo) 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)
} }

Loading…
Cancel
Save