TimeTrex/interface/html5/dist/portal-sign_in-PortalResetForgotPasswordController.bundle.js

1 line
12 KiB
JavaScript
Raw Normal View History

2022-12-13 07:10:06 +01:00
"use strict";(self.webpackChunktimetrex=self.webpackChunktimetrex||[]).push([["portal-sign_in-PortalResetForgotPasswordController"],{5866:(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"PortalResetForgotPasswordController\": () => (/* binding */ PortalResetForgotPasswordController)\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 PortalResetForgotPasswordController 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 .portal-reset-forgot-password': 'resetForgotPassword'\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\tif ( options.callback ) {\n\t\t\tthis.callback = options.callback;\n\t\t}\n\t\t// var $this = this;\n\t\t// __non_webpack_require__( this._required_files, function() {\n\t\tthis.api = _services_TimeTrexClientAPI__WEBPACK_IMPORTED_MODULE_1__/* .TTAPI.APIRecruitmentAuthentication */ .y.APIRecruitmentAuthentication;\n\t\tvar el = Global.loadWidget( 'views/portal/sign_in/PortalResetForgotPassword.html' );\n\t\tthis.setElement( _.template( el )() );\n\t\tthis.render();\n\t\t// } );\n\t}\n\n\trender() {\n\t\tvar $this = this;\n\t\tthis.$( '#new_password' ).focus();\n\t\tthis.$( '#confirm_password' ).unbind( 'keydown' ).bind( 'keydown', function( e ) {\n\t\t\tif ( e.keyCode === 13 ) {\n\t\t\t\t$this.resetForgotPassword();\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.removeView();\n\t\t} );\n\t}\n\n\tremoveView() {\n\t\tthis.$el.remove();\n\t\tLocalCacheData.setAllURLArgs( _.omit( LocalCacheData.getAllURLArgs(), 'sm' ) );\n\t\tLocalCacheData.setAllURLArgs( _.omit( LocalCacheData.getAllURLArgs(), 'key' ) );\n\t\tIndexViewController.instance.router.navigate( '#!m=PortalJobVacancy&company_id=' + LocalCacheData.getAllURLArgs().company_id, {\n\t\t\ttrigger: false,\n\t\t\treplace: true\n\t\t} );\n\t}\n\n\tresetForgotPassword() {\n\t\tvar $this = this;\n\t\tif ( this.getPassword() ) {\n\t\t\tvar password = this.getPassword();\n\t\t\tthis.api.passwordReset( LocalCacheData.getAllURLArgs().key,\n\t\t\t\tpassword.new_password,\n\t\t\t\tpassword.confirm_password\n\t\t\t\t, {\n\t\t\t\t\tonResult: function( result ) {\n\t\t\t\t\t\tif ( !result.isValid() ) {\n\t\t\t\t\t\t\tvar details = result.getDetails();\n\t\t\t\t\t\t\tif ( !details ) {\n\t\t\t\t\t\t\t\tdetails = result.getDescription(); // If the details is empty, try to get description to show.\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tvar error_string = '';\n\t\t\t\t\t\t\tif ( Global.isArray( details ) || typeof details === 'object' ) {\n\t\t\t\t\t\t\t\t$.each( details, function( index, val ) {\n\t\t\t\t\t\t\t\t\tif ( val.hasOwnProperty( 'error' ) ) {\n\t\t\t\t\t\t\t\t\t\tval = val.error;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tvar i = 0;\n\t\t\t\t\t\t\t\t\tfor ( var key in val ) {\n\t\t\t\t\t\t\t\t\t\terror_string = error_string + val[key];\n\t\t\t\t\t\t\t\t\t\tif ( i > 0 ) {\n\t\t\t\t\t\t\t\t\t\t\terror_string += '<br>';\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\ti++;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\terror_string = details;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t$this.setError( $this.$( '#new_password' ), error_string );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t$this.$el.modal( 'hide' );\n\t\t\t\t\t\t\tif ( $this.callback ) {\n\t\t\t\t\t\t\t\t$this.callback();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t} );\