2FAuth/public/build/assets/Manage-eb644258.js

2 lines
7.8 KiB
JavaScript
Raw Normal View History

2024-03-03 22:50:28 +01:00
import{_ as j}from"./CopyButton-346411c3.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-32c6ab3e.js";/*! 2FAuth version 5.0.4 - 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.update(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:""})])])):(