|
|
|
@ -9,7 +9,6 @@ import { SmsReaderService } from 'src/app/hmg-common/services/sms/sms-reader.ser
|
|
|
|
import { ForgetPassword } from '../models/forget.password';
|
|
|
|
import { ForgetPassword } from '../models/forget.password';
|
|
|
|
import { LoginModel } from '../models/LoginModel';
|
|
|
|
import { LoginModel } from '../models/LoginModel';
|
|
|
|
import { SharedDataService } from 'src/app/hmg-common/services/shared-data-service/shared-data.service';
|
|
|
|
import { SharedDataService } from 'src/app/hmg-common/services/shared-data-service/shared-data.service';
|
|
|
|
import { LoginComponent } from "src/app/authentication/login/login.component";
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
@Component({
|
|
|
|
selector: 'app-forgot',
|
|
|
|
selector: 'app-forgot',
|
|
|
|
templateUrl: './forgot.component.html',
|
|
|
|
templateUrl: './forgot.component.html',
|
|
|
|
@ -18,63 +17,81 @@ import { LoginComponent } from "src/app/authentication/login/login.component";
|
|
|
|
export class ForgotComponent implements OnInit {
|
|
|
|
export class ForgotComponent implements OnInit {
|
|
|
|
|
|
|
|
|
|
|
|
private loginData = new LoginModel();
|
|
|
|
private loginData = new LoginModel();
|
|
|
|
public P_NEW_PASSWORD: string = '';
|
|
|
|
public P_NEW_PASSWORD = '';
|
|
|
|
public P_Confirm_NEW_PASSWORD: string = '';
|
|
|
|
// tslint:disable-next-line: variable-name
|
|
|
|
|
|
|
|
public P_Confirm_NEW_PASSWORD = '';
|
|
|
|
public P_USER_NAME: string;
|
|
|
|
public P_USER_NAME: string;
|
|
|
|
public logo = "assets/icon/login/lock.png";
|
|
|
|
public logo = 'assets/icon/login/lock.png';
|
|
|
|
|
|
|
|
public newPasswordIcon = "password";
|
|
|
|
|
|
|
|
public confirmPasswordIcon = "password";
|
|
|
|
public recentPasswordNote = {
|
|
|
|
public recentPasswordNote = {
|
|
|
|
yellowImg: '../assets/imgs/mohemm-action/info.png',
|
|
|
|
yellowImg: '../assets/imgs/mohemm-action/info.png',
|
|
|
|
text: 'Do not user recent password'
|
|
|
|
text: this.ts.trPK('login', 'current-password-validation')
|
|
|
|
};
|
|
|
|
};
|
|
|
|
public isLowerCase = {
|
|
|
|
public isLowerCase = {
|
|
|
|
blankImg: '../assets/icon/blank.svg',
|
|
|
|
blankImg: '../assets/icon/blank.svg',
|
|
|
|
greenImg: '../assets/icon/green.svg',
|
|
|
|
greenImg: '../assets/icon/green.svg',
|
|
|
|
redImg: '../assets/imgs/close.svg',
|
|
|
|
redImg: '../assets/imgs/close.svg',
|
|
|
|
text: 'At least one lowercase',
|
|
|
|
text: this.ts.trPK('login', 'lowercase-password-validation'),
|
|
|
|
isMatch: false
|
|
|
|
isMatch: false
|
|
|
|
};
|
|
|
|
};
|
|
|
|
public isUpperCase = {
|
|
|
|
public isUpperCase = {
|
|
|
|
blankImg: '../assets/icon/blank.svg',
|
|
|
|
blankImg: '../assets/icon/blank.svg',
|
|
|
|
greenImg: '../assets/icon/green.svg',
|
|
|
|
greenImg: '../assets/icon/green.svg',
|
|
|
|
redImg: '../assets/imgs/close.svg',
|
|
|
|
redImg: '../assets/imgs/close.svg',
|
|
|
|
text: 'At least one uppdercase',
|
|
|
|
text: this.ts.trPK('login', 'uppercase-password-validation'),
|
|
|
|
|
|
|
|
isMatch: false
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
public isLetterCase = {
|
|
|
|
|
|
|
|
blankImg: '../assets/icon/blank.svg',
|
|
|
|
|
|
|
|
greenImg: '../assets/icon/green.svg',
|
|
|
|
|
|
|
|
redImg: '../assets/imgs/close.svg',
|
|
|
|
|
|
|
|
text: this.ts.trPK('login', 'letter-password-validation'),
|
|
|
|
isMatch: false
|
|
|
|
isMatch: false
|
|
|
|
};
|
|
|
|
};
|
|
|
|
public isHasDigit = {
|
|
|
|
public isHasDigit = {
|
|
|
|
blankImg: '../assets/icon/blank.svg',
|
|
|
|
blankImg: '../assets/icon/blank.svg',
|
|
|
|
greenImg: '../assets/icon/green.svg',
|
|
|
|
greenImg: '../assets/icon/green.svg',
|
|
|
|
redImg: '../assets/imgs/close.svg',
|
|
|
|
redImg: '../assets/imgs/close.svg',
|
|
|
|
text: 'At least one nomeric',
|
|
|
|
text: this.ts.trPK('login', 'numerica-password-validation'),
|
|
|
|
isMatch: false
|
|
|
|
isMatch: false
|
|
|
|
};
|
|
|
|
};
|
|
|
|
public isMinLength = {
|
|
|
|
public isMinLength = {
|
|
|
|
blankImg: '../assets/icon/blank.svg',
|
|
|
|
blankImg: '../assets/icon/blank.svg',
|
|
|
|
greenImg: '../assets/icon/green.svg',
|
|
|
|
greenImg: '../assets/icon/green.svg',
|
|
|
|
redImg: '../assets/imgs/close.svg',
|
|
|
|
redImg: '../assets/imgs/close.svg',
|
|
|
|
text: 'Minimum 8 characters',
|
|
|
|
text: this.ts.trPK('login', 'min-password-validation'),
|
|
|
|
isMatch: false
|
|
|
|
isMatch: false
|
|
|
|
};
|
|
|
|
};
|
|
|
|
public isRepeatedLetter = {
|
|
|
|
public isRepeatedLetter = {
|
|
|
|
blankImg: '../assets/icon/blank.svg',
|
|
|
|
blankImg: '../assets/icon/blank.svg',
|
|
|
|
greenImg: '../assets/icon/green.svg',
|
|
|
|
greenImg: '../assets/icon/green.svg',
|
|
|
|
redImg: '../assets/imgs/close.svg',
|
|
|
|
redImg: '../assets/imgs/close.svg',
|
|
|
|
text: 'Do not add repeating letters',
|
|
|
|
text: this.ts.trPK('login', 'repeating-password-validation'),
|
|
|
|
isMatch: false
|
|
|
|
isMatch: false
|
|
|
|
};
|
|
|
|
};
|
|
|
|
public isContainSpecialChar = {
|
|
|
|
public isContainSpecialChar = {
|
|
|
|
blankImg: '../assets/icon/blank.svg',
|
|
|
|
blankImg: '../assets/icon/blank.svg',
|
|
|
|
greenImg: '../assets/icon/green.svg',
|
|
|
|
greenImg: '../assets/icon/green.svg',
|
|
|
|
redImg: '../assets/imgs/close.svg',
|
|
|
|
redImg: '../assets/imgs/close.svg',
|
|
|
|
text: 'It should contain special character',
|
|
|
|
text: this.ts.trPK('login', 'special-character-password-validation'),
|
|
|
|
isMatch: false
|
|
|
|
isMatch: false
|
|
|
|
};
|
|
|
|
};
|
|
|
|
public confirmMatchNew = {
|
|
|
|
public confirmMatchNew = {
|
|
|
|
blankImg: '../assets/icon/blank.svg',
|
|
|
|
blankImg: '../assets/icon/blank.svg',
|
|
|
|
greenImg: '../assets/icon/green.svg',
|
|
|
|
greenImg: '../assets/icon/green.svg',
|
|
|
|
redImg: '../assets/imgs/close.svg',
|
|
|
|
redImg: '../assets/imgs/close.svg',
|
|
|
|
text: 'Confirm Password does not match.',
|
|
|
|
text: this.ts.trPK('login', 'not-match-password-validation'),
|
|
|
|
isMatch: false
|
|
|
|
isMatch: false
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
public userNameMatchNew = {
|
|
|
|
|
|
|
|
blankImg: '../assets/icon/blank.svg',
|
|
|
|
|
|
|
|
greenImg: '../assets/icon/green.svg',
|
|
|
|
|
|
|
|
redImg: '../assets/imgs/close.svg',
|
|
|
|
|
|
|
|
text: this.ts.trPK('login', 'contain-username-password-validation'),
|
|
|
|
|
|
|
|
isMatch: false
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
public userId: string;
|
|
|
|
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
constructor(
|
|
|
|
public cs: CommonService,
|
|
|
|
public cs: CommonService,
|
|
|
|
@ -88,16 +105,22 @@ export class ForgotComponent implements OnInit {
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ngOnInit() { }
|
|
|
|
ngOnInit() {
|
|
|
|
|
|
|
|
console.log('ENAD >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>');
|
|
|
|
|
|
|
|
this.userId = this.sharedData.getSharedData(AuthenticationService.LOGIN_DATA, false).P_USER_NAME;
|
|
|
|
|
|
|
|
console.log(this.userId);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public onForgot() {
|
|
|
|
public onForgot() {
|
|
|
|
this.sendSMSForForgotPassword();
|
|
|
|
this.sendSMSForForgotPassword();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// tslint:disable-next-line: member-ordering
|
|
|
|
private checkUserResult: CheckUserAuthenticationResponse;
|
|
|
|
private checkUserResult: CheckUserAuthenticationResponse;
|
|
|
|
|
|
|
|
|
|
|
|
private sendSMSForForgotPassword() {
|
|
|
|
private sendSMSForForgotPassword() {
|
|
|
|
const request = new ForgetPassword();
|
|
|
|
const request = new ForgetPassword();
|
|
|
|
|
|
|
|
console.log(request);
|
|
|
|
this.authService.sendForgetPassword(
|
|
|
|
this.authService.sendForgetPassword(
|
|
|
|
request,
|
|
|
|
request,
|
|
|
|
() => {
|
|
|
|
() => {
|
|
|
|
@ -117,7 +140,7 @@ export class ForgotComponent implements OnInit {
|
|
|
|
forgetPasswordTokenID = forgetPasswordTokenResult.ForgetPasswordTokenID;
|
|
|
|
forgetPasswordTokenID = forgetPasswordTokenResult.ForgetPasswordTokenID;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.loginData.P_USER_NAME = this.P_USER_NAME;
|
|
|
|
this.loginData.P_USER_NAME = this.P_USER_NAME;
|
|
|
|
let request: any = {};
|
|
|
|
const request: any = {};
|
|
|
|
request.P_Confirm_NEW_PASSWORD = this.P_NEW_PASSWORD;
|
|
|
|
request.P_Confirm_NEW_PASSWORD = this.P_NEW_PASSWORD;
|
|
|
|
request.P_NEW_PASSWORD = this.P_Confirm_NEW_PASSWORD;
|
|
|
|
request.P_NEW_PASSWORD = this.P_Confirm_NEW_PASSWORD;
|
|
|
|
request.P_USER_NAME = data.P_USER_NAME;
|
|
|
|
request.P_USER_NAME = data.P_USER_NAME;
|
|
|
|
@ -126,12 +149,11 @@ export class ForgotComponent implements OnInit {
|
|
|
|
this.authService.submitForgetPassword(
|
|
|
|
this.authService.submitForgetPassword(
|
|
|
|
request,
|
|
|
|
request,
|
|
|
|
() => {
|
|
|
|
() => {
|
|
|
|
//this.sendSMSForForgotPassword();
|
|
|
|
|
|
|
|
}, this.ts.trPK('general', 'ok')).subscribe((result: CheckUserAuthenticationResponse) => {
|
|
|
|
}, this.ts.trPK('general', 'ok')).subscribe((result: CheckUserAuthenticationResponse) => {
|
|
|
|
if (this.cs.validResponse(result)) {
|
|
|
|
if (this.cs.validResponse(result)) {
|
|
|
|
this.checkUserResult = result;
|
|
|
|
this.checkUserResult = result;
|
|
|
|
console.log(result);
|
|
|
|
console.log(result);
|
|
|
|
this.cs.toastPK("changePassword", "successChange");
|
|
|
|
this.cs.toastPK('changePassword', 'successChange');
|
|
|
|
this.cs.openLogin();
|
|
|
|
this.cs.openLogin();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
@ -141,10 +163,12 @@ export class ForgotComponent implements OnInit {
|
|
|
|
checkerFuncation(val) {
|
|
|
|
checkerFuncation(val) {
|
|
|
|
if (this.P_NEW_PASSWORD === '') {
|
|
|
|
if (this.P_NEW_PASSWORD === '') {
|
|
|
|
switch (val) {
|
|
|
|
switch (val) {
|
|
|
|
|
|
|
|
// case 1:
|
|
|
|
|
|
|
|
// return this.isLowerCase.blankImg;
|
|
|
|
|
|
|
|
// case 2:
|
|
|
|
|
|
|
|
// return this.isUpperCase.blankImg;
|
|
|
|
case 1:
|
|
|
|
case 1:
|
|
|
|
return this.isLowerCase.blankImg;
|
|
|
|
return this.isLetterCase.blankImg;
|
|
|
|
case 2:
|
|
|
|
|
|
|
|
return this.isUpperCase.blankImg;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
case 3:
|
|
|
|
return this.isHasDigit.blankImg;
|
|
|
|
return this.isHasDigit.blankImg;
|
|
|
|
case 4:
|
|
|
|
case 4:
|
|
|
|
@ -155,24 +179,34 @@ export class ForgotComponent implements OnInit {
|
|
|
|
return this.isContainSpecialChar.blankImg;
|
|
|
|
return this.isContainSpecialChar.blankImg;
|
|
|
|
case 7:
|
|
|
|
case 7:
|
|
|
|
return this.confirmMatchNew.blankImg;
|
|
|
|
return this.confirmMatchNew.blankImg;
|
|
|
|
|
|
|
|
case 8:
|
|
|
|
|
|
|
|
return this.userNameMatchNew.blankImg;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
switch (val) {
|
|
|
|
switch (val) {
|
|
|
|
|
|
|
|
// case 1:
|
|
|
|
|
|
|
|
// if (/[a-z]/.test(this.P_NEW_PASSWORD)) {
|
|
|
|
|
|
|
|
// this.isLowerCase.isMatch = true;
|
|
|
|
|
|
|
|
// return this.isLowerCase.greenImg;
|
|
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
|
|
// this.isLowerCase.isMatch = false;
|
|
|
|
|
|
|
|
// return this.isLowerCase.redImg;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// case 2:
|
|
|
|
|
|
|
|
// if (/[A-Z]/.test(this.P_NEW_PASSWORD)) {
|
|
|
|
|
|
|
|
// this.isUpperCase.isMatch = true;
|
|
|
|
|
|
|
|
// return this.isUpperCase.greenImg;
|
|
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
|
|
// this.isUpperCase.isMatch = false;
|
|
|
|
|
|
|
|
// return this.isUpperCase.redImg;
|
|
|
|
|
|
|
|
// }
|
|
|
|
case 1:
|
|
|
|
case 1:
|
|
|
|
if (/[a-z]/.test(this.P_NEW_PASSWORD)) {
|
|
|
|
if (/[a-zA-Z]/.test(this.P_NEW_PASSWORD)) {
|
|
|
|
this.isLowerCase.isMatch = true;
|
|
|
|
this.isLetterCase.isMatch = true;
|
|
|
|
return this.isLowerCase.greenImg;
|
|
|
|
return this.isLetterCase.greenImg;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
this.isLowerCase.isMatch = false;
|
|
|
|
this.isLetterCase.isMatch = false;
|
|
|
|
return this.isLowerCase.redImg;
|
|
|
|
return this.isLetterCase.redImg;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
|
|
|
|
if (/[A-Z]/.test(this.P_NEW_PASSWORD)) {
|
|
|
|
|
|
|
|
this.isUpperCase.isMatch = true;
|
|
|
|
|
|
|
|
return this.isUpperCase.greenImg;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
this.isUpperCase.isMatch = false;
|
|
|
|
|
|
|
|
return this.isUpperCase.redImg;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case 3:
|
|
|
|
case 3:
|
|
|
|
if (/[0-9]/.test(this.P_NEW_PASSWORD)) {
|
|
|
|
if (/[0-9]/.test(this.P_NEW_PASSWORD)) {
|
|
|
|
@ -214,15 +248,40 @@ export class ForgotComponent implements OnInit {
|
|
|
|
this.confirmMatchNew.isMatch = true;
|
|
|
|
this.confirmMatchNew.isMatch = true;
|
|
|
|
return this.confirmMatchNew.greenImg;
|
|
|
|
return this.confirmMatchNew.greenImg;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
case 8:
|
|
|
|
|
|
|
|
if (!this.P_NEW_PASSWORD.includes(this.userId)) {
|
|
|
|
|
|
|
|
this.userNameMatchNew.isMatch = true;
|
|
|
|
|
|
|
|
return this.userNameMatchNew.greenImg;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
this.userNameMatchNew.isMatch = false;
|
|
|
|
|
|
|
|
return this.userNameMatchNew.redImg;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
disabledSubmitBtn() {
|
|
|
|
disabledSubmitBtn() {
|
|
|
|
if (this.isLowerCase.isMatch && this.isUpperCase.isMatch && this.isHasDigit.isMatch && this.isMinLength.isMatch
|
|
|
|
if (this.isLetterCase.isMatch && this.isHasDigit.isMatch && this.isMinLength.isMatch
|
|
|
|
&& this.isRepeatedLetter.isMatch && this.P_NEW_PASSWORD !== '' && this.P_NEW_PASSWORD
|
|
|
|
&& this.isRepeatedLetter.isMatch && this.P_NEW_PASSWORD !== '' && this.P_NEW_PASSWORD
|
|
|
|
&& this.P_Confirm_NEW_PASSWORD && this.isContainSpecialChar && this.confirmMatchNew.isMatch) {
|
|
|
|
&& this.P_Confirm_NEW_PASSWORD && this.isContainSpecialChar.isMatch && this.confirmMatchNew.isMatch) {
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
} else { return true; }
|
|
|
|
} else { return true; }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
showPassword(val) {
|
|
|
|
|
|
|
|
if (val == 1)
|
|
|
|
|
|
|
|
this.newPasswordIcon = 'password';
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
this.confirmPasswordIcon = 'password'
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
hidePassword(val) {
|
|
|
|
|
|
|
|
if (val == 1)
|
|
|
|
|
|
|
|
this.newPasswordIcon = 'text';
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
this.confirmPasswordIcon = 'text'
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|