2FAuth/public/build/assets/Manage-CqjY5Ai2.js.map

1 line
17 KiB
Plaintext
Raw Normal View History

2024-11-27 12:03:02 +01:00
{"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 (! con