|
|
|
@ -6,6 +6,9 @@ import { PasswordHideShowComponent } from '../../shared/components/password-hide
|
|
|
|
import { HttpURIService } from '../../app.http.uri.service';
|
|
|
|
import { HttpURIService } from '../../app.http.uri.service';
|
|
|
|
import { URIKey } from '../../utils/uri-enums';
|
|
|
|
import { URIKey } from '../../utils/uri-enums';
|
|
|
|
import { StorageService } from '../../shared/services/storage.service';
|
|
|
|
import { StorageService } from '../../shared/services/storage.service';
|
|
|
|
|
|
|
|
import { I18NService } from '../../services/i18n.service';
|
|
|
|
|
|
|
|
import { HttpErrorResponse } from '@angular/common/http';
|
|
|
|
|
|
|
|
import { SuccessMessages } from '../../utils/enums';
|
|
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
@Component({
|
|
|
|
selector: 'app-change-password',
|
|
|
|
selector: 'app-change-password',
|
|
|
|
@ -28,7 +31,7 @@ passwordType2: string = 'password';
|
|
|
|
@ViewChild('psh') passwordHideShow?: PasswordHideShowComponent;
|
|
|
|
@ViewChild('psh') passwordHideShow?: PasswordHideShowComponent;
|
|
|
|
@ViewChild('psh1') passwordHideShow1 ?: PasswordHideShowComponent;
|
|
|
|
@ViewChild('psh1') passwordHideShow1 ?: PasswordHideShowComponent;
|
|
|
|
@ViewChild('psh2') passwordHideShow2 ?: PasswordHideShowComponent;
|
|
|
|
@ViewChild('psh2') passwordHideShow2 ?: PasswordHideShowComponent;
|
|
|
|
constructor(private fb: FormBuilder, private httpURIService: HttpURIService, private storageService: StorageService){}
|
|
|
|
constructor(private fb: FormBuilder, private httpURIService: HttpURIService, private storageService: StorageService, private i18nService: I18NService){}
|
|
|
|
|
|
|
|
|
|
|
|
togglePasswordType() {
|
|
|
|
togglePasswordType() {
|
|
|
|
this.passwordType = this.passwordHideShow?.showPassword ? 'password' : 'text';
|
|
|
|
this.passwordType = this.passwordHideShow?.showPassword ? 'password' : 'text';
|
|
|
|
@ -65,13 +68,6 @@ constructor(private fb: FormBuilder, private httpURIService: HttpURIService, pri
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
checkIfFirstTimeChangePasswordOrNot(): void {
|
|
|
|
checkIfFirstTimeChangePasswordOrNot(): void {
|
|
|
|
const fromMenu = history.state?.['fromMenu'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (fromMenu) {
|
|
|
|
|
|
|
|
this.isFirstLogin = false;
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
const currentUser: any = JSON.parse(
|
|
|
|
const currentUser: any = JSON.parse(
|
|
|
|
this.storageService.getItem('user') || '{}'
|
|
|
|
this.storageService.getItem('user') || '{}'
|
|
|
|
@ -120,7 +116,6 @@ constructor(private fb: FormBuilder, private httpURIService: HttpURIService, pri
|
|
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
oldPassword: form.get('oldPassword')?.value || null,
|
|
|
|
oldPassword: form.get('oldPassword')?.value || null,
|
|
|
|
// confirmPassword: form.get('confirmPassword')?.value || null,
|
|
|
|
|
|
|
|
newPassword: form.get('newPassword')?.value,
|
|
|
|
newPassword: form.get('newPassword')?.value,
|
|
|
|
userId: this.storageService.getItem('USER_ID'),
|
|
|
|
userId: this.storageService.getItem('USER_ID'),
|
|
|
|
porOrgaCode: this.storageService.getItem('POR_ORGACODE')
|
|
|
|
porOrgaCode: this.storageService.getItem('POR_ORGACODE')
|
|
|
|
@ -130,7 +125,15 @@ constructor(private fb: FormBuilder, private httpURIService: HttpURIService, pri
|
|
|
|
const payload = this.getFormPayload();
|
|
|
|
const payload = this.getFormPayload();
|
|
|
|
|
|
|
|
|
|
|
|
this.httpURIService.requestPOST(URIKey.CHANGE_PASSWORD_URI, payload)
|
|
|
|
this.httpURIService.requestPOST(URIKey.CHANGE_PASSWORD_URI, payload)
|
|
|
|
.subscribe();
|
|
|
|
.subscribe({
|
|
|
|
|
|
|
|
next: (response) => {
|
|
|
|
|
|
|
|
if (!(response instanceof HttpErrorResponse)) {
|
|
|
|
|
|
|
|
this.i18nService.success(SuccessMessages.CHANGE_PASSWORD_SUCCESS, []);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|