consumerportal
Version:
mydna Custimised for you
95 lines (78 loc) • 3.67 kB
text/typescript
/// <reference path="../../includes.ts" />
module acctMgmtForgotPasswordCtrl {
import IModalService = app.IModalService;
interface IAcctMgmtForgotPasswordController{
passwordRecovery(): any;
}
interface IAcctMgmtForgotPasswordScope extends angular.IScope{
myForm : angular.IFormController
}
class AcctMgmtForgotPasswordController implements IAcctMgmtForgotPasswordController{
static $inject = [
'$scope',
'$rootScope',
'apiSrvc',
'errorHandlerSrvc',
'mydnaApis',
'appMemorySrvc',
'locationSrvc',
'modalService'
];
tabIndexValue: any;
frm: any = {};
showErrors: any = false;
constructor(
private $scope: IAcctMgmtForgotPasswordScope,
private $rootScope: angular.IRootScopeService,
private apiSrvc: apiSrvc.IApiService,
private errorHandlerSrvc: errorHandlerSrvc.IErrorHandlerService,
private mydnaApis: ImyDNAApis,
private appMemorySrvc: appMemorySrvc.IAppMemoryService,
private locationSrvc: locationSrvc.ILocationService,
private modalService: IModalService
){
var vm = this;
$rootScope.$on("resetTabIndexValue", (event, message) => {
vm.tabIndexValue = "0";
});
$rootScope.$on("setTabIndexValue", (event, message) => {
vm.tabIndexValue = "-1";
});
}
passwordRecovery(){
this.showErrors = this.showErrors == true ? false : "";
if (this.$scope.myForm.$valid) {
this.$scope.$emit("disable-on-save-on");
this.apiSrvc.post_request(this.mydnaApis.ForgotPassword, this.frm).then((data: any) => {
this.modalService.add('modal-notification.warning', {
title: 'Forgot Password link sent to email',
content: 'An email will be sent to the email address you entered if it exists in our system. Remember to check your SPAM box in case it has been sent there.'
}).then((index: number) => {
this.locationSrvc.goto('acctmgmt/login', '');
});
/*
this.appMemorySrvc.setLoginPageMessage({
status: true,
sourceRoute: 'acctmgmt/forgotpassword',
description: 'Forgot Password link sent to email',
body: "An email will be sent to the email address you entered if it exists in our system. Remember to check your SPAM box in case it has been sent there."
});
this.locationSrvc.goto('acctmgmt/login', '');*/
}, err => {
if (err.status == 404) {
this.modalService.add('modal-notification.warning', {
title: 'Email Not Found',
content: 'This email address was not found in our system. Are you sure you typed it correctly?'
});
} else{
this.errorHandlerSrvc.errorHandler(err, 'debug', '');
}
});
}
else {
this.showErrors = true;
}
}
}
angular.module('app').controller('acctMgmtForgotPasswordCtrl', AcctMgmtForgotPasswordController);
}