2FAuth/public/build/assets/Manage-CqjY5Ai2.js
2024-11-27 12:03:02 +01:00

3 lines
8.6 KiB
JavaScript
Vendored

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