2FAuth/public/build/assets/Manage-DFj3U8y5.js
2024-10-12 20:09:07 +02:00

2 lines
8.6 KiB
JavaScript
Vendored

import{_ as D}from"./CopyButton-xy5y_fwK.js";import{_ as O}from"./AccessLogViewer-CINYivkh.js";import{b as Y,u as G,a as J,R as K,r as b,o as Q,I as h,e as f,f as o,k as X,p as m,h as s,t as n,i,g as r,m as d,n as p,j as k,U as v,l as _,F as Z,E as ee,H as u,P as M}from"./app-SZK8VCXD.js";import{u as se}from"./bus-B5bab611.js";import"./SearchBox-CVIMp336.js";import"./Spinner-YD_iyg7o.js";/*! 2FAuth version 5.3.1 - Copyright (c) 2024 Bubka - https://github.com/Bubka/2FAuth */const te={class:"title has-text-grey-dark mb-6"},ie={key:0,class:"has-text-centered"},ne={class:"is-size-4"},ae={key:1},oe={class:"has-text-weight-light has-text-grey-dark is-pulled-right"},re={class:"subtitle is-6 block"},le={key:0,class:"notification is-dark is-size-7-mobile has-text-centered"},de={class:"block is-size-6 is-size-7-mobile has-text-grey"},ce={class:"block"},ue={key:1,class:"title is-4 has-text-grey-light"},_e={key:2,class:"block"},me={class:"list-item is-size-6 is-size-6-mobile has-text-grey"},he={class:"mb-3 is-flex is-justify-content-space-between"},fe={class:"has-text-weight-bold"},pe={class:"tags ml-3 is-right"},ke=["title"],ge=["title"],be={class:"is-size-7 is-size-7-mobile has-text-grey-dark"},ve=["innerHTML"],ye=["innerHTML"],we=["innerHTML"],$e=["innerHTML"],xe={class:"list-item is-size-6 is-size-6-mobile has-text-grey is-flex is-justify-content-space-between"},ze={class:"has-text-weight-bold"},Ce={class:"is-block is-family-primary has-text-grey-dark"},Te={key:0},Fe={class:"tags ml-3 is-right"},Le=["title"],Me={class:"list-item is-size-6 is-size-6-mobile has-text-grey is-flex is-justify-content-space-between"},Be={class:"has-text-weight-bold"},Ie={class:"is-block has-text-grey-dark"},Ee={key:0},He={class:"tags ml-3 is-right"},Pe=["title"],Ue={class:"block"},Ve={class:"title is-5 has-text-grey-light mb-2"},Ne={key:3,class:"block is-size-6 is-size-7-mobile has-text-grey"},Se={class:"title is-4 has-text-grey-light"},je={class:"about-debug box is-family-monospace is-size-7"},Ae=["value"],Re={class:"has-text-grey"},qe={class:"title is-4 has-text-danger"},We={class:"is-left-bordered-danger"},De={class:"block is-size-6 is-size-7-mobile"},Oe={class:"is-block has-text-grey has-text-weight-bold"},Ze={__name:"Manage",props:{userId:[Number,String]},setup(B){const c=Y(),I=G(),$=J(),E=se(),x=K("2fauth"),y=b(!1),t=b(null),z=b(null),C=b(!1),w=B;Q(async()=>{await H()});async function H(){y.value=!0,h.getById(w.userId,{returnError:!0}).then(e=>{t.value=e.data,E.username=t.value.info.name}).catch(e=>{c.error(e)}).finally(()=>{y.value=!1})}async function P(){if(!g())return!1;confirm(u("admin.confirm.purge_password_reset_request"))===!0&&(await h.resendPasswordEmail(t.value.info.id),t.value.password_reset=null)}async function U(){if(!g())return!1;confirm(u("admin.confirm.request_password_reset"))===!0&&h.resetPassword(t.value.info.id,{returnError:!0}).then(e=>{t.value=e.data,c.success({text:u("admin.password_successfully_reset")})}).catch(e=>{e.response.status===400?c.alert({text:e.response.data.reason}):c.error(e)})}function V(e){if(!confirm(u("admin.confirm.change_admin_role"))){M().then(()=>{t.value.info.is_admin=!e});return}if(e===!1&&t.value.info.id===$.id&&!confirm(u("admin.confirm.demote_own_account"))){M().then(()=>{t.value.info.is_admin=!0});return}h.promote(t.value.info.id,{is_admin:e},{returnError:!0}).then(l=>{t.value.info.is_admin=l.data.info.is_admin,c.success({text:u("admin.user_role_updated")})}).catch(l=>{l.response.status===403?(c.alert({text:l.response.data.message}),t.value.info.is_admin=!0):c.error(l.response)})}function N(){if(!g())return!1;confirm(u("admin.confirm.delete_account"))&&h.delete(t.value.info.id,{returnError:!0}).then(e=>{c.success({text:u("auth.forms.user_account_successfully_deleted")}),I.push({name:"admin.users"})}).catch(e=>{e.response.status===403?c.alert({text:e.response.data.message}):c.error(e.response)})}function S(){if(!g())return!1;h.revokePATs(t.value.info.id).then(e=>{t.value.valid_personal_access_tokens=0,c.success({text:u("admin.pats_succesfully_revoked")})})}function g(){return!(t.value.info.id===$.id&&!confirm(u("admin.confirm.edit_own_account")))}return(e,l)=>{const j=f("FontAwesomeIcon"),A=f("FormCheckbox"),R=f("router-link"),T=f("ButtonBackCloseCancel"),q=f("VueFooter"),W=f("ResponsiveWidthWrapper");return o(),X(W,null,{default:m(()=>{var F;return[s("h1",te,n(e.$t("admin.user_management")),1),i(y)||!i(t)?(o(),r("div",ie,[s("span",ne,[d(j,{icon:["fas","spinner"],spin:""})])])):(o(),r("div",ae,[s("div",{class:p(["mb-6",i(t).info.is_admin?"is-left-bordered-warning":"is-left-bordered-link"])},[d(i(v),null,{default:m(({mode:a})=>[s("p",{class:p(["title is-4",{"has-text-grey-lighter":a=="dark"}])},[s("span",oe,"#"+n(i(t).info.id),1),k(n(i(t).info.name),1)],2)]),_:1}),s("p",re,n(i(t).info.email),1)],2),i(t).info.oauth_provider?(o(),r("div",le,n(e.$t("admin.account_bound_to_x_via_oauth",{provider:i(t).info.oauth_provider})),1)):_("",!0),s("div",de,n(e.$t("admin.registered_on_date",{date:i(t).info.created_at}))+" - "+n(e.$t("admin.last_seen_on_date",{date:i(t).info.last_seen_at})),1),s("div",ce,[d(A,{modelValue:i(t).info.is_admin,"onUpdate:modelValue":[l[0]||(l[0]=a=>i(t).info.is_admin=a),l[1]||(l[1]=a=>V(a===!0))],fieldName:"is_admin",label:"admin.forms.is_admin.label",help:"admin.forms.is_admin.help"},null,8,["modelValue"])]),i(x).config.proxyAuth?_("",!0):(o(),r("h2",ue,n(e.$t("admin.access")),1)),i(x).config.proxyAuth?_("",!0):(o(),r("div",_e,[s("div",me,[s("div",he,[s("div",null,[s("span",fe,n(e.$t("auth.forms.password")),1)]),s("div",null,[s("div",pe,[d(i(v),null,{default:m(({mode:a})=>[i(t).password_reset?(o(),r("button",{key:0,class:p(["button tag is-pulled-right",a=="dark"?"is-dark has-background-link":"is-white"]),onClick:P,title:e.$t("admin.resend_email_title")},n(e.$t("admin.resend_email")),11,ke)):_("",!0),s("button",{class:p(["button tag is-pulled-right",a=="dark"?"is-dark has-background-link":"is-white"]),onClick:U,title:e.$t("admin.reset_password_title")},n(e.$t("admin.reset_password")),11,ge)]),_:1})])])]),s("div",be,[i(t).password_reset===0?(o(),r("span",{key:0,innerHTML:e.$t("admin.password_request_expired"),class:"is-block block"},null,8,ve)):i(t).password_reset?(o(),r("span",{key:1,innerHTML:e.$t("admin.password_requested_on_t",{datetime:i(t).password_reset}),class:"is-block block"},null,8,ye)):_("",!0),i(t).password_reset?(o(),r("span",{key:2,innerHTML:e.$t("admin.resend_email_help"),class:"is-block block"},null,8,we)):_("",!0),s("span",{innerHTML:e.$t("admin.reset_password_help"),class:"is-block block"},null,8,$e)])]),s("div",xe,[s("div",null,[s("span",ze,n(e.$t("settings.personal_access_tokens")),1),s("span",Ce,n(e.$t("admin.user_has_x_active_pat",{count:i(t).valid_personal_access_tokens})),1)]),i(t).valid_personal_access_tokens>0?(o(),r("div",Te,[s("div",Fe,[d(i(v),null,{default:m(({mode:a})=>[s("button",{class:p(["button tag is-pulled-right",a=="dark"?"is-dark has-background-link":"is-white"]),onClick:S,title:e.$t("admin.revoke_all_pat_for_user")},n(e.$t("settings.revoke")),11,Le)]),_:1})])])):_("",!0)]),s("div",Me,[s("div",null,[s("span",Be,n(e.$t("auth.webauthn.security_devices")),1),s("span",Ie,n(e.$t("admin.user_has_x_security_devices",{count:i(t).webauthn_credentials})),1)]),i(t).webauthn_credentials>0?(o(),r("div",Ee,[s("div",He,[d(i(v),null,{default:m(({mode:a})=>[s("button",{class:p(["button tag is-pulled-right",a=="dark"?"is-dark has-background-link":"is-white"]),title:e.$t("admin.revoke_all_devices_for_user")},n(e.$t("settings.revoke")),11,Pe)]),_:1})])])):_("",!0)])])),s("div",Ue,[s("h3",Ve,n(e.$t("admin.last_accesses")),1),d(O,{userId:w.userId,lastOnly:!0,onHasMoreEntries:l[2]||(l[2]=a=>C.value=!0)},null,8,["userId"])]),i(C)?(o(),r("div",Ne,[k(n(e.$t("admin.access_log_has_more_entries"))+" ",1),d(R,{id:"lnkFullLogs",to:{name:"admin.logs.access",params:{userId:w.userId}}},{default:m(()=>[k(n(e.$t("admin.see_full_log"))+". ",1)]),_:1},8,["to"])])):_("",!0),s("h2",Se,n(e.$t("settings.preferences")),1),s("div",je,[d(D,{id:"btnCopyEnvVars",token:(F=i(z))==null?void 0:F.innerText},null,8,["token"]),s("ul",{ref_key:"listUserPreferences",ref:z,id:"listUserPreferences"},[(o(!0),r(Z,null,ee(i(t).info.preferences,(a,L)=>(o(),r("li",{value:a,key:L},[s("b",null,n(L),1),k(": "),s("span",Re,n(a),1)],8,Ae))),128))],512)]),s("h2",qe,n(e.$t("admin.danger_zone")),1),s("div",We,[s("div",De,[k(n(e.$t("admin.delete_this_user_legend"))+" ",1),s("span",Oe,n(e.$t("admin.this_is_not_soft_delete")),1)]),s("button",{class:"button is-danger",onClick:N,title:"delete"},n(e.$t("admin.delete_this_user")),1)])])),d(q,{showButtons:!0},{default:m(()=>[d(T,{returnTo:{name:"admin.users"},action:"back"},null,8,["returnTo"]),d(T,{returnTo:{name:"accounts"},action:"close"})]),_:1})]}),_:1})}}};export{Ze as default};