import{t as e}from"./axios-BolLiDn6.js";import{C as t,E as n,T as r,b as i,f as a,p as o,s,t as c,u as l}from"./_plugin-vue_export-helper-C3WbSyGy.js";import{a as u,r as d}from"./runtime-dom.esm-bundler-1ANOfYkS.js";import{n as f}from"./vuex.esm-bundler-6KYrHs9b.js";import p from"./DialogComponent-B4C5yzRq.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 _=t(`router-link`),v=t(`DialogComponent`);return i(),l(`div`,h,[c[9]||=s(`h2`,null,`Login`,-1),s(`form`,{onSubmit:c[2]||=u((...e)=>g.runLogin&&g.runLogin(...e),[`prevent`])},[c[4]||=s(`label`,{for:`email`},`Email-Adresse:`,-1),n(s(`input`,{type:`email`,id:`email`,"onUpdate:modelValue":c[0]||=e=>m.email=e,required:``},null,512),[[d,m.email]]),c[5]||=s(`label`,{for:`password`},`Passwort:`,-1),n(s(`input`,{type:`password`,id:`password`,"onUpdate:modelValue":c[1]||=e=>m.password=e,required:``},null,512),[[d,m.password]]),c[6]||=s(`button`,{type:`submit`},`Login`,-1)],32),s(`p`,null,[o(_,{to:`/register`},{default:r(()=>[...c[7]||=[a(`Registrieren`,-1)]]),_:1})]),s(`p`,null,[o(_,{to:`/forgot-password`},{default:r(()=>[...c[8]||=[a(`Passwort vergessen?`,-1)]]),_:1})]),o(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-A0o_QTnr.js.map