← Back
Editing: register.min.js
(globalThis.itsecWebpackJsonP=globalThis.itsecWebpackJsonP||[]).push([[7777],{3075:e=>{e.exports=function(){return this.wp.i18n}()},9724:(e,t,i)=>{"use strict";i.r(t),i.d(t,{init:()=>d});var s=i(64467),n=i(17232),r=i.n(n),o=i(3075),a=i(77172),l=i(61167);i.p=window.itsecWebpackPublicPath;class c{constructor(e,t){(0,s.A)(this,"captchaToken",void 0),(0,s.A)(this,"hasCaptcha",void 0),(0,s.A)(this,"$el",void 0),(0,s.A)(this,"$elements",{}),(0,s.A)(this,"notices",{}),(0,s.A)(this,"continueUrl",void 0),(0,s.A)(this,"registering",void 0),this.$el=e,this.notices=t}init({continueUrl:e,hasCaptcha:t=!1}){this.hasCaptcha=t,this.continueUrl=e;const i=this.$el.querySelector(".itsec-webauthn-register__submit");i&&(0,l.isAvailable)()?(this.$elements.button=i,this.setUpUI(),this.$el.addEventListener("solid-captcha-response",this.onCaptcha.bind(this)),this.$elements.button.addEventListener("click",this.onRegister.bind(this)),this.$el.querySelector('input[name="wp-submit"]').addEventListener("click",this.onNativeRegister.bind(this))):i&&i.remove()}setUpUI(){this.$elements.username=document.getElementById("user_login"),this.$elements.username.style.display="none",this.$el.querySelectorAll('[for="user_login"]').forEach((function(e){e.style.display="none"}));const e=document.createElement("p");e.classList.add("itsec-pwls-register__title"),e.innerText=(0,o.__)("This site uses Passwordless Registration","it-l10n-ithemes-security-pro"),this.$el.prepend(e),this.$el.querySelector('input[name="wp-submit"]').type="button",this.$elements.email=document.getElementById("user_email"),this.$elements.email.addEventListener("input",this.validateEmail.bind(this)),this.$elements.email.addEventListener("focus",this.validateEmail.bind(this)),this.$elements.email.focus()}onCaptcha(e){this.captchaToken=e.detail}async onRegister(){if(!this.registering)if(this.notices.removeNotices(),this.isValidEmail(this.$elements.email)){this.registering=!0,this.hasCaptcha&&(this.$el.dispatchEvent(new Event("solid-captcha")),this.captchaToken||await this.waitForToken());try{await(0,l.registerCredential)({authenticatorSelection:{residentKey:"preferred"},email:this.$elements.email.value,captcha:this.captchaToken}),window.location.href=this.continueUrl}catch(e){this.displayNoticeType("registration",e?.message||"")}this.registering=!1}else this.displayNoticeType("email")}onNativeRegister(){this.$el.submit()}waitForToken(){return new Promise((e=>{this.$el.addEventListener("solid-captcha-response",(()=>{e()}))}))}displayNoticeType(e,t){let i;if(this.notices.removeNotices(),"email"===e)i=(0,o.__)("Please enter a valid email address.","it-l10n-ithemes-security-pro");else{if("registration"!==e)return;i=(0,o.__)("Passkey Registration failed.","it-l10n-ithemes-security-pro")}t&&(i+="\n"+t),i=(0,o.sprintf)((0,o.__)("Error: %s","it-l10n-ithemes-security-pro"),i),this.notices.addErrorNotice(i)}validateEmail(e){this.isValidEmail(e.target)?(this.$elements.button.disabled=!1,this.$elements.username.value=e.target.value):(this.$elements.button.disabled=!0,this.notices.removeNotices())}isValidEmail(e){return e.value&&(0,a.isEmail)(e.value)}}class h{constructor(e){(0,s.A)(this,"$el",void 0),this.$el=e}addErrorNotice(e){this.addNotice(e,"error")}addNotice(e,t="info"){if(!this.$el)return;const i=document.createElement("p");i.innerText=e;const s=document.createElement("div");s.classList.add("itsec-notice","notice","notice-"+t,"message","register"),s.appendChild(i),this.$el.append(s)}removeNotices(){const e=this.$el.getElementsByClassName("itsec-notice");for(let t=0;t<e.length;t++)e[t].remove()}}const d=(e,t)=>{r()((async()=>{const i=document.getElementById("registerform");if(!i)return;const s=document.getElementById("login"),n=document.createElement("div");n.classList.add("itsec-notice-container"),s.insertBefore(n,i);const r=new h(n);new c(i,r).init({continueUrl:t,hasCaptcha:e})}))}},17232:e=>{e.exports=function(){return this.wp.domReady}()},20816:(e,t,i)=>{"use strict";i.d(t,{A:()=>n});var s=i(82284);function n(e){var t=function(e){if("object"!=(0,s.A)(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var i=t.call(e,"string");if("object"!=(0,s.A)(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==(0,s.A)(t)?t:t+""}},61167:e=>{e.exports=function(){return this.itsec.webauthn.utils}()},64467:(e,t,i)=>{"use strict";i.d(t,{A:()=>n});var s=i(20816);function n(e,t,i){return(t=(0,s.A)(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}},77172:e=>{e.exports=function(){return this.wp.url}()},82284:(e,t,i)=>{"use strict";function s(e){return s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},s(e)}i.d(t,{A:()=>s})}},e=>{var t=e(e.s=9724);((window.itsec=window.itsec||{})["passwordless-login"]=window.itsec["passwordless-login"]||{}).register=t}]);
Save File
Cancel