import{_ as h,o as u,c as _,w as r,a as o,f as n,t as c,V as f,b as a,d as g,e as w,g as V,l as x,m,n as y,i as C,j as v,k as d}from"./index.d4e685c9.js";const b={name:"AuthUserPassword",props:{config:{type:Object,required:!0}},data(){return{user:this.config.user||"",password:"",show_pass:!1,error:"",req:null}},methods:{doLogin(){this.req=fetch(this.config.url,{method:"POST",mode:"cors",cache:"no-cache",redirect:"follow",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:this.user,password:this.password})}).then(t=>{if(t.ok)this.error=null,this.$emit("change","success");else throw t.status==401?Error("Invalid user/password"):Error(`Server responded with '${t.statusText}'`)}).catch(t=>{console.log("doLogin",t),this.error=t.toString(),this.req=null})},doCancel(){this.$emit("change","failed")}}},k={class:"d-flex flex-column"},S=n("span",null,"Authentication required to access:",-1),T={style:{"font-size":"120%"},class:"mt-4"},q=d("mdi-close"),B={key:0,class:"mt-6 mb-4",style:{color:"#aa3333"}},N={class:"d-flex mt-6"},U=d("Cancel"),L=d("Login");function P(t,e,i,j,s,p){return u(),_(v,null,{default:r(()=>[o(w,{class:"d-flex align-start"},{default:r(()=>[n("div",k,[S,n("span",T,c(i.config.realm),1)]),o(f),o(a,{elevation:"0",icon:"",onClick:e[0]||(e[0]=l=>t.$emit("change","failed")),class:"ml-6 mt-n1"},{default:r(()=>[o(g,null,{default:r(()=>[q]),_:1})]),_:1})]),_:1}),o(C,null,{default:r(()=>[n("form",{onSubmit:e[6]||(e[6]=y(()=>{},["prevent"]))},[s.error?(u(),V("div",B,c(s.error),1)):x("",!0),o(m,{modelValue:s.user,"onUpdate:modelValue":e[1]||(e[1]=l=>s.user=l),label:"User/login ID",autofocus:!i.config.fixed_user,disabled:i.config.fixed_user},null,8,["modelValue","autofocus","disabled"]),o(m,{modelValue:s.password,"onUpdate:modelValue":e[2]||(e[2]=l=>s.password=l),label:"Password",autofocus:i.config.fixed_user,type:s.show_pass?"text":"password","append-icon":s.show_pass?"mdi-eye":"mdi-eye-off","onClick:append":e[3]||(e[3]=l=>s.show_pass=!s.show_pass)},null,8,["modelValue","autofocus","type","append-icon"]),n("div",N,[o(a,{onClick:e[4]||(e[4]=l=>t.$emit("change","failed"))},{default:r(()=>[U]),_:1}),o(f),o(a,{color:"primary",type:"submit",onClick:p.doLogin,onDisable:e[5]||(e[5]=l=>!!s.req)},{default:r(()=>[L]),_:1},8,["onClick"])])],32)]),_:1})]),_:1})}var E=h(b,[["render",P]]);export{E as default};
