import{t as e}from"./axios-DHQprbt3.js";import{M as t,O as n,c as r,d as i,h as a,j as o,m as s,t as c,w as l}from"./_plugin-vue_export-helper-Conii5fq.js";import{a as u,c as d}from"./runtime-dom.esm-bundler-CI28bPhn.js";import{n as f}from"./vuex.esm-bundler-CDO_-3pz.js";import p from"./DialogComponent-Xljax2a4.js";var m={name:`LoginComponent`,components:{DialogComponent:p},data(){return{email:``,password:``,dialogTitle:``,dialogMessage:``,dialogVisible:!1}},methods:{...f([`login`]),async runLogin(){try{let t=await e.post(`/auth/login`,{email:this.email,password:this.password}),n=t.data.token,r=t.data;localStorage.setItem(`token`,n),this.login(r.user),e.defaults.headers.common.Authorization=`Bearer ${n}`,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}}},h={class:`login`};function g(e,c,f,p,m,g){let _=n(`router-link`),v=n(`DialogComponent`);return l(),i(`div`,h,[c[9]||=r(`h2`,null,`Login`,-1),r(`form`,{onSubmit:c[2]||=d((...e)=>g.runLogin&&g.runLogin(...e),[`prevent`])},[c[4]||=r(`label`,{for:`email`},`Email-Adresse:`,-1),t(r(`input`,{type:`email`,id:`email`,"onUpdate:modelValue":c[0]||=e=>m.email=e,required:``},null,512),[[u,m.email]]),c[5]||=r(`label`,{for:`password`},`Passwort:`,-1),t(r(`input`,{type:`password`,id:`password`,"onUpdate:modelValue":c[1]||=e=>m.password=e,required:``},null,512),[[u,m.password]]),c[6]||=r(`button`,{type:`submit`},`Login`,-1)],32),r(`p`,null,[a(_,{to:`/register`},{default:o(()=>[...c[7]||=[s(`Registrieren`,-1)]]),_:1})]),r(`p`,null,[a(_,{to:`/forgot-password`},{default:o(()=>[...c[8]||=[s(`Passwort vergessen?`,-1)]]),_:1})]),a(v,{title:m.dialogTitle,message:m.dialogMessage,modelValue:m.dialogVisible,"onUpdate:modelValue":c[3]||=e=>m.dialogVisible=e,onClose:g.closeDialog},null,8,[`title`,`message`,`modelValue`,`onClose`])])}var _=c(m,[[`render`,g],[`__scopeId`,`data-v-5eeff340`]]);export{_ as default};
//# sourceMappingURL=LoginContent-BuB5FgEi.js.map