forgot password completed

master
ansariakhtar 6 years ago
parent a46ebcb357
commit 1d79849787

@ -18,6 +18,7 @@ import { MobileNumberModule } from 'src/app/hmg-common/ui/mobile-number/mobile-
import { SmsdialogPageModule } from 'src/app/hmg-common/ui/smsdialog/smsdialog.module';
import { SmsPageModule } from 'src/app/hmg-common/ui/sms/sms.module';
import { SmsPagePage } from './sms-page/sms-page.page';
import { CheckUserComponent } from './check-user/check-user.component';
@ -41,6 +42,10 @@ const routes: Routes = [
{
path: 'smspage',
component: SmsPagePage
},
{
path: 'checkuser',
component: CheckUserComponent
}
]
}
@ -65,7 +70,8 @@ const routes: Routes = [
LoginComponent,
ForgotComponent,
AgreementComponent,
SmsPagePage
SmsPagePage,
CheckUserComponent
],
providers:[
FingerprintAIO,

@ -0,0 +1,33 @@
<ion-header>
<ion-toolbar class="header-toolbar">
<ion-buttons slot="start">
<ion-back-button color="light" class="btnBack" ></ion-back-button>
</ion-buttons>
<ion-title color="light" > {{'login,forgot-password' | translate}}</ion-title>
</ion-toolbar>
</ion-header>
<ion-content padding>
<ion-grid>
<ion-item>
<img class="item-icon" src="assets/imgs/username.png" item-start />
<ion-label>{{ts.trPK('login','username')}}</ion-label>
<ion-input required type="text" [(ngModel)]="P_USER_NAME">
</ion-input>
</ion-item>
</ion-grid>
<page-trailer [small]="true"></page-trailer>
</ion-content>
<ion-footer>
<div class="centerDiv">
<ion-button color="customnavy" ion-button (click)=" userCheck()">{{ts.trPK('login','changepassword')}}</ion-button>
</div>
</ion-footer>

@ -0,0 +1,7 @@
.header-toolbar{
--background: linear-gradient(45deg, #3ac1f1 0%, #19a163 36%, #19a163 59%, #1a586d 100%);
}
.btnBack{
background: transparent;
}

@ -0,0 +1,27 @@
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { CheckUserComponent } from './check-user.component';
describe('CheckUserComponent', () => {
let component: CheckUserComponent;
let fixture: ComponentFixture<CheckUserComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ CheckUserComponent ],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(CheckUserComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

@ -0,0 +1,98 @@
import { Component, OnInit, ViewChild, ChangeDetectorRef, OnDestroy } from '@angular/core';
import { CommonService } from 'src/app/hmg-common/services/common/common.service';
import { AuthenticationService } from 'src/app/hmg-common/services/authentication/authentication.service';
import { Router } from '@angular/router';
import { AlertController } from '@ionic/angular';
import { TranslatorService } from 'src/app/hmg-common/services/translator/translator.service';
import { CheckUserAuthenticationRequest } from 'src/app/hmg-common/services/authentication/models/check-user-auth.request';
import { CheckUserAuthenticationResponse } from 'src/app/hmg-common/services/authentication/models/check-user-auth.response';
import { CheckActivationCodeRequest } from 'src/app/hmg-common/services/authentication/models/check-activation-code.request';
import { SmsReaderService } from 'src/app/hmg-common/services/sms/sms-reader.service';
import { ForgotFileIDResponse } from '../../hmg-common/services/authentication/models/forgot-File-ID.response';
import { InternationalMobileComponent } from 'src/app/hmg-common/ui/mobile-number/international-mobile/international-mobile.component';
import { CountryCode } from 'src/app/hmg-common/ui/mobile-number/international-mobile/models/country-code.model';
import { LoginRequest } from 'src/app/hmg-common/services/authentication/models/login.request';
import { SharedDataService } from 'src/app/hmg-common/services/shared-data-service/shared-data.service';
import { Password } from '../models/password';
import { LoginModel } from '../models/LoginModel';
@Component({
selector: 'app-check-user',
templateUrl: './check-user.component.html',
styleUrls: ['./check-user.component.scss'],
})
export class CheckUserComponent implements OnInit,OnDestroy {
public P_USER_NAME : string;
private loginData = new LoginModel();
@ViewChild(InternationalMobileComponent) internationlMobile: InternationalMobileComponent;
constructor(public cs: CommonService,
public authService: AuthenticationService,
public router: Router,
public alertController: AlertController,
public ts: TranslatorService,
public smsService: SmsReaderService,
public sharedData: SharedDataService,
public changeDetector: ChangeDetectorRef) { }
ngOnInit() {}
ngOnDestroy(): void {
this.smsService.stopSMSMonitoring();
}
public onForgot() {
this.sendSMSForForgotPassword();
}
public userCheck()
{
this.cs.startLoading();
const request = new CheckUserAuthenticationRequest();
request.P_USER_NAME = this.P_USER_NAME;
this.authService.checkUserAuthentication(
request,
() => {
//this.sendSMSForForgotPassword();
}, this.ts.trPK('general', 'ok')).subscribe((result: CheckUserAuthenticationResponse) => {
if (this.cs.validResponse(result)) {
this.checkUserResult = result;
this.cs.stopLoading();
this.sendSMSForForgotPassword();
// if (result.isSMSSent) {
// this.startReceivingSMS();
// this.presentSMSPasswordDialog();
// }
}
});
}
private checkUserResult: CheckUserAuthenticationResponse;
private sendSMSForForgotPassword() {
this.cs.startLoading();
let changePwdObj= new LoginRequest();
changePwdObj.MobileNumber= this.checkUserResult.BasicMemberInformation.P_MOBILE_NUMBER;
changePwdObj.P_USER_NAME=this.P_USER_NAME;
changePwdObj.P_MOBILE_NUMBER=this.checkUserResult.BasicMemberInformation.P_MOBILE_NUMBER;
this.authService.sendPublicSMS(
changePwdObj,
() => {
this.sendSMSForForgotPassword();
}, this.ts.trPK('general', 'ok')).subscribe((result: CheckUserAuthenticationResponse) => {
if (this.cs.validResponse(result)) {
this.checkUserResult = result;
console.log("2");
console.log(result);
this.loginData.LogInTokenID = result.LogInTokenID;
this.loginData.P_USER_NAME = this.P_USER_NAME;
this.sharedData.setSharedData(this.loginData, "logindata");
this.sharedData.setSharedData(true,Password.IS_FORGET_PSW);
this.cs.stopLoading();
this.cs.openSMSPage();
}});
}
}

@ -12,14 +12,21 @@
<ion-content padding>
<ion-grid>
<ion-item>
<img class="item-icon" src="assets/imgs/username.png" item-start />
<ion-label>{{ts.trPK('login','username')}}</ion-label>
<ion-input required type="text" [(ngModel)]="P_USER_NAME">
</ion-input>
</ion-item>
<ion-item>
<img class="item-icon" src="assets/imgs/password.png" item-start />
<ion-label>{{'changePassword,newPassword' | translate}}</ion-label>
<ion-input required type="password"
[(ngModel)]="P_NEW_PASSWORD">
</ion-input>
</ion-item>
<ion-item>
<img class="item-icon" src="assets/imgs/password.png" item-start />
<ion-label>{{'changePassword,confirmPassword' | translate}}</ion-label>
<ion-input required type="password"
[(ngModel)]="P_Confirm_NEW_PASSWORD">
</ion-input>
</ion-item>
</ion-grid>
<page-trailer [small]="true"></page-trailer>
@ -28,6 +35,6 @@
</ion-content>
<ion-footer>
<div class="centerDiv">
<ion-button color="customnavy" ion-button (click)=" userCheck()">{{ts.trPK('login','changepassword')}}</ion-button>
</div>
<ion-button color="customnavy" ion-button (click)=" forgotpassword()">{{ts.trPK('login','changepassword')}}</ion-button>
</div>
</ion-footer>

@ -11,7 +11,9 @@ import { SmsReaderService } from 'src/app/hmg-common/services/sms/sms-reader.ser
import { ForgotFileIDResponse } from '../../hmg-common/services/authentication/models/forgot-File-ID.response';
import { InternationalMobileComponent } from 'src/app/hmg-common/ui/mobile-number/international-mobile/international-mobile.component';
import { CountryCode } from 'src/app/hmg-common/ui/mobile-number/international-mobile/models/country-code.model';
import { ForgetPassword } from '../models/forget.password';
import { LoginModel } from '../models/LoginModel';
import { SharedDataService } from 'src/app/hmg-common/services/shared-data-service/shared-data.service';
@Component({
selector: 'app-forgot',
@ -20,7 +22,10 @@ import { CountryCode } from 'src/app/hmg-common/ui/mobile-number/international-m
})
export class ForgotComponent implements OnInit,OnDestroy {
public countryCode: CountryCode;
private loginData = new LoginModel();
public P_NEW_PASSWORD: string;
public P_Confirm_NEW_PASSWORD : string;
public P_USER_NAME : string;
@ViewChild(InternationalMobileComponent) internationlMobile: InternationalMobileComponent;
constructor(
public cs: CommonService,
@ -29,7 +34,8 @@ export class ForgotComponent implements OnInit,OnDestroy {
public alertController: AlertController,
public ts: TranslatorService,
public smsService: SmsReaderService,
public changeDetector: ChangeDetectorRef
public changeDetector: ChangeDetectorRef,
public sharedData: SharedDataService
) {
}
@ -39,77 +45,49 @@ export class ForgotComponent implements OnInit,OnDestroy {
ngOnDestroy(): void {
this.smsService.stopSMSMonitoring();
}
public onForgot() {
this.sendSMSForForgotPassword();
}
public countryCodeChanged(countryCode: CountryCode) {
this.countryCode = countryCode;
}
public isValidForm() {
return (this.countryCode && this.countryCode.isValid);
}
private checkUserResult: CheckUserAuthenticationResponse;
private sendSMSForForgotPassword() {
const request = new CheckUserAuthenticationRequest();
const request = new ForgetPassword();
//request.PatientMobileNumber = this.countryCode.number;
//request.ZipCode = CountryCode.localCode(this.countryCode.code);
this.authService.sendSMSForForgotFileNumber(
this.authService.sendForgetPassword(
request,
() => {
this.sendSMSForForgotPassword();
}, this.ts.trPK('general', 'ok')).subscribe((result: CheckUserAuthenticationResponse) => {
if (this.cs.validResponse(result)) {
this.checkUserResult = result;
if (result.isSMSSent) {
this.startReceivingSMS();
this.presentSMSPasswordDialog();
}
}
});
}
private startReceivingSMS() {
this.smsService.startSMSMonitoring((code) => {
this.cs.dismissSMSDialog().subscribe(cleared => {
this.checkActivationCode(code);
});
});
}
public presentSMSPasswordDialog() {
this.cs.presentSMSPasswordDialog(
(code: string) => {
this.checkActivationCode(code);
});
}
private checkActivationCode(readedCode?) {
const request = new CheckActivationCodeRequest();
request.LogInTokenID = this.checkUserResult.LogInTokenID;
request.PatientOutSA = this.checkUserResult.PatientOutSA ? 1 : 0;
request.PatientMobileNumber = this.countryCode.number;
request.ZipCode = CountryCode.localCode(this.countryCode.code);
request.activationCode = readedCode;
this.authService.forgotFileIdActivation(request,
public forgotpassword(){
const data = this.sharedData.getSharedData("logindata", false);
this.loginData.P_USER_NAME = this.P_USER_NAME;
let request:ForgetPassword = new ForgetPassword();
request.P_Confirm_NEW_PASSWORD=this.P_NEW_PASSWORD;
request.P_NEW_PASSWORD=this.P_Confirm_NEW_PASSWORD;
request.P_USER_NAME = data.P_USER_NAME;
//console.log(request);
//request.P_USER_NAME = this.userName.P_USER_NAME;
this.authService.submitForgetPassword(
request,
() => {
this.presentSMSPasswordDialog();
}, this.ts.trPK('general', 'retry')).subscribe((result: ForgotFileIDResponse) => {
//this.sendSMSForForgotPassword();
}, this.ts.trPK('general', 'ok')).subscribe((result: CheckUserAuthenticationResponse) => {
if (this.cs.validResponse(result)) {
this.smsService.stopSMSMonitoring();
this.cs.presentAlert(result.ReturnMessage);
this.checkUserResult = result;
console.log(result);
this.cs.toastPK("changePassword","passwordchanged");
this.cs.openLogin();
}
});
}
}

@ -17,6 +17,7 @@ import { Device } from '@ionic-native/device/ngx';
import { SplashScreen } from '@ionic-native/splash-screen/ngx';
import { SharedDataService } from 'src/app/hmg-common/services/shared-data-service/shared-data.service';
import { LoginModel } from '../models/LoginModel';
import { LoginRequest } from 'src/app/hmg-common/services/authentication/models/login.request';
@Component({
selector: 'login',
@ -356,12 +357,12 @@ export class LoginComponent implements OnInit, OnDestroy {
}
private checkUserAuthentication() {
const request = new CheckUserAuthenticationRequest();
const request = new LoginRequest();
request.P_USER_NAME = this.username;
request.P_LANGUAGE = this.language;
request.P_PASSWORD = this.password;
console.log(request);
this.authService.checkUserAuthentication(
this.authService.login(
request,
() => {
}, this.ts.trPK('general', 'ok')).subscribe((result: CheckUserAuthenticationResponse) => {

@ -0,0 +1,7 @@
import { Request } from 'src/app/hmg-common/services/models/request';
export class ForgetPassword extends Request {
public static IS_FORGET_PSW:string="is_forget_password";
public P_NEW_PASSWORD: string;
public P_Confirm_NEW_PASSWORD:string;
public P_USER_NAME : string;
}

@ -0,0 +1,10 @@
import { Request } from 'src/app/hmg-common/services/models/request';
export class Password extends Request {
public static IS_FORGET_PSW:string="is_forget_password";
public IS_FORGET_PWD:boolean;
public P_NEW_PASSWORD: string;
public P_OLD_PASSWORD:string;
public P_Confirm_NEW_PASSWORD:string;
}

@ -8,6 +8,7 @@ import { SMSCheckRequest } from 'src/app/hmg-common/services/authentication/mode
import { LoginModel } from '../models/LoginModel';
import { AuthenticationService } from 'src/app/hmg-common/services/authentication/authentication.service';
import { SMSCheckResponse } from 'src/app/hmg-common/services/authentication/models/smscheck.response';
import { Password } from '../models/password';
@Component({
@ -44,6 +45,7 @@ export class SmsPagePage implements OnInit {
this.count = 0;
this.initTimer();
this.startTimer();
this.isForgetPwd = this.sharedData.getSharedData(Password.IS_FORGET_PSW) || false;
}
@ -126,7 +128,7 @@ export class SmsPagePage implements OnInit {
request.activationCode =this.activationCode;
//request.P_USER_NAME=this.userName,
//request.MobileNumber=this.member.MemberLoginList.P_MOBILE_NUMBER
console.log(data.LogInTokenID);
this.authService.checkSMS(
request,
() => {
@ -143,7 +145,28 @@ export class SmsPagePage implements OnInit {
public checkForgetPwdSMS()
{
const data = this.sharedData.getSharedData("logindata", false);
const request = new SMSCheckRequest();
request.LogInTokenID= data.LogInTokenID,
request.activationCode =this.activationCode;
//request.P_USER_NAME=this.userName,
//request.MobileNumber=this.member.MemberLoginList.P_MOBILE_NUMBER
console.log(data.LogInTokenID);
this.authService.checkForgetSMS(
request,
() => {
}, this.translate.trPK('general', 'ok')).subscribe((result: SMSCheckResponse) => {
console.log(result);
if (this.common.validResponse(result)) {
console.log(result);
//this.loginData.LogInTokenID = result.LogInTokenID;
//this.sharedData.setSharedData(this.loginData, "logindata");
this.common.openForgotPassword();
}
});
}
}

@ -26,6 +26,7 @@ import { Events } from '@ionic/angular';
import { InternationalMobileComponent } from '../../ui/mobile-number/international-mobile/international-mobile.component';
import { SMSCheckRequest } from './models/smscheck.request';
import { SMSCheckResponse } from './models/smscheck.response';
import { ForgetPassword } from 'src/app/authentication/models/forget.password';
@Injectable({
providedIn: 'root'
@ -58,6 +59,10 @@ export class AuthenticationService {
public static forgotFileIDURL = 'Services/Authentication.svc/REST/CheckActivationCodeForSendFileNo';
public static user: AuthenticatedUser;
/*user checking methods */
public static userChecking = 'Services/ERP.svc/REST/Get_BasicUserInformation';
public static changePasswordForget ='Services/ERP.svc/REST/ChangePassword_Forget';
public static LOGIN_EVENT = 'user-login-event';
public static FAMILY_LOGIN_EVENT = 'family-login-event';
public static AUTHENTICATED_USER_KEY = 'save-authenticated-user';
@ -156,11 +161,8 @@ export class AuthenticationService {
public login(request: LoginRequest, onError: any, errorLabel: string): Observable<Response> {
request.PatientID = 0;
request.TokenID = '';
request.isDentalAllowedBackend = false;
request.isRegister = false;
return this.con.post(AuthenticationService.loginURL, request, onError, errorLabel);
this.setPublicFields(request);
return this.con.post(AuthenticationService.login, request, onError, errorLabel);
}
@ -430,7 +432,7 @@ export class AuthenticationService {
public checkUserAuthentication(request: CheckUserAuthenticationRequest, onError: any, errorLabel: string)
: Observable<CheckUserAuthenticationResponse> {
this.setPublicFields(request);
return this.con.post(AuthenticationService.login, request, onError, errorLabel);
return this.con.post(AuthenticationService.userChecking, request, onError, errorLabel);
}
public checkActivationCode(request: CheckActivationCodeRequest, onError: any, errorLabel: string)
@ -445,6 +447,18 @@ export class AuthenticationService {
return this.con.post(AuthenticationService.smsCheck, request, onError, errorLabel);
}
public checkForgetSMS(request: SMSCheckRequest, onError: any, errorLabel: string)
: Observable<SMSCheckResponse> {
this.setPublicFields(request);
return this.con.post(AuthenticationService.smsCheckForget, request, onError, errorLabel);
}
public sendPublicSMS(request: SMSCheckRequest, onError: any, errorLabel: string)
: Observable<CheckUserAuthenticationResponse> {
this.setPublicFields(request);
return this.con.post(AuthenticationService.smsSendCode, request, onError, errorLabel);
}
/*
client side:
id no , mobile no , zip code
@ -476,6 +490,19 @@ export class AuthenticationService {
return this.con.post(AuthenticationService.activationCodeURL, request, onError, errorLabel);
}
public sendForgetPassword(request: ForgetPassword, onError: any, errorLabel: string)
: Observable<CheckUserAuthenticationResponse> {
this.setPublicFields(request);
return this.con.post(AuthenticationService.smsSendCode, request, onError, errorLabel);
}
public submitForgetPassword(request: ForgetPassword, onError: any, errorLabel: string)
: Observable<CheckUserAuthenticationResponse> {
this.setPublicFields(request);
return this.con.post(AuthenticationService.changePasswordForget, request, onError, errorLabel);
}
public sendSMSForForgotFileNumber(request: CheckUserAuthenticationRequest, onError: any, errorLabel: string)
: Observable<CheckUserAuthenticationResponse> {
this.setPublicFields(request);

@ -0,0 +1,7 @@
export class BasicInfo extends Request{
public P_EMAIL_ADDRESS:string;
public P_MOBILE_NUMBER: string;
public P_RETURN_MSG: string;
public P_RETURN_STATUS: string;
}

@ -1,4 +1,6 @@
import { Response } from '../../models/response';
import { BasicInfo } from './basic.info';
import { MemberList } from './member.list';
export class CheckUserAuthenticationResponse extends Response {
PatientHasFile: boolean;
@ -10,4 +12,12 @@ export class CheckUserAuthenticationResponse extends Response {
hasFile: boolean;
isSMSSent: boolean;
LogInTokenID: string;
P_EMAIL_ADDRESS : string;
P_MOBILE_NUMBER : string;
P_RETURN_MSG : string;
P_RETURN_STATUS : string;
public IsPasswordExpired: boolean;
//public P_SESSION_ID:string;
public MemberLoginList: MemberList ;
public BasicMemberInformation: BasicInfo;
}

@ -7,6 +7,11 @@ export class LoginRequest extends Request {
SearchType: number; // 1 for iqama 2 for file number
TokenID: string; // ""
ZipCode: string; // "966"
MobileNumber: string;
P_USER_NAME : string;
P_MOBILE_NUMBER : string;
P_PASSWORD : string;
P_LANGUAGE : string;
// isDentalAllowedBackend: false
isRegister: boolean; // false
}

@ -0,0 +1,9 @@
export class MemberList {
public P_EMAIL_ADDRESS:string;
public P_INVALID_LOGIN_MSG: string;
public P_MOBILE_NUMBER: string;
public P_PASSOWRD_EXPIRED: string;
public P_RETURN_MSG: string;
public P_RETURN_STATUS: string;
public P_SESSION_ID: number;
}

@ -891,6 +891,9 @@ export class CommonService {
public openHome() {
this.alternateNavigate(CommonService.HOME_URL, "home-open", true);
}
public openForgotPassword() {
this.nav.navigateForward(["/authentication/forgot"]);
}
public reload(url: string, from: string) {
console.log("force reload called from:" + from);
@ -930,9 +933,12 @@ export class CommonService {
}
}
public openLogin() {
this.nav.navigateRoot(["/authentication/login"]);
}
public openUserForgot() {
this.nav.navigateForward(["/authentication/forgot"]);
this.nav.navigateForward(["/authentication/checkuser"]);
}
public openSMSPage() {
this.nav.navigateForward(["/authentication/smspage"]);

@ -90,6 +90,20 @@
"ar":"تحقق مرة واحدة كلمة المرور"
}
},
"changePassword":{
"newPassword":{
"en":"New Password",
"ar":"كلمة المرور الجديدة"
},
"confirmPassword":{
"en":"Confirm Password",
"ar":"تأكيد كلمة المرور"
},
"passwordchanged":{
"en":"Your password changed successfully",
"ar":"تم تغيير كلمة المرور الخاصة بك بنجاح"
}
},
"verificationcode":
{
"verificationcode":{

Loading…
Cancel
Save