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

1 line
17 KiB
Plaintext

{"version":3,"file":"Manage-CqjY5Ai2.js","sources":["../../../resources/js/views/admin/users/Manage.vue"],"sourcesContent":["<script setup>\n import CopyButton from '@/components/CopyButton.vue'\n import AccessLogViewer from '@/components/AccessLogViewer.vue'\n import userService from '@/services/userService'\n import { useNotifyStore } from '@/stores/notify'\n import { UseColorMode } from '@vueuse/components'\n import { useUserStore } from '@/stores/user'\n import { useBusStore } from '@/stores/bus'\n\n const notify = useNotifyStore()\n const router = useRouter()\n const user = useUserStore()\n const bus = useBusStore()\n const $2fauth = inject('2fauth')\n\n const isFetching = ref(false)\n const managedUser = ref(null)\n const listUserPreferences = ref(null)\n const showFullLogLink = ref(false)\n\n const props = defineProps({\n userId: [Number, String]\n })\n\n onMounted(async () => {\n await getUser()\n })\n\n /**\n * Gets the user from backend\n */\n async function getUser() {\n isFetching.value = true\n\n userService.getById(props.userId, {returnError: true})\n .then(response => {\n managedUser.value = response.data\n bus.username = managedUser.value.info.name\n })\n .catch(error => {\n notify.error(error)\n })\n .finally(() => {\n isFetching.value = false\n })\n }\n\n /**\n * Resends a pwd reset email to the user\n */\n async function resendPasswordEmail() {\n if (! confirmForYourself()) {\n return false\n }\n \n if (confirm(trans('admin.confirm.purge_password_reset_request')) === true) {\n await userService.resendPasswordEmail(managedUser.value.info.id)\n managedUser.value.password_reset = null\n }\n }\n\n /**\n * Resets the user password\n */\n async function resetPassword() {\n if (! confirmForYourself()) {\n return false\n }\n\n if (confirm(trans('admin.confirm.request_password_reset')) === true) {\n userService.resetPassword(managedUser.value.info.id, { returnError: true })\n .then(response => {\n managedUser.value = response.data\n notify.success({ text: trans('admin.password_successfully_reset') })\n })\n .catch(error => {\n if(error.response.status === 400) {\n notify.alert({ text: error.response.data.reason })\n }\n else notify.error(error)\n })\n }\n }\n\n /**\n * Set admin role\n * \n * @param {string} preference \n * @param {boolean} isAdmin \n */\n function saveAdminRole(isAdmin) {\n if (! confirm(trans('admin.confirm.change_admin_role'))) {\n nextTick().then(() => {\n managedUser.value.info.is_admin = ! isAdmin\n })\n return\n }\n\n if(isAdmin === false && managedUser.value.info.id === user.id) {\n if (! confirm(trans('admin.confirm.demote_own_account'))) {\n nextTick().then(() => {\n managedUser.value.info.is_admin = true\n })\n return\n }\n }\n\n userService.promote(managedUser.value.info.id, { 'is_admin': isAdmin }, { returnError: true }).then(response => {\n managedUser.value.info.is_admin = response.data.info.is_admin\n notify.success({ text: trans('admin.user_role_updated') })\n })\n .catch(error => {\n if( error.response.status === 403 ) {\n notify.alert({ text: error.response.data.message })\n managedUser.value.info.is_admin = true\n }\n else {\n notify.error(error.response)\n }\n })\n }\n\n /**\n * submit user account deletion\n */\n function deleteUser() {\n if (! confirmForYourself()) {\n return false\n }\n\n if(confirm(trans('admin.confirm.delete_account'))) {\n userService.delete(managedUser.value.info.id, { returnError: true }).then(response => {\n notify.success({ text: trans('auth.forms.user_account_successfully_deleted') })\n router.push({ name: 'admin.users' });\n })\n .catch(error => {\n if( error.response.status === 403 ) {\n notify.alert({ text: error.response.data.message })\n }\n else {\n notify.error(error.response)\n }\n })\n }\n }\n\n /**\n * submit user account deletion\n */\n function revokePATs() {\n if (! confirmForYourself()) {\n return false\n }\n\n userService.revokePATs(managedUser.value.info.id).then(response => {\n managedUser.value.valid_personal_access_tokens = 0\n notify.success({ text: trans('admin.pats_succesfully_revoked') })\n })\n }\n\n /**\n * submit user account deletion\n */\n function revokeWebauthnCredentials() {\n if (! confirmForYourself()) {\n return false\n }\n\n userService.revokeWebauthnCredentials(managedUser.value.info.id).then(response => {\n managedUser.value.valid_personal_access_tokens = 0\n notify.success({ text: trans('admin.security_devices_succesfully_revoked') })\n })\n }\n\n /**\n * Confirmation for modification on own account\n */\n function confirmForYourself() {\n if(managedUser.value.info.id === user.id) {\n if (! confirm(trans('admin.confirm.edit_own_account'))) {\n return false\n }\n }\n return true\n }\n \n</script>\n\n\n<template>\n <UseColorMode v-slot=\"{ mode }\">\n <ResponsiveWidthWrapper>\n <h1 class=\"title has-text-grey-dark mb-6\">\n {{ $t('admin.user_management') }}\n </h1>\n <!-- loader -->\n <div v-if=\"isFetching || ! managedUser\" class=\"has-text-centered\">\n <span class=\"is-size-4\">\n <FontAwesomeIcon :icon=\"['fas', 'spinner']\" spin />\n </span>\n </div>\n <div v-else>\n <div class=\"mb-6\" :class=\"managedUser.info.is_admin ? 'is-left-bordered-warning' : 'is-left-bordered-link'\">\n <p class=\"title is-4\" :class=\"{ 'has-text-grey-lighter' : mode == 'dark' }\">\n <span class=\"has-text-weight-light has-text-grey-dark is-pulled-right\">#{{ managedUser.info.id }}</span>{{ managedUser.info.name }}</p>\n <p class=\"subtitle is-6 block\">{{ managedUser.info.email }}</p>\n </div>\n <!-- oauth banner -->\n <div v-if=\"managedUser.info.oauth_provider\" class=\"notification is-dark is-size-7-mobile has-text-centered\">\n {{ $t('admin.account_bound_to_x_via_oauth', { provider: managedUser.info.oauth_provider }) }}\n </div>\n <div class=\"block is-size-6 is-size-7-mobile has-text-grey\">\n {{ $t('admin.registered_on_date', { date: managedUser.info.created_at }) }} - {{ $t('admin.last_seen_on_date', { date: managedUser.info.last_seen_at }) }}\n </div>\n <!-- isAdmin option -->\n <div class=\"block\">\n <FormCheckbox v-model=\"managedUser.info.is_admin\" @update:model-value=\"val => saveAdminRole(val === true)\" fieldName=\"is_admin\" label=\"admin.forms.is_admin.label\" help=\"admin.forms.is_admin.help\" />\n </div>\n <h2 v-if=\"!$2fauth.config.proxyAuth\" class=\"title is-4 has-text-grey-light\">{{ $t('admin.access') }}</h2>\n <!-- access -->\n <div v-if=\"!$2fauth.config.proxyAuth\" class=\"block\">\n <!-- reset password -->\n <div class=\"list-item is-size-6 is-size-6-mobile has-text-grey\">\n <div class=\"mb-3 is-flex is-justify-content-space-between\">\n <div>\n <span class=\"has-text-weight-bold\">{{ $t('auth.forms.password') }}</span>\n </div>\n <div>\n <div class=\"tags ml-3 is-right\">\n <!-- resend email button -->\n <button type=\"button\" v-if=\"managedUser.password_reset\" class=\"button tag is-pulled-right\" :class=\"mode == 'dark' ? 'is-dark has-background-link' : 'is-white'\" @click=\"resendPasswordEmail\" :title=\"$t('admin.resend_email_title')\">\n {{ $t('admin.resend_email') }}\n </button>\n <!-- reset password button -->\n <button type=\"button\" class=\"button tag is-pulled-right \" :class=\"mode == 'dark' ? 'is-dark has-background-link' : 'is-white'\" @click=\"resetPassword\" :title=\"$t('admin.reset_password_title')\">\n {{ $t('admin.reset_password') }}\n </button>\n </div>\n </div>\n </div>\n <div class=\"is-size-7 is-size-7-mobile has-text-grey-dark\">\n <span v-if=\"managedUser.password_reset === 0\" v-html=\"$t('admin.password_request_expired')\" class=\"is-block block\"></span>\n <span v-else-if=\"managedUser.password_reset\" v-html=\"$t('admin.password_requested_on_t', { datetime: managedUser.password_reset })\" class=\"is-block block\"></span>\n <span v-if=\"managedUser.password_reset\" v-html=\"$t('admin.resend_email_help')\" class=\"is-block block\"></span>\n <span v-html=\"$t('admin.reset_password_help')\" class=\"is-block block\"></span>\n </div>\n </div>\n <!-- personal access tokens -->\n <div class=\"list-item is-size-6 is-size-6-mobile has-text-grey is-flex is-justify-content-space-between\">\n <div>\n <span class=\"has-text-weight-bold\">{{ $t('settings.personal_access_tokens') }}</span>\n <span class=\"is-block is-family-primary has-text-grey-dark\">\n {{ $t('admin.user_has_x_active_pat', { count: managedUser.valid_personal_access_tokens }) }}\n </span>\n </div>\n <div v-if=\"managedUser.valid_personal_access_tokens > 0\">\n <div class=\"tags ml-3 is-right\">\n <!-- manage link -->\n <button type=\"button\" class=\"button tag is-pulled-right\" :class=\"mode == 'dark' ? 'is-dark has-background-link' : 'is-white'\" @click=\"revokePATs\" :title=\"$t('admin.revoke_all_pat_for_user')\">\n {{ $t('settings.revoke') }}\n </button>\n </div>\n </div>\n </div>\n <!-- webauthn devices -->\n <div class=\"list-item is-size-6 is-size-6-mobile has-text-grey is-flex is-justify-content-space-between\">\n <div>\n <span class=\"has-text-weight-bold\">{{ $t('auth.webauthn.security_devices') }}</span>\n <span class=\"is-block has-text-grey-dark\">\n {{ $t('admin.user_has_x_security_devices', { count: managedUser.webauthn_credentials }) }}\n </span>\n </div>\n <div v-if=\"managedUser.webauthn_credentials > 0\">\n <div class=\"tags ml-3 is-right\">\n <!-- manage link -->\n <button type=\"button\" class=\"button tag is-pulled-right\" :class=\"mode == 'dark' ? 'is-dark has-background-link' : 'is-white'\" :title=\"$t('admin.revoke_all_devices_for_user')\">\n {{ $t('settings.revoke') }}\n </button>\n </div>\n </div>\n </div>\n </div>\n <!-- last access -->\n <div class=\"block\">\n <h3 class=\"title is-5 has-text-grey-light mb-2\">{{ $t('admin.last_accesses') }}</h3>\n <AccessLogViewer :userId=\"props.userId\" :lastOnly=\"true\" @has-more-entries=\"showFullLogLink = true\"/>\n </div>\n <div v-if=\"showFullLogLink\" class=\"block is-size-6 is-size-7-mobile has-text-grey\">\n {{ $t('admin.access_log_has_more_entries') }} <router-link id=\"lnkFullLogs\" :to=\"{ name: 'admin.logs.access', params: { userId: props.userId }}\" >\n {{ $t('admin.see_full_log') }}.\n </router-link>\n </div>\n <!-- preferences -->\n <h2 class=\"title is-4 has-text-grey-light\">{{ $t('settings.preferences') }}</h2>\n <div class=\"about-debug box is-family-monospace is-size-7\">\n <CopyButton id=\"btnCopyEnvVars\" :token=\"listUserPreferences?.innerText\" />\n <ul ref=\"listUserPreferences\" id=\"listUserPreferences\">\n <li v-for=\"(value, preference) in managedUser.info.preferences\" :value=\"value\" :key=\"preference\">\n <b>{{preference}}</b>: <span class=\"has-text-grey\">{{value}}</span>\n </li>\n </ul>\n </div>\n <!-- danger zone -->\n <h2 class=\"title is-4 has-text-danger\">{{ $t('admin.danger_zone') }}</h2>\n <div class=\"is-left-bordered-danger\">\n <div class=\"block is-size-6 is-size-7-mobile\">\n {{ $t('admin.delete_this_user_legend') }}\n <span class=\"is-block has-text-grey has-text-weight-bold\">\n {{ $t('admin.this_is_not_soft_delete') }}\n </span>\n </div>\n <button type=\"button\" class=\"button is-danger\" @click=\"deleteUser\" title=\"delete\">\n {{ $t('admin.delete_this_user') }}\n </button>\n </div>\n </div>\n <!-- footer -->\n <VueFooter :showButtons=\"true\">\n <ButtonBackCloseCancel :returnTo=\"{ name: 'admin.users' }\" action=\"back\" />\n <ButtonBackCloseCancel :returnTo=\"{ name: 'accounts' }\" action=\"close\" />\n </VueFooter>\n </ResponsiveWidthWrapper>\n </UseColorMode>\n</template>\n"],"names":["notify","useNotifyStore","router","useRouter","user","useUserStore","bus","useBusStore","$2fauth","inject","isFetching","ref","managedUser","listUserPreferences","showFullLogLink","props","__props","onMounted","getUser","userService","response","error","resendPasswordEmail","confirmForYourself","trans","resetPassword","saveAdminRole","isAdmin","nextTick","deleteUser","revokePATs"],"mappings":"8uEASI,MAAMA,EAASC,EAAc,EACvBC,EAASC,GAAS,EAClBC,EAAOC,EAAY,EACnBC,EAAMC,GAAW,EACjBC,EAAUC,GAAO,QAAQ,EAEzBC,EAAaC,EAAI,EAAK,EACtBC,EAAcD,EAAI,IAAI,EACtBE,EAAsBF,EAAI,IAAI,EAC9BG,EAAkBH,EAAI,EAAK,EAE3BI,EAAQC,EAIdC,EAAU,SAAY,CAClB,MAAMC,EAAO,CAChB,CAAA,EAKD,eAAeA,GAAU,CACrBR,EAAW,MAAQ,GAEnBS,EAAY,QAAQJ,EAAM,OAAQ,CAAC,YAAa,EAAI,CAAC,EACpD,KAAKK,GAAY,CACdR,EAAY,MAAQQ,EAAS,KAC7Bd,EAAI,SAAWM,EAAY,MAAM,KAAK,IACzC,CAAA,EACA,MAAMS,GAAS,CACZrB,EAAO,MAAMqB,CAAK,CACrB,CAAA,EACA,QAAQ,IAAM,CACXX,EAAW,MAAQ,EACtB,CAAA,CACT,CAKI,eAAeY,GAAsB,CACjC,GAAI,CAAEC,EAAkB,EACpB,MAAO,GAGP,QAAQC,EAAM,4CAA4C,CAAC,IAAM,KACjE,MAAML,EAAY,oBA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