2FAuth/public/build/assets/AppSetup-b7dcb9f9.js
2024-03-21 18:41:26 +01:00

2 lines
8.9 KiB
JavaScript
Vendored
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import{_ as q}from"./AdminTabs-7af3858b.js";import{a4 as B,R as A,r as b,e as g,f as _,g as f,h as n,n as F,i as s,t as u,m as i,p as I,j as C,l as M,U as J,Q as K,a as P,b as E,a2 as X,a0 as Y,o as Z,I as $,F as ee,G as se}from"./app-2d89b28f.js";import{_ as te}from"./CopyButton-7a25d704.js";/*! 2FAuth version 5.1.1 - Copyright (c) 2023 Bubka - https://github.com/Bubka/2FAuth */const w=B("api"),U={get(r={}){return w.get("/settings",{...r})},update(r,p){return w.put("/settings/"+r,{value:p})},delete(r,p={}){return w.delete("/settings/"+r,{...p})}},S=B("web"),L={getSystemInfos(r={}){return S.get("system/infos",{...r})},getLastRelease(r={}){return S.get("system/latestRelease",{...r})},sendTestEmail(r={}){return S.post("system/test-email",{...r})},clearCache(r={}){return S.get("system/clear-cache",{...r})},optimize(r={}){return S.get("system/optimize",{...r})}},le={class:"columns is-mobile is-vcentered"},ne={class:"column is-narrow"},ae={class:"column"},oe=n("span",{class:"release-flag"},null,-1),ie={class:"is-size-7",href:"https://github.com/Bubka/2FAuth/releases"},re={key:1,class:"has-text-grey"},de={key:2,class:"has-text-grey"},ue={__name:"VersionChecker",setup(r){const p=A(),k=b(!1),m=b();async function a(){k.value=!0,m.value=void 0,await L.getLastRelease({returnError:!0}).then(c=>{p.latestRelease=c.data.newRelease,m.value=c.data.newRelease===null?null:c.data.newRelease===!1}).catch(()=>{m.value=null}),k.value=!1}return(c,y)=>{const R=g("FontAwesomeIcon");return _(),f("div",le,[n("div",ne,[n("button",{type:"button",class:F([s(k)?"is-loading":"","button is-link is-rounded is-small"]),onClick:a},u(c.$t("admin.check_now")),3)]),n("div",ae,[i(s(J),null,{default:I(({mode:V})=>[s(p).latestRelease?(_(),f("span",{key:0,class:F(["mt-2",V=="dark"?"has-text-warning":"has-text-warning-dark"])},[oe,C(u(c.$t("admin.x_is_available",{version:s(p).latestRelease}))+" ",1),n("a",ie,u(c.$t("admin.view_on_github")),1)],2)):M("",!0),s(m)?(_(),f("span",re,[i(R,{icon:["fas","check"],class:"mr-1 has-text-success"}),C(" "+u(c.$t("commons.you_are_up_to_date")),1)])):s(m)===null?(_(),f("span",de,[i(R,{icon:["fas","times"],class:"mr-1 has-text-danger"}),C(u(c.$t("errors.check_failed_try_later")),1)])):M("",!0)]),_:1})])])}}},ce={class:"options-tabs"},me={class:"title is-4 pt-4 has-text-grey-light"},pe={class:"field"},_e=["innerHTML"],fe=["innerHTML"],be=["innerHTML"],he={class:"columns is-mobile is-vcentered"},ge={class:"column is-narrow"},ye={class:"icon is-small"},ve={class:"title is-4 pt-4 has-text-grey-light"},ke={class:"title is-4 pt-4 has-text-grey-light"},Re={class:"title is-4 pt-5 has-text-grey-light"},Ve={class:"field"},Se=["innerHTML"],Ee=["innerHTML"],$e={class:"field mb-5 is-grouped"},Ce={class:"control"},Le={class:"field"},Fe=["innerHTML"],Te={key:0,class:"about-debug box is-family-monospace is-size-7"},we=["value"],Ue={class:"has-text-grey"},Ie={key:1,class:"about-debug box is-family-monospace is-size-7 has-text-warning-dark"},xe={__name:"AppSetup",setup(r){const p=K("2fauth"),k=P(),m=E(),a=A(),c=X(p.prefix+"returnTo","accounts"),y=b(),R=b(null),V=b(!1),T=b(!1),v=b({restrictList:null,restrictRule:null}),o=b({checkForUpdate:a.checkForUpdate,useEncryption:a.useEncryption,restrictRegistration:a.restrictRegistration,restrictList:a.restrictList,restrictRule:a.restrictRule,disableRegistration:a.disableRegistration,keepSsoRegistrationEnabled:a.keepSsoRegistrationEnabled,enableSso:a.enableSso});function h(l,e){v.value[l]=null,U.update(l,e).then(d=>{a[l]=e,E().success({type:"is-success",text:$("settings.forms.setting_saved")})}).catch(d=>{d.response.status===422?v.value[l]=d.response.data.message:m.error(d)})}function N(l,e){e==""?(v.value[l]=null,U.delete(l,{returnError:!0}).then(d=>{a[l]="",E().success({type:"is-success",text:$("settings.forms.setting_saved")})}).catch(d=>{d.response.status!==404&&m.error(d)})):h(l,e)}function z(){V.value=!0,L.sendTestEmail().finally(()=>{V.value=!1})}function W(){T.value=!0,L.clearCache().then(l=>{E().success({type:"is-success",text:$("admin.cache_cleared")})}).finally(()=>{T.value=!1})}return Y(l=>{l.name.startsWith("admin.")||m.clear()}),Z(async()=>{U.get({returnError:!0}).then(l=>{o.value.restrictList="",o.value.restrictRule="",l.data.forEach(e=>{a[e.key]=e.value,o.value[e.key]=e.value})}).catch(l=>{m.alert({text:$("errors.data_cannot_be_refreshed_from_server")})}),L.getSystemInfos({returnError:!0}).then(l=>{y.value=l.data.common}).catch(()=>{y.value=null})}),(l,e)=>{const d=g("FormCheckbox"),j=g("FontAwesomeIcon"),H=g("FormField"),G=g("FormWrapper"),O=g("ButtonBackCloseCancel"),Q=g("VueFooter");return _(),f("div",null,[i(q,{activeTab:"admin.appSetup"}),n("div",ce,[i(G,null,{default:I(()=>{var x;return[n("form",null,[n("h4",me,u(l.$t("settings.general")),1),i(d,{modelValue:s(o).checkForUpdate,"onUpdate:modelValue":[e[0]||(e[0]=t=>s(o).checkForUpdate=t),e[1]||(e[1]=t=>h("checkForUpdate",t))],fieldName:"checkForUpdate",label:"commons.check_for_update",help:"commons.check_for_update_help"},null,8,["modelValue"]),i(ue),n("div",pe,[n("label",{class:"label",innerHTML:l.$t("admin.forms.test_email.label")},null,8,_e),n("p",{class:"help",innerHTML:l.$t("admin.forms.test_email.help")},null,8,fe),n("p",{class:"help",innerHTML:l.$t("admin.forms.test_email.email_will_be_send_to_x",{email:s(k).email})},null,8,be)]),n("div",he,[n("div",ge,[n("button",{type:"button",class:F([s(V)?"is-loading":"","button is-link is-rounded is-small"]),onClick:z},[n("span",ye,[i(j,{icon:["far","paper-plane"]})]),n("span",null,u(l.$t("commons.send")),1)],2)])]),n("h4",ve,u(l.$t("settings.security")),1),i(d,{modelValue:s(o).useEncryption,"onUpdate:modelValue":[e[2]||(e[2]=t=>s(o).useEncryption=t),e[3]||(e[3]=t=>h("useEncryption",t))],fieldName:"useEncryption",label:"admin.forms.use_encryption.label",help:"admin.forms.use_encryption.help"},null,8,["modelValue"]),n("h4",ke,u(l.$t("admin.registrations")),1),i(d,{modelValue:s(o).enableSso,"onUpdate:modelValue":[e[4]||(e[4]=t=>s(o).enableSso=t),e[5]||(e[5]=t=>h("enableSso",t))],fieldName:"enableSso",label:"admin.forms.enable_sso.label",help:"admin.forms.enable_sso.help"},null,8,["modelValue"]),i(d,{modelValue:s(o).restrictRegistration,"onUpdate:modelValue":[e[6]||(e[6]=t=>s(o).restrictRegistration=t),e[7]||(e[7]=t=>h("restrictRegistration",t))],fieldName:"restrictRegistration",isDisabled:s(a).disableRegistration,label:"admin.forms.restrict_registration.label",help:"admin.forms.restrict_registration.help"},null,8,["modelValue","isDisabled"]),i(H,{modelValue:s(o).restrictList,"onUpdate:modelValue":e[8]||(e[8]=t=>s(o).restrictList=t),"onChange:modelValue":e[9]||(e[9]=t=>N("restrictList",t)),fieldError:s(v).restrictList,fieldName:"restrictList",isDisabled:!s(a).restrictRegistration||s(a).disableRegistration,label:"admin.forms.restrict_list.label",help:"admin.forms.restrict_list.help",isIndented:!0},null,8,["modelValue","fieldError","isDisabled"]),i(H,{modelValue:s(o).restrictRule,"onUpdate:modelValue":e[10]||(e[10]=t=>s(o).restrictRule=t),"onChange:modelValue":e[11]||(e[11]=t=>N("restrictRule",t)),fieldError:s(v).restrictRule,fieldName:"restrictRule",isDisabled:!s(a).restrictRegistration||s(a).disableRegistration,label:"admin.forms.restrict_rule.label",help:"admin.forms.restrict_rule.help",isIndented:!0,leftIcon:"slash",rightIcon:"slash"},null,8,["modelValue","fieldError","isDisabled"]),i(d,{modelValue:s(o).disableRegistration,"onUpdate:modelValue":[e[12]||(e[12]=t=>s(o).disableRegistration=t),e[13]||(e[13]=t=>h("disableRegistration",t))],fieldName:"disableRegistration",label:"admin.forms.disable_registration.label",help:"admin.forms.disable_registration.help"},null,8,["modelValue"]),i(d,{modelValue:s(o).keepSsoRegistrationEnabled,"onUpdate:modelValue":[e[14]||(e[14]=t=>s(o).keepSsoRegistrationEnabled=t),e[15]||(e[15]=t=>h("keepSsoRegistrationEnabled",t))],fieldError:s(v).keepSsoRegistrationEnabled,fieldName:"keepSsoRegistrationEnabled",isDisabled:!s(a).enableSso||!s(a).disableRegistration,label:"admin.forms.keep_sso_registration_enabled.label",help:"admin.forms.keep_sso_registration_enabled.help",isIndented:!0},null,8,["modelValue","fieldError","isDisabled"])]),n("h4",Re,u(l.$t("commons.environment")),1),n("div",Ve,[n("label",{class:"label",innerHTML:l.$t("admin.forms.cache_management.label")},null,8,Se),n("p",{class:"help",innerHTML:l.$t("admin.forms.cache_management.help")},null,8,Ee)]),n("div",$e,[n("p",Ce,[n("button",{type:"button",class:F([s(T)?"is-loading":"","button is-link is-rounded is-small"]),onClick:W},u(l.$t("commons.clear")),3)])]),n("div",Le,[n("label",{class:"label",innerHTML:l.$t("admin.variables")},null,8,Fe)]),s(y)?(_(),f("div",Te,[i(te,{id:"btnCopyEnvVars",token:(x=s(R))==null?void 0:x.innerText},null,8,["token"]),n("ul",{ref_key:"listInfos",ref:R,id:"listInfos"},[(_(!0),f(ee,null,se(s(y),(t,D)=>(_(),f("li",{value:t,key:D},[n("b",null,u(D),1),C(": "),n("span",Ue,u(t),1)],8,we))),128))],512)])):s(y)===null?(_(),f("div",Ie,u(l.$t("errors.error_during_data_fetching")),1)):M("",!0)]}),_:1})]),i(Q,{showButtons:!0},{default:I(()=>[i(O,{returnTo:{name:s(c)},action:"close"},null,8,["returnTo"])]),_:1})])}}};export{xe as default};