1 line
8.2 KiB
JavaScript
1 line
8.2 KiB
JavaScript
|
"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 += '<br>';\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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiNzYuanMiLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7QUFBd0Q7QUFDSDs7QUFFOUMsNkNBQTZDLGlFQUFjO0FBQ2xFLDJCQUEyQjtBQUMzQixFQUFFLENBQUM7QUFDSDtBQUNBO0FBQ0E7QUFDQSxJQUFJOztBQUVKO0FBQ0E7O0FBRUE7QUFDQTtBQUNBLGFBQWEsaUlBQWtDO0FBQy9DO0FBQ0EsbUJBQW1CLENBQUM7QUFDcEI7QUFDQTtBQUNBOztBQUVBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0EsSUFBSTtBQUNKLEVBQUUsQ0FBQztBQUNIO0FBQ0E7QUFDQTtBQUNBLElBQUk7QUFDSjtBQUNBO0FBQ0EsSUFBSTtBQUNKOztBQUVBO0FBQ0E7QUFD
|