2FAuth/public/build/assets/OAuth-DqNwsu-0.js
2024-10-27 07:35:17 +01:00

2 lines
4.7 KiB
JavaScript
Vendored

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