{"version":3,"sources":["webpack:///D:/a/1/s/frontend/src/views/widgets/verifyAccountModal/js/verifyAccountModal.js","webpack:///D:/a/1/s/frontend/src/views/widgets/loginModal/js/authenticationUtils.js","webpack:///D:/a/1/s/frontend/src/views/widgets/forgotPasswordModal/js/forgotPasswordModal.js","webpack:///D:/a/1/s/frontend/src/views/widgets/loginModal/js/loginModal.js","webpack:///D:/a/1/s/frontend/src/views/widgets/loginButton/js/loginButton.js","webpack:///./cognito.js","webpack:///./loading-spinner.js"],"names":["__webpack_require__","VerifyAccountModal","options","_classCallCheck3","default","this","_","merge","template","$","html","userPool","Cognito","getUserPool","UserPoolId","window","cognitoUserPoolId","ClientId","cognitoAppClientId","cognitoUser","$modal","$serverError","$btnVerify","email","open","addEventHandler","setupVerifyAccountProcess","_this","length","removeClass","append","setTimeout","find","addClass","val","_this2","off","on","e","preventDefault","close","code","getCognitoUser","prop","verifyEmail","then","result","onVerified","err","message","sendVerifyCode","_this3","getUserAttributes","userAttrs","emailAttr","Name","getValue","_this4","_promise2","resolve","reject","getSession","session","getAttributeVerificationCode","onSuccess","onFailure","_this5","verifyAttribute","AuthenticationUtils","authData","authenticationDetails","cognitoAuthenticateUser","emailVerified","JSON","parse","onAuthenticatedSuccess","onAskedToVerify","onError","authenticateUser","token","axios","post","_utils","_verifyAccountModal","ForgotPasswordModal","verifyModal","userData","$frmStep1","$frmStep2","$sendCode","$btnReset","$email","$emailError","siblings","$emailFormGrp","closest","utils","isEmail","createUserData","forgotPassword","data","forgotPasswordErrorHandler","$code","$password","$tips","verificationCode","newPassword","confirmPassword","finally","init","password","response","_this6","_forgotPasswordModal","_authenticationUtils","LoginModal","$btnLogin","forgotModal","authenticatedHandler","authUtils","validateData","validateForm","isValid","login","formData","username","$username","$userError","$userFormGrp","$passwordError","$passwordFormGrp","trim","invalidUserName","invalidPassword","createAuthData","errorHandler","LoadingSpinner","show","signin","ErrorCode","ErrorMessage","location","reload","Message","hide","errorMsg","cssClass","getIdToken","getJwtToken","signinHandler","getToken","_loginModal","LoginButton","el","$el","loginModal","$loginModal","logout","signOut","signout","_amazonCognitoIdentityJs","poolData","CognitoUserPool","Username","Pool","CognitoUser","getCurrentUser","AuthenticationDetails","Password","onFinally","refreshToken","getRefreshToken","config","credentials","needsRefresh","refreshSession","jwtToken","params","Logins","refresh","attributeList","firstname","Value","lastname","attrFirstName","CognitoUserAttribute","attrLastName","push","apply","signUp","$loader","document","querySelector","classList","add","body","insertAdjacentElement","remove"],"mappings":"oQAAAA,EAAA,UACAA,EAAA,iEAEaC,8BACZ,SAAAA,EAAYC,IAAS,EAAAC,EAAAC,SAAAC,KAAAJ,GACpBI,KAAKH,QAAUI,UAAEC,SAAUL,GAE3BG,KAAKG,SAAWC,EAAE,uBAAuBC,OAEzCL,KAAKM,SAAWC,UAAQC,aACvBC,WAAYC,OAAOC,kBACnBC,SAAUF,OAAOG,qBAGlBb,KAAKc,YAAc,KACnBd,KAAKe,OAAS,KACdf,KAAKgB,aAAe,KACpBhB,KAAKiB,WAAa,KAClBjB,KAAKkB,MAAQ,uDAIblB,KAAKmB,OACLnB,KAAKoB,kBACLpB,KAAKqB,2DAGC,IAAAC,EAAAtB,KACNA,KAAKe,OAASX,EAAE,sCACZJ,KAAKe,OAAOQ,OACfvB,KAAKe,OAAOS,YAAY,WAExBpB,EAAE,QAAQqB,OAAOzB,KAAKG,UACtBH,KAAKe,OAASX,EAAE,sCAChBsB,WAAW,WACVJ,EAAKP,OAAOS,YAAY,WACtB,MAEJxB,KAAKgB,aAAehB,KAAKe,OAAOY,KAAK,iBACrC3B,KAAKiB,WAAajB,KAAKe,OAAOY,KAAK,8CAI/B3B,KAAKe,QAAUf,KAAKe,OAAOQ,SAC9BvB,KAAKe,OAAOa,SAAS,UAGrB5B,KAAKe,OAAOY,KAAK,eAAeH,YAAY,SAC5CxB,KAAKe,OAAOY,KAAK,SAASE,IAAI,IAC9B7B,KAAKe,OAAOY,KAAK,UAAUtB,KAAK,IAChCL,KAAKgB,aAAaX,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odash';\nimport Cognito from '../../../../global/js/cognito';\n\nexport class VerifyAccountModal {\n\tconstructor(options) {\n\t\tthis.options = _.merge({}, options);\n\t\t// Load template\n\t\tthis.template = $('#VerifyAccountModal').html();\n\t\t// Initialize User Pool\n\t\tthis.userPool = Cognito.getUserPool({\n\t\t\tUserPoolId: window.cognitoUserPoolId,\n\t\t\tClientId: window.cognitoAppClientId,\n\t\t});\n\n\t\tthis.cognitoUser = null;\n\t\tthis.$modal = null;\n\t\tthis.$serverError = null;\n\t\tthis.$btnVerify = null;\n\t\tthis.email = '';\n\t}\n\n\tinit() {\n\t\tthis.open();\n\t\tthis.addEventHandler();\n\t\tthis.setupVerifyAccountProcess();\n\t}\n\n\topen() {\n\t\tthis.$modal = $('[data-role=\"verify-account-modal\"]');\n\t\tif (this.$modal.length) {\n\t\t\tthis.$modal.removeClass('hidden');\n\t\t} else {\n\t\t\t$('body').append(this.template);\n\t\t\tthis.$modal = $('[data-role=\"verify-account-modal\"]');\n\t\t\tsetTimeout(()=> {\n\t\t\t\tthis.$modal.removeClass('hidden');\n\t\t\t}, 300);\n\t\t}\n\t\tthis.$serverError = this.$modal.find('.server-error');\n\t\tthis.$btnVerify = this.$modal.find('.btn-login');\n\t}\n\n\tclose() {\n\t\tif (this.$modal && this.$modal.length) {\n\t\t\tthis.$modal.addClass('hidden');\n\n\t\t\t// Reset style\n\t\t\tthis.$modal.find('.form-group').removeClass('error');\n\t\t\tthis.$modal.find('input').val('');\n\t\t\tthis.$modal.find('.error').html('');\n\t\t\tthis.$serverError.html('');\n\t\t}\n\t}\n\n\taddEventHandler() {\n\t\tif (!this.$modal || !this.$modal.length) return;\n\n\t\tthis.$modal\n\t\t\t.off('click.close')\n\t\t\t.on('click.close', '.popup-close', (e)=> {\n\t\t\t\te.preventDefault();\n\t\t\t\tthis.close();\n\t\t\t});\n\n\t\tthis.$modal\n\t\t\t.off('click.send')\n\t\t\t.on('click.send', '.btn-verify', (e)=> {\n\t\t\t\te.preventDefault();\n\t\t\t\tconst code = this.$modal.find('#code').val();\n\t\t\t\tif (!this.cognitoUser) this.cognitoUser = Cognito.getCognitoUser(null, this.userPool);\n\t\t\t\tthis.$btnVerify.prop('disabled', true);\n\t\t\t\tthis.verifyEmail(code)\n\t\t\t\t\t.then((result)=>{\n\t\t\t\t\t\tthis.$btnVerify.prop('disabled', false);\n\t\t\t\t\t\tthis.close();\n\t\t\t\t\t\tif (typeof this.options.onVerified === 'function') this.options.onVerified(result);\n\t\t\t\t\t}, (err)=> {\n\t\t\t\t\t\tthis.$serverError.html(`${err.message}`);\n\t\t\t\t\t});\n\t\t\t});\n\n\t\tthis.$modal\n\t\t\t.off('click.sendagain')\n\t\t\t.on('click.sendagain', '.btn-send-again', (e)=> {\n\t\t\t\te.preventDefault();\n\t\t\t\tthis.sendVerifyCode();\n\t\t\t});\n\t}\n\n\t/**\n\t * Set up verification process for the modal.\n\t */\n\tsetupVerifyAccountProcess() {\n\t\tthis.$btnVerify.prop('disabled', true);\n\t\tCognito.getUserAttributes(this.userPool)\n\t\t\t.then((userAttrs)=> {\n\t\t\t\tthis.sendVerifyCode()\n\t\t\t\t\t.then((result)=> {\n\t\t\t\t\t\tconst emailAttr = _.find(userAttrs, {Name: 'email'});\n\t\t\t\t\t\tthis.email = emailAttr.getValue();\n\t\t\t\t\t\tthis.$modal.find('.user-email').html(this.email);\n\n\t\t\t\t\t\tthis.$modal.find('.success-request').removeClass('d-none');\n\t\t\t\t\t\tthis.$serverError.html('');\n\t\t\t\t\t\tthis.$btnVerify.prop('disabled', false);\n\t\t\t\t\t}, (err)=> {\n\t\t\t\t\t\tthis.$modal.find('.success-request').addClass('d-none');\n\t\t\t\t\t\tthis.$serverError.html(`${err.message}`);\n\t\t\t\t\t});\n\t\t\t}, (err)=> {\n\t\t\t\tthis.$modal.find('.success-request').addClass('d-none');\n\t\t\t\tthis.$serverError.html(`${err.message}`);\n\t\t\t});\n\t}\n\n\t/**\n\t * Send a verification code email.\n\t */\n\tsendVerifyCode() {\n\t\treturn new Promise((resolve, reject)=> {\n\t\t\tthis.cognitoUser = Cognito.getCognitoUser(null, this.userPool);\n\t\t\tif (this.cognitoUser) {\n\t\t\t\tthis.cognitoUser.getSession((err, session)=>{\n\t\t\t\t\tthis.cognitoUser.getAttributeVerificationCode('email', {\n\t\t\t\t\t\tonSuccess: (result)=>{\n\t\t\t\t\t\t\tresolve(result);\n\t\t\t\t\t\t},\n\t\t\t\t\t\tonFailure: (err)=>{\n\t\t\t\t\t\t\treject(err);\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Send verification code to server.\n\t */\n\tverifyEmail(code) {\n\t\treturn new Promise((resolve, reject)=> {\n\t\t\tif (!this.cognitoUser) reject({message: 'Cannot get user.'});\n\t\t\tthis.cognitoUser.verifyAttribute('email', code, {\n\t\t\t\tonSuccess: (result)=>{\n\t\t\t\t\tresolve(result);\n\t\t\t\t},\n\t\t\t\tonFailure: (err)=>{\n\t\t\t\t\treject(err);\n\t\t\t\t},\n\t\t\t});\n\t\t});\n\t}\n}\n","import _ from 'lodash';\nimport axios from 'axios';\nimport Cognito from '../../../../global/js/cognito';\n\nexport class AuthenticationUtils {\n\tconstructor() {}\n\n\t/**\n\t * Login Flow\n\t * @param {authenticationDetails} authData\n\t * @param {{cognitoUser, userPool, onAuthenticatedSuccess, onAskedToVerify, onError}} options\n\t * @returns\n\t */\n\tlogin(authData, options) {\n\t\toptions = _.merge({}, options);\n\t\tconst userPool = options.userPool;\n\t\tconst cognitoUser = options.cognitoUser;\n\t\tconst authenticationDetails = authData;\n\n\t\treturn this\n\t\t\t\t.cognitoAuthenticateUser({authenticationDetails, cognitoUser})\n\t\t\t\t.then((result)=> {\n\t\t\t\t\tCognito.getUserAttributes(userPool)\n\t\t\t\t\t\t.then((userAttrs)=> {\n\t\t\t\t\t\t\t// Check if email_verified property is existed.\n\t\t\t\t\t\t\tconst emailVerified = _.find(userAttrs, {Name: 'email_verified'});\n\t\t\t\t\t\t\tif (!emailVerified) return;\n\t\t\t\t\t\t\tconst isEmailVerified = JSON.parse(emailVerified.getValue());\n\t\t\t\t\t\t\tif (isEmailVerified) {\n\t\t\t\t\t\t\t\t// Account has already verified flow\n\t\t\t\t\t\t\t\tif (typeof options.onAuthenticatedSuccess === 'function') options.onAuthenticatedSuccess(result);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// Request to verify account\n\t\t\t\t\t\t\t\tif (typeof options.onAskedToVerify === 'function') options.onAskedToVerify();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t}, (err)=> {\n\t\t\t\t\tif (typeof options.onError === 'function') options.onError(err);\n\t\t\t\t});\n\t}\n\n\t/**\n\t * Authenticate a user to Cognito\n\t * @param {{authenticationDetails, cognitoUser}} options\n\t * @returns an axios promise\n\t */\n\tcognitoAuthenticateUser(options) {\n\t\toptions = _.merge({}, options);\n\t\treturn new Promise((resolve, reject)=> {\n\t\t\toptions.cognitoUser.authenticateUser(options.authenticationDetails, {\n\t\t\t\tonSuccess: function(result) {\n\t\t\t\t\tresolve(result);\n\t\t\t\t},\n\t\t\t\tonFailure: function(err) {\n\t\t\t\t\treject(err);\n\t\t\t\t},\n\t\t\t});\n\t\t});\n\t}\n\n\t/**\n\t *\n\t * @param {string} token Token from AWS Cognito\n\t * @returns a axios promise\n\t */\n\tsignin(token) {\n\t\treturn axios.post('/api/customer/signin', {token: token});\n\t}\n}\n","import _ from 'lodash';\nimport Cognito from '../../../../global/js/cognito';\nimport {utils} from '../../../../global/js/utils';\nimport {VerifyAccountModal} from '../../verifyAccountModal/js/verifyAccountModal';\nexport class ForgotPasswordModal {\n\tconstructor() {\n\t\t// Load template\n\t\tthis.template = $('#ForgotPasswordModal').html();\n\t\tthis.email = '';\n\t\t// Initialize User Pool\n\t\tthis.userPool = Cognito.getUserPool({\n\t\t\tUserPoolId: window.cognitoUserPoolId,\n\t\t\tClientId: window.cognitoAppClientId,\n\t\t});\n\n\t\tthis.verifyModal = new VerifyAccountModal({\n\t\t\tonVerified: ()=> {\n\t\t\t\tthis.onVerified();\n\t\t\t},\n\t\t});\n\n\t\tthis.userData = null;\n\t\tthis.cognitoUser = null;\n\t\tthis.$modal = null;\n\t\tthis.$serverError = null;\n\t\tthis.$frmStep1 = null;\n\t\tthis.$frmStep2 = null;\n\t\tthis.$sendCode = null;\n\t}\n\n\tinit() {\n\t\tthis.open();\n\t\tthis.addEventHandler();\n\t}\n\n\topen() {\n\t\tthis.$modal = $('[data-role=\"forgot-password-modal\"]');\n\t\tif (this.$modal.length) {\n\t\t\tthis.$modal.removeClass('hidden');\n\t\t} else {\n\t\t\t$('body').append(this.template);\n\t\t\tthis.$modal = $('[data-role=\"forgot-password-modal\"]');\n\t\t\tsetTimeout(()=> {\n\t\t\t\tthis.$modal.removeClass('hidden');\n\t\t\t}, 300);\n\t\t}\n\t\tthis.$serverError = this.$modal.find('.server-error');\n\t\tthis.$frmStep1 = this.$modal.find('.step-1');\n\t\tthis.$frmStep2 = this.$modal.find('.step-2');\n\t\tthis.$sendCode = this.$modal.find('.btn-send-code');\n\t}\n\n\tclose() {\n\t\tif (this.$modal && this.$modal.length) {\n\t\t\tthis.$modal.addClass('hidden');\n\n\t\t\t// Reset style\n\t\t\tthis.$modal.find('.form-group').removeClass('error');\n\t\t\tthis.$modal.find('.step-1').removeClass('d-none');\n\t\t\tthis.$modal.find('.step-2').addClass('d-none');\n\t\t\tthis.$modal.find('input').val('');\n\t\t\tthis.$modal.find('.error').html('');\n\t\t\tthis.$serverError.html('');\n\t\t\t// Reset data\n\t\t\tthis.userData = null;\n\t\t\tthis.cognitoUser = null;\n\t\t}\n\t}\n\n\n\taddEventHandler() {\n\t\tif (!this.$modal || !this.$modal.length) return;\n\n\t\tconst $btnReset = this.$modal.find('.btn-reset');\n\n\t\tthis.$modal\n\t\t\t.off('click.close')\n\t\t\t.on('click.close', '.popup-close', (e)=> {\n\t\t\t\te.preventDefault();\n\t\t\t\tthis.close();\n\t\t\t});\n\n\t\tthis.$modal\n\t\t\t.off('click.send')\n\t\t\t.on('click.send', '.btn-send-code', (e)=> {\n\t\t\t\te.preventDefault();\n\t\t\t\tconst $email = this.$modal.find('#email');\n\t\t\t\tconst $emailError = $email.siblings('.error');\n\t\t\t\tconst $emailFormGrp = $email.closest('.form-group');\n\t\t\t\tconst email = $email.val();\n\t\t\t\tif (utils.isEmail(email)) {\n\t\t\t\t\t// Remove error\n\t\t\t\t\t$emailError.html('');\n\t\t\t\t\t$emailFormGrp.removeClass('error');\n\n\t\t\t\t\t// Request send a verify code\n\t\t\t\t\tthis.userData = Cognito.createUserData(email, this.userPool);\n\t\t\t\t\tthis.cognitoUser = Cognito.getCognitoUser(this.userData);\n\n\t\t\t\t\tthis.forgotPassword()\n\t\t\t\t\t\t.then(\n\t\t\t\t\t\t\t(data)=> {\n\t\t\t\t\t\t\t\tthis.$serverError.html('');\n\t\t\t\t\t\t\t\t// Move to next step\n\t\t\t\t\t\t\t\tthis.$frmStep1.addClass('d-none');\n\t\t\t\t\t\t\t\tthis.$frmStep2.removeClass('d-none');\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t(err)=> {\n\t\t\t\t\t\t\t\tthis.forgotPasswordErrorHandler(err);\n\t\t\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\t$emailError.html('Email is invalid.');\n\t\t\t\t\t$emailFormGrp.addClass('error');\n\t\t\t\t}\n\t\t\t});\n\n\t\tthis.$modal\n\t\t\t.off('click.sendagain')\n\t\t\t.on('click.sendagain', '.btn-send-again', (e)=> {\n\t\t\t\te.preventDefault();\n\t\t\t\tthis.forgotPassword()\n\t\t\t\t\t.then(\n\t\t\t\t\t\t(data)=> {\n\t\t\t\t\t\t\tthis.$serverError.html('');\n\t\t\t\t\t\t},\n\t\t\t\t\t\t(err)=> {\n\t\t\t\t\t\t\tthis.forgotPasswordErrorHandler(err);\n\t\t\t\t\t\t});\n\t\t\t});\n\n\t\tthis.$modal\n\t\t\t.off('click.reset')\n\t\t\t.on('click.reset', '.btn-reset', (e)=> {\n\t\t\t\te.preventDefault();\n\t\t\t\tif (this.cognitoUser) {\n\t\t\t\t\tconst $code = this.$modal.find('#code');\n\t\t\t\t\tconst $password = this.$modal.find('#password');\n\t\t\t\t\tconst $tips = this.$modal.find('.form-tip');\n\n\t\t\t\t\tconst verificationCode = $code.val();\n\t\t\t\t\tconst newPassword = $password.val();\n\t\t\t\t\t$btnReset.prop('disabled', true);\n\t\t\t\t\tthis.confirmPassword(verificationCode, newPassword)\n\t\t\t\t\t\t.then(()=> {\n\t\t\t\t\t\t\t$tips.addClass('success');\n\t\t\t\t\t\t\tthis.close();\n\t\t\t\t\t\t}, (err)=> {\n\t\t\t\t\t\t\tthis.$serverError.html(`${err.message}`);\n\t\t\t\t\t\t\t$tips.addClass('error');\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.finally(()=> {\n\t\t\t\t\t\t\t$btnReset.prop('disabled', false);\n\t\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t});\n\t}\n\n\tforgotPassword() {\n\t\treturn new Promise((resolve, reject)=> {\n\t\t\tif (!this.cognitoUser) reject({message: 'Cannot get user.'});\n\t\t\tthis.cognitoUser.forgotPassword({\n\t\t\t\tonSuccess: function(data) {\n\t\t\t\t\tresolve(data);\n\t\t\t\t},\n\t\t\t\tonFailure: function(err) {\n\t\t\t\t\treject(err);\n\t\t\t\t},\n\t\t\t});\n\t\t});\n\t}\n\n\tforgotPasswordErrorHandler(err) {\n\t\tthis.$serverError.html(`${err.message}`);\n\t\tif ('InvalidParameterException' === err.code) {\n\t\t\tthis.verifyModal.init();\n\t\t} else {\n\t\t\tthis.$sendCode.prop('disabled', true);\n\t\t}\n\t}\n\n\tconfirmPassword(code, password) {\n\t\treturn new Promise((resolve, reject)=> {\n\t\t\tif (!this.cognitoUser) reject({message: 'Cannot get user.'});\n\t\t\tthis.cognitoUser.confirmPassword(code, password, {\n\t\t\t\tonSuccess(response) {\n\t\t\t\t\tresolve(response);\n\t\t\t\t},\n\t\t\t\tonFailure(err) {\n\t\t\t\t\treject(err);\n\t\t\t\t},\n\t\t\t});\n\t\t});\n\t}\n\n\tonVerified() {\n\t\tthis.$serverError.html('');\n\t\tthis.$sendCode.prop('disabled', true);\n\t\tthis.forgotPassword()\n\t\t\t.then(\n\t\t\t\t(data)=> {\n\t\t\t\t\t// Move to next step\n\t\t\t\t\tthis.$frmStep1.addClass('d-none');\n\t\t\t\t\tthis.$frmStep2.removeClass('d-none');\n\t\t\t\t\tthis.$sendCode.prop('disabled', false);\n\t\t\t\t},\n\t\t\t\t(err)=> {\n\t\t\t\t\tthis.forgotPasswordErrorHandler(err);\n\t\t\t\t});\n\t}\n}\n","import _ from 'lodash';\nimport Cognito from '../../../../global/js/cognito';\nimport {utils} from '../../../../global/js/utils';\nimport LoadingSpinner from '../../../../global/js/loading-spinner';\nimport {ForgotPasswordModal} from '../../forgotPasswordModal/js/forgotPasswordModal';\nimport {VerifyAccountModal} from '../../verifyAccountModal/js/verifyAccountModal';\nimport {AuthenticationUtils} from './authenticationUtils';\n\nexport class LoginModal {\n\tconstructor() {\n\t\t// Load template\n\t\tthis.template = $('#SignInModal').html();\n\t\t// Initialize User Pool\n\t\tthis.userPool = Cognito.getUserPool({\n\t\t\tUserPoolId: window.cognitoUserPoolId,\n\t\t\tClientId: window.cognitoAppClientId,\n\t\t});\n\n\t\tthis.cognitoUser = null;\n\t\tthis.$modal = null;\n\t\tthis.$serverError = null;\n\t\tthis.$btnLogin = null;\n\n\t\tthis.forgotModal = new ForgotPasswordModal();\n\t\tthis.verifyModal = new VerifyAccountModal({\n\t\t\tonVerified: ()=> {\n\t\t\t\t// Auto-login if verifying account successfully\n\t\t\t\tthis.authenticatedHandler();\n\t\t\t},\n\t\t});\n\t\tthis.authUtils = new AuthenticationUtils();\n\t}\n\n\tinit() {\n\t\tthis.open();\n\t\tthis.addEventHandler();\n\t}\n\n\topen() {\n\t\tthis.$modal = $('[data-role=\"login-modal\"]');\n\t\tif (this.$modal.length) {\n\t\t\tthis.$modal.removeClass('hidden');\n\t\t} else {\n\t\t\t$('body').append(this.template);\n\t\t\tthis.$modal = $('[data-role=\"login-modal\"]');\n\t\t\tsetTimeout(()=> {\n\t\t\t\tthis.$modal.removeClass('hidden');\n\t\t\t}, 300);\n\t\t}\n\t\tthis.$serverError = this.$modal.find('.server-error');\n\t\tthis.$btnLogin = this.$modal.find('.btn-login');\n\t}\n\n\tclose() {\n\t\tif (this.$modal && this.$modal.length) {\n\t\t\tthis.$modal.addClass('hidden');\n\n\t\t\t// Reset style\n\t\t\tthis.$modal.find('.form-group').removeClass('error');\n\t\t\tthis.$modal.find('input').val('');\n\t\t\tthis.$modal.find('.error').html('');\n\t\t\tthis.$serverError.html('');\n\t\t}\n\t}\n\n\taddEventHandler() {\n\t\tif (!this.$modal || !this.$modal.length) return;\n\t\tthis.$modal\n\t\t\t.off('click.close')\n\t\t\t.on('click.close', '.popup-close', (e)=> {\n\t\t\t\te.preventDefault();\n\t\t\t\tthis.close();\n\t\t\t});\n\n\t\tthis.$modal\n\t\t\t.off('click.reset')\n\t\t\t.on('click.reset', '.btn-reset', (e)=> {\n\t\t\t\te.preventDefault();\n\t\t\t\tthis.forgotModal.init();\n\t\t\t});\n\n\t\tthis.$modal\n\t\t\t.off('click.login')\n\t\t\t.on('click.login', '.btn-login', (e)=> {\n\t\t\t\tconst validateData = this.validateForm();\n\t\t\t\tif (validateData.isValid) {\n\t\t\t\t\tthis.login(validateData.formData.username, validateData.formData.password);\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t});\n\t}\n\n\tvalidateForm() {\n\t\tconst $username = this.$modal.find('#username');\n\t\tconst $password = this.$modal.find('#password');\n\t\tconst $userError = $username.siblings('.error');\n\t\tconst $userFormGrp = $userError.closest('.form-group');\n\t\tconst $passwordError = $password.siblings('.error');\n\t\tconst $passwordFormGrp = $password.closest('.form-group');\n\t\tconst username = $username.val().trim();\n\t\tconst password = $password.val().trim();\n\t\tlet invalidUserName = false;\n\t\tlet invalidPassword = false;\n\t\tif (!username) {\n\t\t\t$userError.html('Email is required.');\n\t\t\t$userFormGrp.addClass('error');\n\t\t\tinvalidUserName = true;\n\t\t} else if (!utils.isEmail(username)) {\n\t\t\t$userError.html('Email is invalid.');\n\t\t\t$userFormGrp.addClass('error');\n\t\t\tinvalidUserName = true;\n\t\t} else {\n\t\t\t$userError.html('');\n\t\t\t$userFormGrp.removeClass('error');\n\t\t\tinvalidUserName = false;\n\t\t}\n\n\t\tif (!password) {\n\t\t\t$passwordError.html('Password is required.');\n\t\t\t$passwordFormGrp.addClass('error');\n\t\t\tinvalidPassword = true;\n\t\t} else {\n\t\t\t$passwordError.html('');\n\t\t\t$passwordFormGrp.removeClass('error');\n\t\t\tinvalidPassword = false;\n\t\t}\n\t\treturn {\n\t\t\tisValid: !invalidUserName && !invalidPassword,\n\t\t\tformData: {\n\t\t\t\tusername: username,\n\t\t\t\tpassword: password,\n\t\t\t},\n\t\t};\n\t}\n\n\tlogin(username, password) {\n\t\tconst authenticationDetails = Cognito.createAuthData(username, password);\n\t\tconst userData = Cognito.createUserData(username, this.userPool);\n\t\tconst cognitoUser = Cognito.getCognitoUser(userData);\n\t\tthis.cognitoUser = cognitoUser;\n\n\t\tthis.$btnLogin.prop('disabled', true);\n\t\treturn this.authUtils.login(\n\t\t\tauthenticationDetails,\n\t\t\t{\n\t\t\t\tcognitoUser: this.cognitoUser,\n\t\t\t\tuserPool: this.userPool,\n\t\t\t\tonAuthenticatedSuccess: (result)=> {\n\t\t\t\t\tthis.authenticatedHandler(result);\n\t\t\t\t},\n\t\t\t\tonAskedToVerify: () => {\n\t\t\t\t\tthis.verifyModal.init();\n\t\t\t\t\tthis.$btnLogin.prop('disabled', false);\n\t\t\t\t\tthis.close();\n\t\t\t\t},\n\t\t\t\tonError: (err)=> {\n\t\t\t\t\tthis.errorHandler(err.message);\n\t\t\t\t},\n\t\t\t});\n\t}\n\n\tsigninHandler(token) {\n\t\tLoadingSpinner.show();\n\t\tthis.authUtils.signin(token)\n\t\t\t.then((response)=> {\n\t\t\t\tif (response && response.data && response.data.ErrorCode) {\n\t\t\t\t\tthis.errorHandler(response.data.ErrorMessage, 'overflow-scroll');\n\t\t\t\t} else {\n\t\t\t\t\twindow.location.reload();\n\t\t\t\t}\n\t\t\t}, (err)=> {\n\t\t\t\tthis.errorHandler(err.response.data.Message || err.response.data);\n\t\t\t}).finally(()=> {\n\t\t\t\tLoadingSpinner.hide();\n\t\t\t});\n\t}\n\n\terrorHandler(errorMsg, cssClass) {\n\t\tthis.$serverError.html(`${errorMsg}`);\n\t\tthis.$btnLogin.prop('disabled', false);\n\t}\n\n\tauthenticatedHandler(result) {\n\t\tif (result) {\n\t\t\tconst token = result.getIdToken().getJwtToken();\n\t\t\tthis.signinHandler(token);\n\t\t} else {\n\t\t\tCognito.getToken(this.userPool)\n\t\t\t\t.then((token)=> {\n\t\t\t\t\tthis.signinHandler(token);\n\t\t\t\t}, (err)=> {\n\t\t\t\t\tthis.errorHandler(err.message);\n\t\t\t\t});\n\t\t}\n\t}\n}\n","\n// CONSTANTS are all caps.\nconst NS = 'LoginButton';\nconst CLS = 'loginButton';\nconst WG = '.' + CLS + '-';\n\nimport axios from 'axios';\nimport Cognito from '../../../../global/js/cognito';\nimport {LoginModal} from '../../loginModal/js/loginModal';\n\nexport class LoginButton {\n\tconstructor(el) {\n\t\tthis.$el = $(el);\n\t\tthis.loginModal = new LoginModal();\n\t}\n\n\tinit() {\n\t\tthis.$el.on('click', '.btn-login', (e)=> {\n\t\t\te.preventDefault();\n\t\t\tconst $loginModal = $('[data-role=\"login-modal\"]');\n\t\t\tif ($loginModal.length) {\n\t\t\t\t$loginModal.removeClass('hidden');\n\t\t\t} else {\n\t\t\t\tthis.loginModal.init();\n\t\t\t}\n\t\t});\n\n\t\tthis.$el.on('click', '.btn-logout', (e)=> {\n\t\t\te.preventDefault();\n\t\t\tthis.logout();\n\t\t});\n\t}\n\n\tlogout() {\n\t\tconst userPool = Cognito.getUserPool({\n\t\t\tUserPoolId: window.cognitoUserPoolId,\n\t\t\tClientId: window.cognitoAppClientId,\n\t\t});\n\t\tconst cognitoUser = Cognito.getCognitoUser(null, userPool);\n\t\tif (cognitoUser) cognitoUser.signOut();\n\t\tthis\n\t\t\t.signout()\n\t\t\t.then(()=> {\n\t\t\t\twindow.location.reload();\n\t\t\t});\n\t}\n\n\tsignout() {\n\t\treturn axios.post('/api/customer/signout');\n\t}\n}\n","import {\n\tCognitoUserAttribute,\n\tCognitoUserPool,\n\tCognitoUser,\n\tAuthenticationDetails,\n\tconfig,\n} from 'amazon-cognito-identity-js';\n\nexport default class Cognito {\n\tstatic getUserPool() {\n\t\tconst poolData = {\n\t\t\tUserPoolId: window.cognitoUserPoolId,\n\t\t\tClientId: window.cognitoAppClientId,\n\t\t};\n\t\treturn new CognitoUserPool(poolData);\n\t}\n\n\tstatic createUserData(username, userPool) {\n\t\treturn {\n\t\t\tUsername: username,\n\t\t\tPool: userPool,\n\t\t};\n\t}\n\n\t/**\n\t * @summary Get cognito user\n\t * @description This method will return current cognito user if userData input is null\n\t * Or a new cognito user if userData input is not null\n\t * @param {object} userData\n\t * @param {object} userPool\n\t * @returns {object} cognito user\n\t */\n\tstatic getCognitoUser(userData, userPool) {\n\t\tif (userData) {\n\t\t\treturn new CognitoUser(userData);\n\t\t} else if (userPool) {\n\t\t\treturn userPool.getCurrentUser();\n\t\t}\n\t\treturn null;\n\t}\n\n\tstatic createAuthData(username, password) {\n\t\treturn new AuthenticationDetails({\n\t\t\tUsername: username,\n\t\t\tPassword: password,\n\t\t});\n\t}\n\n\tstatic refreshToken(cognitoUser, onSuccess, onFinally) {\n\t\tif (cognitoUser) return;\n\t\tcognitoUser.getSession((err, session)=>{\n\t\t\tconst refreshToken = session.getRefreshToken();\n\t\t\tif (config.credentials.needsRefresh()) {\n\t\t\t\tcognitoUser.refreshSession(refreshToken, (err, session) => {\n\t\t\t\t\tif (err) {\n\t\t\t\t\t\tconsole.log(err);\n\t\t\t\t\t\tif (typeof onFinally === 'function') onFinally();\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst jwtToken = session.getIdToken().getJwtToken();\n\t\t\t\t\t\tconfig.credentials.params.Logins[\n\t\t\t\t\t\t\t`cognito-idp.ap-southeast-2.amazonaws.com/${window.cognitoUserPoolId}`\n\t\t\t\t\t\t] = jwtToken;\n\t\t\t\t\t\tconfig.credentials.refresh((err) => {\n\t\t\t\t\t\t\tif (err) {\n\t\t\t\t\t\t\t\tconsole.log(err);\n\t\t\t\t\t\t\t\tif (typeof onFinally === 'function') onFinally();\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tif (typeof onSuccess === 'function') onSuccess(jwtToken);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t}\n\n\tstatic getUserAttributes(userPool) {\n\t\treturn new Promise((resolve, reject)=> {\n\t\t\tconst cognitoUser = Cognito.getCognitoUser(null, userPool);\n\t\t\tif (cognitoUser) {\n\t\t\t\tcognitoUser.getSession((err, session)=>{\n\t\t\t\t\tcognitoUser.getUserAttributes((err, result)=>{\n\t\t\t\t\t\tif (err) {\n\t\t\t\t\t\t\treject(err);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tresolve(result);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t}\n\n\tstatic getToken(userPool) {\n\t\treturn new Promise((resolve, reject)=> {\n\t\t\tconst cognitoUser = Cognito.getCognitoUser(null, userPool);\n\t\t\tcognitoUser.getSession((err, session)=>{\n\t\t\t\tif (err) {\n\t\t\t\t\treject(err);\n\t\t\t\t} else {\n\t\t\t\t\tresolve(session.getIdToken().getJwtToken());\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t}\n\n\tstatic signup(params, userPool) {\n\t\treturn new Promise((resolve, reject)=> {\n\t\t\tconst attributeList = [];\n\t\t\tconst firstname = {\n\t\t\t\tName: 'given_name',\n\t\t\t\tValue: params.firstname,\n\t\t\t};\n\n\t\t\tconst lastname = {\n\t\t\t\tName: 'family_name',\n\t\t\t\tValue: params.lastname,\n\t\t\t};\n\t\t\tconst attrFirstName = new CognitoUserAttribute(firstname);\n\t\t\tconst attrLastName = new CognitoUserAttribute(lastname);\n\n\t\t\tattributeList.push(...[attrFirstName, attrLastName]);\n\n\t\t\tuserPool.signUp(params.username, params.password, attributeList, null, (err, result)=> {\n\t\t\t\tif (err) {\n\t\t\t\t\treject(err);\n\t\t\t\t} else {\n\t\t\t\t\tresolve(result);\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t}\n}\n","export default class LoadingSpinner {\n\tstatic show() {\n\t\tconst $loader = document.querySelector('.loading-spinner');\n\t\tif ($loader) {\n\t\t\t$loader.classList.add('is-active');\n\t\t} else {\n\t\t\tdocument.body.insertAdjacentElement('beforeend', `