mirror of
https://github.com/nextcloud/server.git
synced 2026-02-18 18:28:50 -05:00
3 lines
4.4 KiB
JavaScript
3 lines
4.4 KiB
JavaScript
import{d as U,c as A}from"./pinia-eY1FsIxi.chunk.mjs";import{r as _,b as I,j as p,o as n,c as x,u as a,w as k,g as i,t as d,l as E,F as m,k as f,p as N,C as M,n as w,e as y,h as R}from"./runtime-dom.esm-bundler-nUg13ekW.chunk.mjs";import{g as $,l as j,a as B}from"./index-Ma7sfat2.chunk.mjs";import{a as P}from"./index-C1xmmKTZ-B_lLl9Ld.chunk.mjs";import{t as o}from"./translation-DoG5ZELJ-2ffMJaM4.chunk.mjs";import{c as F}from"./index-b3AfNmc1.chunk.mjs";import{N as g}from"./logger-D3RVzcfQ-B4GxPQ5t.chunk.mjs";import{N as G}from"./mdi-DK5BPbEO.chunk.mjs";import{g as H}from"./index-6_gsQFyp.chunk.mjs";import{c as q}from"./index-ClUK5nWL.chunk.mjs";import{g as z}from"./createElementId-DhjFt1I9-CRJVCjcq.chunk.mjs";import"./index-DeDXQtUD.chunk.mjs";import"./NcNoteCard-Cok_4Fld-BLQT242e.chunk.mjs";import"./NcPasswordField-uaMO2pdt-Bb_nZP1o.chunk.mjs";import"./NcInputField-o5OFv3z6-DGXgkff4.chunk.mjs";import"./index-sH3U_332.chunk.mjs";const D=H().detectLogLevel().setApp("twofactor_backupcodes").build();function J(r){const c=$().theming.name||"Nextcloud",e=window.open("",o("twofactor_backupcodes","{name} backup codes",{name:c}));if(!e)throw P(o("twofactor_backupcodes","Unable to open a new tab for printing")),new Error("Unable to open a new tab for printing");const t=e.document.createElement("h1");t.textContent=o("twofactor_backupcodes","{name} backup codes",{name:c});const s=e.document.createElement("pre");for(const b of r){const u=e.document.createTextNode(b);s.appendChild(u),s.appendChild(e.document.createElement("br"))}e.document.body.innerHTML="",e.document.body.appendChild(t),e.document.body.appendChild(s),e.print(),e.close()}async function K(){const r=z("/apps/twofactor_backupcodes/settings/create"),{data:c}=await q.post(r);return c}const v=j("twofactor_backupcodes","state"),O=U("twofactor_backupcodes",()=>{const r=_(v.enabled),c=_(v.total),e=_(v.used),t=_([]);async function s(){r.value=!1;const{codes:b,state:u}=await K();r.value=u.enabled,c.value=u.total,e.value=u.used,t.value=b}return{enabled:r,total:c,used:e,codes:t,generate:s}}),Q=["aria-label"],V=I({__name:"PersonalSettings",setup(r){const c=$().theming.name??"Nextcloud",e=O(),t=_(!1),s=N(()=>e.codes&&e.codes.length>0),b=c+"-backup-codes.txt",u=N(()=>s.value?"data:text/plain,"+encodeURIComponent(e.codes.reduce((l,C)=>l+C+`
|
|
`,"")):"");async function h(){await F(),t.value=!0;try{await e.generate()}catch(l){D.error("Error generating backup codes",{error:l}),P(o("twofactor_backupcodes","An error occurred while generating your backup codes"))}finally{t.value=!1}}function T(){J(!e.codes||e.codes.length===0?[]:e.codes)}return(l,C)=>(n(),p("div",{class:w(l.$style.backupcodesSettings)},[a(e).enabled?(n(),p(m,{key:1},[f("p",null,[s.value?(n(),p(m,{key:1},[i(d(a(o)("twofactor_backupcodes","These are your backup codes. Please save and/or print them as you will not be able to read the codes again later."))+" ",1),f("ul",{"aria-label":a(o)("twofactor_backupcodes","List of backup codes")},[(n(!0),p(m,null,M(a(e).codes,S=>(n(),p("li",{key:S,class:w(l.$style.backupcodesSettings__code)},d(S),3))),128))],8,Q)],64)):(n(),p(m,{key:0},[i(d(a(o)("twofactor_backupcodes","Backup codes have been generated. {used} of {total} codes have been used.",{used:a(e).used,total:a(e).total})),1)],64))]),f("p",{class:w(l.$style.backupcodesSettings__actions)},[y(a(g),{id:"generate-backup-codes",variant:"error",onClick:h},{default:k(()=>[i(d(a(o)("twofactor_backupcodes","Regenerate backup codes")),1)]),_:1}),s.value?(n(),p(m,{key:0},[y(a(g),{onClick:T},{default:k(()=>[i(d(a(o)("twofactor_backupcodes","Print backup codes")),1)]),_:1}),y(a(g),{href:u.value,download:b,variant:"primary"},{default:k(()=>[i(d(a(o)("twofactor_backupcodes","Save backup codes")),1)]),_:1},8,["href"])],64)):E("",!0)],2),f("p",null,[f("em",null,d(a(o)("twofactor_backupcodes","If you regenerate backup codes, you automatically invalidate old codes.")),1)])],64)):(n(),x(a(g),{key:0,disabled:t.value,variant:"primary",onClick:h},{icon:k(()=>[t.value?(n(),x(a(G),{key:0})):E("",!0)]),default:k(()=>[i(" "+d(a(o)("twofactor_backupcodes","Generate backup codes")),1)]),_:1},8,["disabled"]))],2))}}),W="_backupcodesSettings_bnkw8_2",X="_backupcodesSettings__code_bnkw8_7",Y="_backupcodesSettings__actions_bnkw8_13",Z={backupcodesSettings:W,backupcodesSettings__code:X,backupcodesSettings__actions:Y},ee={$style:Z},ae=B(V,[["__cssModules",ee]]),oe=A(),L=R(ae);L.use(oe),L.mount("#twofactor-backupcodes-settings");
|
|
//# sourceMappingURL=twofactor_backupcodes-settings-personal.mjs.map
|