latest
This commit is contained in:
@@ -24,7 +24,7 @@
|
||||
<div class="alert alert-success" *ngIf="updateSuccess">
|
||||
<strong>Update Success!</strong>
|
||||
</div>
|
||||
<form (ngSubmit)="updateUserInfo" method="post">
|
||||
<form (ngSubmit)="onUpdateUserInfo()" >
|
||||
<input type="hidden" name="id" [(ngModel)]="user.id" />
|
||||
<div class="bg-info" *ngIf="updateUserInfo">User info updated.</div>
|
||||
<div class="form-group">
|
||||
@@ -55,7 +55,7 @@
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="txtNewPassword">Password</label> <span id="checkPasswordMatch" style="color:red;"></span>
|
||||
<input type="password" class="form-control" id="txtNewPassword" name="newPassword" />
|
||||
<input type="password" class="form-control" id="txtNewPassword" name="newPassword" [(ngModel)]="newPassword" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="txtConfirmPassword">Confirm Password</label>
|
||||
|
||||
@@ -33,6 +33,9 @@ export class MyProfileComponent implements OnInit {
|
||||
private recoverEmail:string;
|
||||
|
||||
private user: User = new User();
|
||||
private updateSuccess:boolean;
|
||||
private newPassword:string;
|
||||
private incorrectPassword:boolean;
|
||||
private userPayment: UserPayment = new UserPayment();
|
||||
private userBilling: UserBilling = new UserBilling();
|
||||
private userPaymentList: UserPayment[] = [];
|
||||
@@ -119,6 +122,20 @@ export class MyProfileComponent implements OnInit {
|
||||
);
|
||||
}
|
||||
|
||||
onUpdateUserInfo() {
|
||||
this.userService.updateUserInfo(this.user, this.newPassword).subscribe(
|
||||
res => {
|
||||
console.log(res.text());
|
||||
this.updateSuccess = true;
|
||||
},
|
||||
error => {
|
||||
console.log(error.text());
|
||||
let errorMessage=error.text();
|
||||
if (errorMessage==="Incorrect current password!") this.incorrectPassword=true;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
onNewPayment () {
|
||||
this.paymentService.newPayment(this.userPayment).subscribe(
|
||||
res => {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import {AppConst} from '../constants/app-const';
|
||||
import {Http, Headers} from '@angular/http';
|
||||
import {User} from '../models/User';
|
||||
|
||||
@Injectable()
|
||||
export class UserService {
|
||||
@@ -18,6 +19,25 @@ export class UserService {
|
||||
'Content-Type': 'application/json',
|
||||
'x-auth-token' : localStorage.getItem("xAuthToken")
|
||||
});
|
||||
return this.http.post(url, userInfo, {headers : tokenHeader});
|
||||
}
|
||||
|
||||
updateUserInfo(user:User, newPassword:string) {
|
||||
|
||||
let url = this.serverPath+"/user/updateUserInfo";
|
||||
let userInfo = {
|
||||
"id" : user.id,
|
||||
"firstName" : user.firstName,
|
||||
"lastName" : user.lastName,
|
||||
"username" : user.username,
|
||||
"currentPassword" : user.password,
|
||||
"email" : user.email,
|
||||
"newPassword" : newPassword
|
||||
};
|
||||
let tokenHeader = new Headers ({
|
||||
'Content-Type': 'application/json',
|
||||
'x-auth-token' : localStorage.getItem("xAuthToken")
|
||||
});
|
||||
return this.http.post(url, JSON.stringify(userInfo), {headers : tokenHeader});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user