2FAuth/public/build/assets/Manage-BdbniM-Y.js

2 lines
8.6 KiB
JavaScript
Raw Normal View History

2024-11-17 23:37:23 +01:00
import{_ as D}from"./CopyButton-CNDtpSH2.js";import{_ as O}from"./AccessLogViewer-mgRyksdg.js";import{a as Y,u as G,r as b,o as J,I as h,h as K,k as m,l as f,m as o,e as s,t as n,f as i,d as r,j as d,n as p,g as k,U as v,i as _,F as Q,E as X,p as Z,L as ee,H as u,P as M}from"./app-D4Udf6Mm.js";import{u as se}from"./bus-RVphoWuw.js";import"./SearchBox-B-38rGG5.js";import"./Spinner-DHClvaFf.js";/*! 2FAuth version 5.4.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},Le={class:"tags ml-3 is-right"},Fe=["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"],qe={class:"has-text-grey"},Re={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=Z(),$=G(),E=se(),x=ee("2fauth"),y=b(!1),t=b(null),z=b(null),C=b(!1),w=B;J(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.inf