'use strict'; angular .module('customerLogin') .component('forgottenPassword', { templateUrl: 'tmpl/forgottenpwd/forgotten-password.html?session=aPPgCjaanafkaFRIHfikQbpdcplYgicj', controllerAs: 'forgetPwdCtrl', controller: ['$rootScope', '$routeParams', '$scope', '$location', '$kWindow', 'AuthService', 'AUTH_STATUS', ForgottenPwdController] }); function ForgottenPwdController($rootScope, $routeParams, $scope, $location, $kWindow, AuthService, AUTH_STATUS) { var self = this; self.cUserId = ''; angular.element(document).ready(function () { $("#cUserId").select(); }); self.changeView = function (view) { $location.path(view); }; self.cancelRequest = function () { $rootScope.$broadcast('CancelForgottenPwd'); } self.reloadLoginPage = function(){ $rootScope.$broadcast('ReloadLoginPage'); } self.viewName = "Forgotten Password"; self.companyLogo = "/WMS-Web-Live/img/company-logo.png"; self.sendRequest = function () { if (self.cUserId == "") { self.showErrorMsg("Error", "Please enter a valid Username", "cUserId", false); } else { if ($('#g-recaptcha-response').val() == '') { self.showErrorMsg("Error", "Please select reCAPTCHA tickbox", ""); } else { AuthService.forgottenPwd($.trim(self.cUserId), $('#g-recaptcha-response').val()).then(function () { if (AuthService.status == AUTH_STATUS.success) { self.cUserId = ''; self.showErrorMsg("Confirmation", AuthService.cErrorMsg, "", true); self.changeView('/login'); } else if (AuthService.status == AUTH_STATUS.error) { self.cUserId = ''; self.showErrorMsg("Error", AuthService.cErrorMsg, "", true); self.changeView('/login'); } }, function () { self.cUserId = ''; self.showErrorMsg("Login", "Password change Failed","", true); self.changeView('/login'); }); } } } self.showErrorMsg = function (pcTitle, pcErrorMsg, pcField,plReload) { var errorMsgWinHdl = $kWindow.open({ options: { modal: true, title: pcTitle, resizable: true, height: 'auto', width: 400, visible: false }, templateUrl: '../lib/htmls/errormsg.template.html', controllerAs: 'error', controller: ['$windowInstance', 'message', function ErrorMsgContoller($errorMsgWinHdl, pcErrorMsg) { this.message = pcErrorMsg; this.btnOK = function () { $errorMsgWinHdl.close(true); if (pcField != "") $("#" + pcField).select(); if (plReload == true) self.reloadLoginPage(); }; }], resolve: { message: function () { return pcErrorMsg; } } }); } } var resetFPCaptcha = function(){ grecaptcha.reset('notarobotFP'); }