import{M as e,O as t,c as n,ct as r,d as i,h as a,j as o,m as s,t as c,u as l,w as u}from"./_plugin-vue_export-helper-Conii5fq.js";import{a as d,c as f}from"./runtime-dom.esm-bundler-CI28bPhn.js";import{n as p}from"./vuex.esm-bundler-CDO_-3pz.js";import{r as m}from"./router-Bsgsf08R.js";var h={name:`DialogComponent`,props:{title:{type:String,required:!0},message:{type:String,required:!0},modelValue:{type:Boolean,default:!1}},methods:{closeDialog(){this.$emit(`update:modelValue`,!1),this.$emit(`close`)}}},g={key:0,class:`dialog-overlay`},_={class:`dialog`};function v(e,t,a,o,s,c){return a.modelValue?(u(),i(`div`,g,[n(`div`,_,[n(`h2`,null,r(a.title),1),n(`p`,null,r(a.message),1),n(`button`,{onClick:t[0]||=(...e)=>c.closeDialog&&c.closeDialog(...e)},`OK`)])])):l(``,!0)}var y={name:`LoginComponent`,components:{DialogComponent:c(h,[[`render`,v],[`__scopeId`,`data-v-7743bdb5`]])},data(){return{email:``,password:``,dialogTitle:``,dialogMessage:``,dialogVisible:!1}},methods:{...p([`login`]),async runLogin(){try{let e=await m.post(`/auth/login`,{email:this.email,password:this.password}),t=e.data.token,n=e.data.user;this.login({user:n,token:t}),m.defaults.headers.common.Authorization=`Bearer ${t}`,this.$router.push(`/admin/index`)}catch(e){e.response?this.showDialog(`Fehler`,e.response.data.message):this.showDialog(`Ein Fehler ist aufgetreten`,e.message)}},showDialog(e,t){this.dialogTitle=e,this.dialogMessage=t,this.dialogVisible=!0},closeDialog(){this.dialogVisible=!1}}},b={class:`login`};function x(r,c,l,p,m,h){let g=t(`router-link`),_=t(`DialogComponent`);return u(),i(`div`,b,[c[9]||=n(`h2`,null,`Login`,-1),n(`form`,{onSubmit:c[2]||=f((...e)=>h.runLogin&&h.runLogin(...e),[`prevent`])},[c[4]||=n(`label`,{for:`email`},`Email-Adresse:`,-1),e(n(`input`,{type:`email`,id:`email`,"onUpdate:modelValue":c[0]||=e=>m.email=e,required:``},null,512),[[d,m.email]]),c[5]||=n(`label`,{for:`password`},`Passwort:`,-1),e(n(`input`,{type:`password`,id:`password`,"onUpdate:modelValue":c[1]||=e=>m.password=e,required:``},null,512),[[d,m.password]]),c[6]||=n(`button`,{type:`submit`},`Login`,-1)],32),n(`p`,null,[a(g,{to:`/register`},{default:o(()=>[...c[7]||=[s(`Registrieren`,-1)]]),_:1})]),n(`p`,null,[a(g,{to:`/forgot-password`},{default:o(()=>[...c[8]||=[s(`Passwort vergessen?`,-1)]]),_:1})]),a(_,{title:m.dialogTitle,message:m.dialogMessage,modelValue:m.dialogVisible,"onUpdate:modelValue":c[3]||=e=>m.dialogVisible=e,onClose:h.closeDialog},null,8,[`title`,`message`,`modelValue`,`onClose`])])}var S=c(y,[[`render`,x],[`__scopeId`,`data-v-1f68aa6b`]]);export{S as default};
//# sourceMappingURL=LoginContent-C12FGqVB.js.map