芝麻web文件管理V1.00
编辑当前文件:/home/pulsehostuk9/public_html/invoicer.pulsehost.co.uk/public/build/assets/auth-BcagBUX6.js
import{u as r,s as l,bm as m}from"./main-WS8l16KQ.js";const u=e=>{const t=p(),a=r();if(!e.response)a.showNotification({type:"error",message:"Please check your internet connection or wait until servers are back online."});else if(e.response.data&&(e.response.statusText==="Unauthorized"||e.response.data===" Unauthorized.")){const o=e.response.data.message?e.response.data.message:"Unauthorized";i(o),t.logout()}else if(e.response.data.errors){const o=JSON.parse(JSON.stringify(e.response.data.errors));for(const s in o)d(o[s][0])}else e.response.data.error?d(e.response.data.error):d(e.response.data.message)},d=e=>{switch(e){case"These credentials do not match our records.":i("errors.login_invalid_credentials");break;case"The email has already been taken.":i("validation.email_already_taken");break;case"invalid_credentials":i("errors.invalid_credentials");break;case"Email could not be sent to this email address.":i("errors.email_could_not_be_sent");break;case"not_allowed":i("errors.not_allowed");break;default:i(e,!1);break}},i=(e,t=!0)=>{const{global:a}=window.i18n;r().showNotification({type:"error",message:t?a.t(e):e})},{defineStore:f}=window.pinia,{global:n}=window.i18n,p=f({id:"customerAuth",state:()=>({loginData:{email:"",password:"",device_name:"xyz",company:""}}),actions:{login(e){const t=r(!0);return new Promise((a,o)=>{l.get("/sanctum/csrf-cookie").then(s=>{s&&l.post(`/${e.company}/customer/login`,e).then(c=>{t.showNotification({type:"success",message:n.tm("general.login_successfully")}),a(c),setTimeout(()=>{this.loginData.email="",this.loginData.password=""},1e3)}).catch(c=>{u(c),o(c)})})})},forgotPassword(e){const t=r(!0);return new Promise((a,o)=>{l.post(`/api/v1/${e.company}/customer/auth/password/email`,e).then(s=>{s.data&&t.showNotification({type:"success",message:n.tm("general.send_mail_successfully")}),a(s)}).catch(s=>{s.response&&s.response.status===403?t.showNotification({type:"error",message:n.tm("errors.email_could_not_be_sent")}):u(s),o(s)})})},resetPassword(e,t){return new Promise((a,o)=>{l.post(`/api/v1/${t}/customer/auth/reset/password`,e).then(s=>{s.data&&r(!0).showNotification({type:"success",message:n.tm("login.password_reset_successfully")}),a(s)}).catch(s=>{s.response&&s.response.status===403&¬ificationStore.showNotification({type:"error",message:n.tm("validation.email_incorrect")}),o(s)})})},logout(e){return new Promise((t,a)=>{l.post(`/${e}/customer/logout`).then(o=>{r().showNotification({type:"success",message:n.tm("general.logged_out_successfully")}),m.push({name:"customer.login"}),t(o)}).catch(o=>{u(o),a(o)})})}}});export{u as h,p as u};