|
|
@@ -25,6 +25,8 @@ export class NewPasswordComponent implements OnInit {
|
|
|
submitted: boolean = false;
|
|
|
showDetails: boolean;
|
|
|
newPass: boolean;
|
|
|
+ userData: any;
|
|
|
+ sendOtherToken: boolean;
|
|
|
|
|
|
constructor(
|
|
|
private formBuilder: FormBuilder,
|
|
|
@@ -37,6 +39,12 @@ export class NewPasswordComponent implements OnInit {
|
|
|
}
|
|
|
|
|
|
ngOnInit() {
|
|
|
+ Swal.fire({
|
|
|
+ allowOutsideClick: false,
|
|
|
+ type: "info",
|
|
|
+ text: "Espere por favor...",
|
|
|
+ });
|
|
|
+ Swal.showLoading();
|
|
|
if (this.token !== null) {
|
|
|
this.userService
|
|
|
.validateUserToken({
|
|
|
@@ -45,8 +53,9 @@ export class NewPasswordComponent implements OnInit {
|
|
|
})
|
|
|
.subscribe(
|
|
|
(res) => {
|
|
|
- console.log(res);
|
|
|
- let userData = res["data"].user;
|
|
|
+ Swal.close();
|
|
|
+ this.sendOtherToken = false;
|
|
|
+ this.userData = res["data"].user;
|
|
|
this.newPass = true;
|
|
|
this.validToken = true;
|
|
|
this.activateForm = this.formBuilder.group(
|
|
|
@@ -68,10 +77,12 @@ export class NewPasswordComponent implements OnInit {
|
|
|
);
|
|
|
},
|
|
|
(err) => {
|
|
|
+ Swal.close();
|
|
|
this.newPass = false;
|
|
|
this.userActivated = true;
|
|
|
this.invalidToken = true;
|
|
|
this.errorMessage = err.message;
|
|
|
+ this.sendOtherToken = true;
|
|
|
}
|
|
|
);
|
|
|
} else {
|
|
|
@@ -80,6 +91,38 @@ export class NewPasswordComponent implements OnInit {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ getNewToken() {
|
|
|
+ Swal.fire({
|
|
|
+ allowOutsideClick: false,
|
|
|
+ type: "info",
|
|
|
+ text: "Espere por favor...",
|
|
|
+ });
|
|
|
+ Swal.showLoading();
|
|
|
+ this.userService
|
|
|
+ .sendAnotherToken({
|
|
|
+ token: this.token,
|
|
|
+ })
|
|
|
+ .subscribe(
|
|
|
+ (res) => {
|
|
|
+ Swal.fire({
|
|
|
+ type: "success",
|
|
|
+ title: "Exito",
|
|
|
+ text: "Se ha enviado otro correo para recuperación de contraseña",
|
|
|
+ }).then((result) => {
|
|
|
+ this.successActivation = true;
|
|
|
+ this.validToken = false;
|
|
|
+ this.invalidToken = false;
|
|
|
+ window.location.href = "#/investment-proposals";
|
|
|
+ });
|
|
|
+ },
|
|
|
+ (err) => {
|
|
|
+ Swal.close();
|
|
|
+ this.validToken = false;
|
|
|
+ this.errorMessage = err.message;
|
|
|
+ }
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
get f() {
|
|
|
return this.activateForm.controls;
|
|
|
}
|
|
|
@@ -91,24 +134,40 @@ export class NewPasswordComponent implements OnInit {
|
|
|
if (this.activateForm.invalid) {
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
+ Swal.fire({
|
|
|
+ allowOutsideClick: false,
|
|
|
+ type: "info",
|
|
|
+ text: "Espere por favor...",
|
|
|
+ });
|
|
|
+ Swal.showLoading();
|
|
|
this.userService
|
|
|
.changePassword({
|
|
|
password: this.f.password.value,
|
|
|
confirm_password: this.f.confirm_password.value,
|
|
|
- /*phone_number: this.f.phone_number.value,
|
|
|
- distribuidora: this.f.distribuidora.value,
|
|
|
- cod_tarifa: this.f.cod_tarifa.value*/
|
|
|
+ email: this.userData.email,
|
|
|
+ first_name: this.userData.first_name,
|
|
|
+ last_name: this.userData.last_name,
|
|
|
+ phone_number: this.userData.phone_number,
|
|
|
})
|
|
|
.subscribe(
|
|
|
(res) => {
|
|
|
- this.successActivation = true;
|
|
|
- this.validToken = false;
|
|
|
- this.activateMessage = "Su clave ha sido actualizada exitosamente";
|
|
|
+ Swal.fire({
|
|
|
+ type: "success",
|
|
|
+ title: "Exito",
|
|
|
+ text: "Su clave ha sido actualizada exitosamente",
|
|
|
+ }).then((result) => {
|
|
|
+ this.successActivation = true;
|
|
|
+ this.validToken = false;
|
|
|
+ window.location.href = "#/investment-proposals";
|
|
|
+ });
|
|
|
},
|
|
|
(err) => {
|
|
|
+ Swal.fire({
|
|
|
+ type: "error",
|
|
|
+ title: "Error en el servidor",
|
|
|
+ text: err.message,
|
|
|
+ });
|
|
|
this.validToken = false;
|
|
|
- this.errorMessage = err.message;
|
|
|
}
|
|
|
);
|
|
|
//
|