1import{_ as M}from"./wep0n37s.js";import{d as J,u as j,b7 as q,O as z,b as H,E as _,v as K,aK as Q,h as E,k as X,J as w,g as f,j as i,n as Y,i as g,b8 as u,b9 as m,ai as S,aO as Z}from"./DlfMOYjO.js";import{F as U}from"./oUX_p-gP.js";import"./CX3m-Oeu.js";const D={ref:"loginPage",class:"bp-main-grid center-content"},W={class:"center-content bg-surface-secondary shadow-default md:p-15 mt-20 rounded-md pb-10"},oe=J({__name:"Login",setup(ee){const{getTranslation:e}=j(),n=H(),R=q(),{trackAuthEvent:c}=z(),T=e("header.login"),y=e("password_reset.form.header"),F=e("views.base.login.submit_error"),$=e("password_reset.form.email_error"),h=(n==null?void 0:n.public.LOGIN_URL)||"/login",v=(n==null?void 0:n.public.SIGNUP_UR)||"/signin",O=_(()=>{var a,o,l;return((l=(o=(a=R.currentRoute)==null?void 0:a.value)==null?void 0:o.query)==null?void 0:l.step)||!1}),P=_(()=>window.location.origin),b=_(()=>`${P.value}${h}?step=forgot-password`),L=[{id:"loginEmail",element:"input",type:"email",error:e("login.form.email_error"),placeholder:e("login.form.email_label"),debounce:!0},{id:"loginPassword",element:"input",type:"password",error:e("login.form.password_error"),placeholder:e("login.form.password_label"),debounce:!0},{id:"forgotPassword",element:"markdown",content:` <a href="${b==null?void 0:b.value}"> ${e("login.form.forgot_password")} </a> `},{id:"submitButton",element:"button",label:T},{id:"hasAbonement",element:"markdown",content:`<strong>${e("login.form.already_subscriber_header")}</strong> ${e("login.form.already_subscriber_description")} <a href="${v}">${e("fields.click_here")}</a>`},{id:"newUser",element:"markdown",content:`<strong>${e("login.form.new_user_header")}</strong> <a href="#" class="mkt-subscribe-trigger">${e("login.form.get_access_now")}</a>`}],x=[{id:"hasAbonement",element:"markdown",content:e("password_reset.form.email_help")},{id:"resetEmail",element:"input",type:"email",debounce:!0,placeholder:e("signup.credentials_form.email_label"),error:e("signup.credentials_form.email_error")},{id:"hasAbonement",element:"markdown",content:`<a href='${h}'> ${e("fields.back")} </a>`},{id:"submitButton",element:"button",label:e("auth.reset_password")}],s=K(),t=Q({status:0,statusText:""}),C=async a=>{var o,l,I;if(!a.loginEmail||!a.loginPassword)throw c(u.LOGIN_FAILURE,m.ERROR,"signInForm","all page","Invalid credentials"),S("Invalid credentials");c(u.LOGIN_SUBMIT,m.SUBMIT,"signInForm","all page");try{const r=await $fetch("/api/auth/login",{method:"POST",body:{username:a.loginEmail,password:a.loginPassword},credentials:"include"});s.setUser({...(o=r==null?void 0:r.willowUser)==null?void 0:o.attributes.reduce((p,k)=>(p[k.Name]=k.Value,p),{}),accessToken:(l=r==null?void 0:r.willowUser)==null?void 0:l.accessToken,refreshToken:(I=r==null?void 0:r.willowUser)==null?void 0:I.refreshToken}),t.status=r.status,t.statusText=r.statusText??"",await s.getFavourites(s.user.sub);const B=n==null?void 0:n.public.BRAND_CODE.toUpperCase(),d=s==null?void 0:s.user["custom:subscribed_brands"],G=s==null?void 0:s.user["custom:subscription_number"];d!=null&&d.includes(B)||["PAS","IVP","IFP","GDP","HIP"].some(p=>d==null?void 0:d.includes(p))?s.setUserState("Subscriber"):G?s.setUserState("ExpiredSubscriber"):s.setUserState("JustRegister"),c(u.LOGIN_SUCCESS,m.SUCCESS,"signInForm","all page");const V=localStorage.getItem("returnUrl");Z(V||"/")}catch{t.status=401,t.statusText=F,c(u.LOGIN_FAILURE,m.ERROR,"signInForm","all page",`${t.status} ${t.statusText}`)}},N=async a=>{if(!a.resetEmail)throw c(u.LOGIN_FAILURE,m.ERROR,"signInForm","all page","Invalid credentials"),S("Invalid credentials");try{(await $fetch("/api/auth/resetpassword",{method:"POST",body:{email:a.resetEmail}})).statusCode===200&&(t.status=200,t.statusText=e("password_reset.form.check_email_body"),c(u.LOGIN_SUCCESS,m.SUBMIT,"signInForm","all page"))}catch(o){t.status=401,t.statusText=$,c(u.LOGIN_FAILURE,m.ERROR,"signInForm","all page",`${o}`),console.error("error: ",o)}},A=_(()=>t.status===200?"status-success":"status-error");return(a,o)=>{const l=M;return g(),E("main",D,[X("div",W,[i(O)==="forgot-password"?(g(),w(U,{key:0,title:i(y),class:"","form-elements":x,onSubmit:N},null,8,["title"])):(g(),w(U,{key:1,title:"Log in form","form-elements":L,onSubmit:C})),i(t).status!==0?(g(),E("div",{key:2,class:Y([i(A),"bg-surface-secondary px-15 rounded-md shadow-lg"])},[i(t).status===200?(g(),w(l,{key:0,class:"text-success bg-[#90ee90] p-6",markdown:i(t).statusText},null,8,["markdown"])):f("",!0),i(t).status===401?(g(),w(l,{key:1,class:"text-success bg-[#ff0000] p-6",markdown:i(t).statusText},null,8,["markdown"])):f("",!0)],2)):f("",!0)])],512)}}});
1export{oe as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.