mirror of
https://github.com/Bubka/2FAuth.git
synced 2024-12-01 12:43:46 +01:00
2 lines
4.4 KiB
JavaScript
Vendored
2 lines
4.4 KiB
JavaScript
Vendored
import{R as j,b as D,a2 as G,T as O,r as m,o as q,d as J,I as z,a1 as Q,e as _,f as l,g as c,m as n,h as t,p as f,i as o,l as d,t as a,w as X,j as g,F as Y,E as Z,k as ee,U as se,n as A,C as E,H as y}from"./app-BsP-5XS6.js";import{F as te}from"./Form-BkUnzt6c.js";import{_ as oe}from"./SettingTabs-BfWoNH2z.js";import{S as ne}from"./Spinner-CewaMSJd.js";/*! 2FAuth version 5.2.0 - Copyright (c) 2024 Bubka - https://github.com/Bubka/2FAuth */const ae={class:"options-tabs"},ie=["innerHTML"],le={class:"title is-4 has-text-grey-light"},re={class:"is-size-7-mobile"},ce={class:"mt-3"},ue={key:1},de={class:"tags is-pulled-right"},me=["onClick"],_e=["onClick","title"],fe={key:1,class:"is-size-7-mobile is-size-6 my-3"},ve={key:2,class:"pat is-family-monospace is-size-6 is-size-7-mobile has-text-success"},pe={class:"mt-2 is-size-7 is-pulled-right"},he={key:0,class:"is-overlay modal-otp modal-background"},ke={class:"main-section"},ge={class:"field is-grouped"},ye={class:"control"},be={class:"control"},$e={__name:"OAuth",setup(Te){const S=j("2fauth"),v=D(),x=G(S.prefix+"returnTo","accounts"),{copy:L}=O({legacy:!0}),r=m([]),b=m(!1),T=m(!1),p=m(!1),h=m(null),C=m(null);q(()=>{w()});const u=J(new te({name:""}));function w(){b.value=!0,z.getPersonalAccessTokens({returnError:!0}).then(e=>{r.value=[],e.data.forEach(i=>{i.id===C.value?(i.value=h.value,r.value.unshift(i)):r.value.push(i)})}).catch(e=>{e.response.status===405?T.value=!0:v.error(e)}).finally(()=>{b.value=!1,C.value=null,h.value=null})}function F(){P(),T.value?v.warn({text:y("errors.unsupported_with_reverseproxy")}):p.value=!0}function M(){u.post("/oauth/personal-access-tokens").then(e=>{h.value=e.data.accessToken,C.value=e.data.token.id,w(),p.value=!1,u.reset()})}function N(e){confirm(y("settings.confirm.revoke"))&&z.deletePersonalAccessToken(e).then(i=>{r.value=r.value.filter(k=>k.id!==e),v.success({text:y("settings.token_revoked")})})}function P(){r.value.forEach(e=>{e.value=null}),h.value=null}function I(e){L(e),v.success({text:y("commons.copied_to_clipboard")})}function K(){p.value=!1,u.reset()}return Q(e=>{e.name.startsWith("settings.")||v.clear()}),(e,i)=>{const k=_("FontAwesomeIcon"),U=_("ButtonBackCloseCancel"),H=_("VueFooter"),V=_("FormWrapper"),R=_("FormField"),$=_("VueButton");return l(),c("div",null,[n(oe,{activeTab:"settings.oauth.tokens"},null,8,["activeTab"]),t("div",ae,[n(V,null,{default:f(()=>[o(T)?(l(),c("div",{key:0,class:"notification is-warning has-text-centered",innerHTML:e.$t("auth.auth_handled_by_proxy")},null,8,ie)):d("",!0),t("h4",le,a(e.$t("settings.personal_access_tokens")),1),t("div",re,a(e.$t("settings.token_legend")),1),t("div",ce,[t("a",{tabindex:"0",class:"is-link",onClick:F,onKeyup:X(F,["enter"])},[n(k,{icon:["fas","plus-circle"]}),g(" "+a(e.$t("settings.generate_new_token")),1)],32)]),o(r).length>0?(l(),c("div",ue,[(l(!0),c(Y,null,Z(o(r),s=>(l(),c("div",{key:s.id,class:"group-item is-size-5 is-size-6-mobile"},[s.value?(l(),ee(k,{key:0,class:"has-text-success",icon:["fas","check"]})):d("",!0),g(" "+a(s.name)+" ",1),t("div",de,[n(o(se),null,{default:f(({mode:B})=>[s.value?(l(),c("button",{key:0,class:A(["button tag",{"is-link":B!="dark"}]),onClick:E(W=>I(s.value),["stop"])},a(e.$t("commons.copy")),11,me)):d("",!0),t("button",{class:A(["button tag",B==="dark"?"is-dark":"is-white"]),onClick:W=>N(s.id),title:e.$t("settings.revoke")},a(e.$t("settings.revoke")),11,_e)]),_:2},1024)]),s.value?(l(),c("span",fe,a(e.$t("settings.make_sure_copy_token")),1)):d("",!0),s.value?(l(),c("span",ve,a(s.value),1)):d("",!0)]))),128)),t("div",pe,a(e.$t("settings.revoking_a_token_is_permanent")),1)])):d("",!0),n(ne,{isVisible:o(b)&&o(r).length===0},null,8,["isVisible"]),n(H,{showButtons:!0},{default:f(()=>[n(U,{returnTo:{name:o(x)},action:"close"},null,8,["returnTo"])]),_:1})]),_:1})]),o(p)?(l(),c("div",he,[t("main",ke,[n(V,{title:"settings.forms.new_token"},{default:f(()=>[t("form",{onSubmit:E(M,["prevent"]),onKeydown:i[1]||(i[1]=s=>o(u).onKeydown(s))},[n(R,{modelValue:o(u).name,"onUpdate:modelValue":i[0]||(i[0]=s=>o(u).name=s),fieldName:"name",fieldError:o(u).errors.get("name"),inputType:"text",label:"commons.name",autofocus:""},null,8,["modelValue","fieldError"]),t("div",ge,[t("div",ye,[n($,{id:"btnGenerateToken",isLoading:o(u).isBusy},{default:f(()=>[g(a(e.$t("commons.generate")),1)]),_:1},8,["isLoading"])]),t("div",be,[n($,{onClick:K,nativeType:"button",id:"btnCancel",color:"is-text"},{default:f(()=>[g(a(e.$t("commons.cancel")),1)]),_:1})])])],32)]),_:1})])])):d("",!0)])}}};export{$e as default};
|