import{t as e}from"./axios-DHQprbt3.js";import{D as t,E as n,m as r,p as i,s as a,t as o,u as s,w as c,x as l}from"./_plugin-vue_export-helper-CCRG-STz.js";import{a as u,r as d}from"./runtime-dom.esm-bundler-D2hy5fF2.js";import{n as f}from"./vuex.esm-bundler-Ci4zImA8.js";import p from"./DialogComponent-BB67UImD.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,o,f,p,m,g){let _=c(`router-link`),v=c(`DialogComponent`);return l(),s(`div`,h,[o[9]||=a(`h2`,null,`Login`,-1),a(`form`,{onSubmit:o[2]||=u((...e)=>g.runLogin&&g.runLogin(...e),[`prevent`])},[o[4]||=a(`label`,{for:`email`},`Email-Adresse:`,-1),t(a(`input`,{type:`email`,id:`email`,"onUpdate:modelValue":o[0]||=e=>m.email=e,required:``},null,512),[[d,m.email]]),o[5]||=a(`label`,{for:`password`},`Passwort:`,-1),t(a(`input`,{type:`password`,id:`password`,"onUpdate:modelValue":o[1]||=e=>m.password=e,required:``},null,512),[[d,m.password]]),o[6]||=a(`button`,{type:`submit`},`Login`,-1)],32),a(`p`,null,[r(_,{to:`/register`},{default:n(()=>[...o[7]||=[i(`Registrieren`,-1)]]),_:1})]),a(`p`,null,[r(_,{to:`/forgot-password`},{default:n(()=>[...o[8]||=[i(`Passwort vergessen?`,-1)]]),_:1})]),r(v,{title:m.dialogTitle,message:m.dialogMessage,modelValue:m.dialogVisible,"onUpdate:modelValue":o[3]||=e=>m.dialogVisible=e,onClose:g.closeDialog},null,8,[`title`,`message`,`modelValue`,`onClose`])])}var _=o(m,[[`render`,g],[`__scopeId`,`data-v-5eeff340`]]);export{_ as default};
//# sourceMappingURL=LoginContent-Cf5QdG23.js.map