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