"use strict";(self.webpackChunktimetrex=self.webpackChunktimetrex||[]).push([["portal-sign_in-PortalForgotPasswordController"],{76:(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"PortalForgotPasswordController\": () => (/* binding */ PortalForgotPasswordController)\n/* harmony export */ });\n/* harmony import */ var _views_TTBackboneView__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(6739);\n/* harmony import */ var _services_TimeTrexClientAPI__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7526);\n/* provided dependency */ var _ = __webpack_require__(9050);\n/* provided dependency */ var $ = __webpack_require__(9755);\n\n\n\nclass PortalForgotPasswordController extends _views_TTBackboneView__WEBPACK_IMPORTED_MODULE_0__.TTBackboneView {\n\tconstructor( options = {} ) {\n\t\t_.defaults( options, {\n\t\t\tevents: {\n\t\t\t\t'click .send-reset-email': 'sendResetEmail'\n\t\t\t}\n\t\t} );\n\n\t\tsuper( options );\n\t}\n\n\tinitialize( options ) {\n\t\tsuper.initialize( options );\n\t\tthis.api = _services_TimeTrexClientAPI__WEBPACK_IMPORTED_MODULE_1__/* .TTAPI.APIRecruitmentAuthentication */ .y.APIRecruitmentAuthentication;\n\t\tvar el = Global.loadWidget( 'views/portal/sign_in/PortalForgotPassword.html' );\n\t\tthis.setElement( _.template( el )() );\n\t\tthis.emailInput = this.$( '#email' );\n\t\tthis.render();\n\t}\n\n\trender() {\n\t\tvar $this = this;\n\t\tthis.emailInput.focus();\n\t\tthis.emailInput.unbind( 'keydown' ).bind( 'keydown', function( e ) {\n\t\t\tif ( e.keyCode === 13 ) {\n\t\t\t\t$this.sendResetEmail();\n\t\t\t}\n\t\t} );\n\t\t$( 'body' ).append( this.$el );\n\t\tthis.$el.modal( {\n\t\t\t'show': true,\n\t\t\t'backdrop': 'static'\n\t\t} );\n\t\tthis.$el.on( 'hidden.bs.modal', function() {\n\t\t\t$this.$el.remove();\n\t\t} );\n\t}\n\n\tsendResetEmail() {\n\t\tvar $this = this;\n\t\tvar email = this.emailInput.val();\n\t\tthis.api.resetPassword( email, {\n\t\t\tonResult: function( result ) {\n\t\t\t\tif ( !result.isValid() ) {\n\t\t\t\t\t$this.showErrorAlert( result );\n\t\t\t\t} else {\n\t\t\t\t\tvar response = result.getResult();\n\t\t\t\t\tif ( response.hasOwnProperty( 'email_sent' ) ) { // make sure email if is sent successfully\n\t\t\t\t\t\t$this.$el.modal( 'hide' );\n\t\t\t\t\t\tIndexViewController.instance.router.showTipModal( $.i18n._( 'An email has been sent to you with instructions on how to change your password.' ) );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} );\n\t}\n\n\tshowErrorAlert( result ) {\n\t\tvar details = result.getDetails();\n\t\t// if ( details.hasOwnProperty( 'error' ) ) {\n\t\t//\n\t\t// }\n\t\tif ( !details ) {\n\t\t\tdetails = result.getDescription(); // If the details is empty, try to get description to show.\n\t\t}\n\t\tvar error_string = '';\n\n\t\tif ( Global.isArray( details ) || typeof details === 'object' ) {\n\n\t\t\t$.each( details, function( index, val ) {\n\n\t\t\t\tif ( val.hasOwnProperty( 'error' ) ) {\n\t\t\t\t\tval = val.error;\n\t\t\t\t}\n\t\t\t\tvar i = 0;\n\t\t\t\tfor ( var key in val ) {\n\t\t\t\t\terror_string = error_string + val[key];\n\t\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\t\terror_string += '
';\n\t\t\t\t\t}\n\t\t\t\t\ti++;\n\t\t\t\t}\n\t\t\t} );\n\t\t} else {\n\t\t\terror_string = details;\n\t\t}\n\t\tthis.emailInput.css( 'border', '1px solid red' );\n\t\tthis.emailInput.tooltip( {\n\t\t\ttitle: error_string\n\t\t} );\n\t\tthis.emailInput.tooltip( 'show' );\n\t}\n\n}//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNzYuanMiLCJtYXBw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