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

1 line
11 KiB
Plaintext

{"version":3,"file":"OAuth-B7q39fAh.js","sources":["../../../resources/js/views/settings/OAuth.vue"],"sourcesContent":["<script setup>\n import Form from '@/components/formElements/Form'\n import userService from '@/services/userService'\n import SettingTabs from '@/layouts/SettingTabs.vue'\n import { useNotifyStore } from '@/stores/notify'\n import { UseColorMode } from '@vueuse/components'\n import { useUserStore } from '@/stores/user'\n import Spinner from '@/components/Spinner.vue'\n\n const $2fauth = inject('2fauth')\n const notify = useNotifyStore()\n const user = useUserStore()\n const returnTo = useStorage($2fauth.prefix + 'returnTo', 'accounts')\n const { copy } = useClipboard({ legacy: true })\n\n const tokens = ref([])\n const isFetching = ref(false)\n const createPATModalIsVisible = ref(false)\n const visibleToken = ref(null)\n const visibleTokenId = ref(null)\n\n const isDisabled = computed(() => {\n return (appSettings.enableSso && appSettings.useSsoOnly) || user.authenticated_by_proxy\n })\n\n onMounted(() => {\n fetchTokens()\n })\n\n const form = reactive(new Form({\n name : '',\n }))\n\n /**\n * Get all groups from backend\n */\n function fetchTokens() {\n isFetching.value = true\n\n userService.getPersonalAccessTokens({returnError: true})\n .then(response => {\n tokens.value = []\n response.data.forEach((data) => {\n if (data.id === visibleTokenId.value) {\n data.value = visibleToken.value\n tokens.value.unshift(data)\n }\n else {\n tokens.value.push(data)\n }\n })\n })\n .catch(error => {\n if( error.response.status === 405 ) {\n // The backend returns a 405 response if the user is authenticated by a reverse proxy\n // or if SSO only is enabled.\n // The form is already disabled (see isDisabled) so we do nothing more here\n }\n else {\n notify.error(error)\n }\n })\n .finally(() => {\n isFetching.value = false\n visibleTokenId.value = null\n visibleToken.value = null\n })\n }\n\n\n /**\n * Open the PAT creation view\n */\n function showPATcreationForm() {\n clearTokenValues()\n\n if (isDisabled.value) {\n notify.warn({ text: trans('errors.unsupported_with_reverseproxy') })\n }\n else createPATModalIsVisible.value = true\n }\n \n /**\n * Generate a fresh token\n */\n function generatePAToken() {\n form.post('/oauth/personal-access-tokens')\n .then(response => {\n visibleToken.value = response.data.accessToken\n visibleTokenId.value = response.data.token.id\n fetchTokens()\n createPATModalIsVisible.value = false\n form.reset()\n })\n }\n\n /**\n * revoke a token (after confirmation)\n */\n function revokeToken(tokenId) {\n if(confirm(trans('settings.confirm.revoke'))) {\n userService.deletePersonalAccessToken(tokenId)\n .then(response => {\n // Remove the revoked token from the collection\n tokens.value = tokens.value.filter(a => a.id !== tokenId)\n notify.success({ text: trans('settings.token_revoked') })\n })\n }\n }\n\n /**\n * Removes visible tokens data\n */\n function clearTokenValues() {\n tokens.value.forEach(token => {\n token.value = null\n })\n visibleToken.value = null\n }\n\n /**\n * Copies data to clipboard and notifies on success\n */\n function copyToClipboard(data) {\n copy(data)\n notify.success({ text: trans('commons.copied_to_clipboard') })\n }\n\n /**\n * Closes & resets the PAT creation form \n */\n function cancelPATcreation() {\n createPATModalIsVisible.value = false\n form.reset()\n }\n\n onBeforeRouteLeave((to) => {\n if (! to.name.startsWith('settings.')) {\n notify.clear()\n }\n })\n</script>\n\n<template>\n <div>\n <SettingTabs :activeTab=\"'settings.oauth.tokens'\" />\n <div class=\"options-tabs\">\n <FormWrapper>\n <div v-if=\"isDisabled && user.oauth_provider\" class=\"notification is-warning has-text-centered\">\n {{ $t('auth.sso_only_x_settings_are_disabled', { auth_method: 'OAuth' }) }}\n </div>\n <div v-if=\"isDisabled && user.authenticated_by_proxy\" class=\"notification is-warning has-text-centered\" v-html=\"$t('auth.auth_handled_by_proxy')\" />\n <h4 class=\"title is-4 has-text-grey-light\">{{ $t('settings.personal_access_tokens') }}</h4>\n <div class=\"is-size-7-mobile\">\n {{ $t('settings.token_legend')}}\n </div>\n <div class=\"mt-3\">\n <a tabindex=\"0\" class=\"is-link\" @click=\"showPATcreationForm\" @keyup.enter=\"showPATcreationForm\">\n <FontAwesomeIcon :icon=\"['fas', 'plus-circle']\" /> {{ $t('settings.generate_new_token')}}\n </a>\n </div>\n <div v-if=\"tokens.length > 0\">\n <div v-for=\"token in tokens\" :key=\"token.id\" class=\"group-item is-size-5 is-size-6-mobile\">\n <FontAwesomeIcon v-if=\"token.value\" class=\"has-text-success\" :icon=\"['fas', 'check']\" /> {{ token.name }}\n <!-- revoke link -->\n <div class=\"tags is-pulled-right\">\n <UseColorMode v-slot=\"{ mode }\">\n <button type=\"button\" v-if=\"token.value\" class=\"button tag\" :class=\"{'is-link': mode != 'dark'}\" @click.stop=\"copyToClipboard(token.value)\">\n {{ $t('commons.copy') }}\n </button>\n <button type=\"button\" class=\"button tag\" :class=\"mode === 'dark' ? 'is-dark':'is-white'\" @click=\"revokeToken(token.id)\" :title=\"$t('settings.revoke')\">\n {{ $t('settings.revoke') }}\n </button>\n </UseColorMode>\n </div>\n <!-- warning msg -->\n <span v-if=\"token.value\" class=\"is-size-7-mobile is-size-6 my-3\">\n {{ $t('settings.make_sure_copy_token') }}\n </span>\n <!-- token value -->\n <span v-if=\"token.value\" class=\"pat is-family-monospace is-size-6 is-size-7-mobile has-text-success\">\n {{ token.value }}\n </span>\n </div>\n <div class=\"mt-2 is-size-7 is-pulled-right\">\n {{ $t('settings.revoking_a_token_is_permanent')}}\n </div>\n </div>\n <Spinner :isVisible=\"isFetching && tokens.length === 0\" />\n <!-- footer -->\n <VueFooter :showButtons=\"true\">\n <ButtonBackCloseCancel :returnTo=\"{ name: returnTo }\" action=\"close\" />\n </VueFooter>\n </FormWrapper>\n </div>\n <div v-if=\"createPATModalIsVisible\" class=\"is-overlay modal-otp modal-background\">\n <main class=\"main-section\">\n <FormWrapper title=\"settings.forms.new_token\">\n <form @submit.prevent=\"generatePAToken\" @keydown=\"form.onKeydown($event)\">\n <FormField v-model=\"form.name\" fieldName=\"name\" :fieldError=\"form.errors.get('name')\" inputType=\"text\" label=\"commons.name\" autofocus />\n <div class=\"field is-grouped\">\n <div class=\"control\">\n <VueButton :id=\"'btnGenerateToken'\" :isLoading=\"form.isBusy\" >\n {{ $t('commons.generate') }}\n </VueButton>\n </div>\n <div class=\"control\">\n <VueButton @click=\"cancelPATcreation\" :nativeType=\"'button'\" id=\"btnCancel\" :color=\"'is-text'\">\n {{ $t('commons.cancel') }}\n </VueButton>\n </div>\n </div>\n </form>\n </FormWrapper>\n </main>\n </div>\n </div>\n</template>\n"],"names":["$2fauth","inject","notify","useNotifyStore","user","useUserStore","returnTo","useStorage","copy","useClipboard","tokens","ref","isFetching","createPATModalIsVisible","visibleToken","visibleTokenId","isDisabled","computed","onMounted","fetchTokens","form","reactive","Form","userService","response","data","error","showPATcreationForm","clearTokenValues","trans","generatePAToken","revokeToken","tokenId","a","token","copyToClipboard","cancelPATcreation","onBeforeRouteLeave","to"],"mappings":"ilCASI,MAAMA,EAAUC,EAAO,QAAQ,EACzBC,EAASC,EAAc,EACvBC,EAAOC,EAAY,EACnBC,EAAWC,EAAWP,EAAQ,OAAS,WAAY,UAAU,EAC7D,CAAE,KAAAQ,CAAM,EAAGC,EAAa,CAAE,OAAQ,EAAM,CAAA,EAExCC,EAASC,EAAI,CAAE,CAAA,EACfC,EAAaD,EAAI,EAAK,EACtBE,EAA0BF,EAAI,EAAK,EACnCG,EAAeH,EAAI,IAAI,EACvBI,EAAiBJ,EAAI,IAAI,EAEzBK,EAAaC,EAAS,IAChB,YAAY,WAAa,YAAY,YAAeb,EAAK,sBACpE,EAEDc,EAAU,IAAM,CACZC,EAAW,CACd,CAAA,EAED,MAAMC,EAAOC,EAAS,IAAIC,GAAK,CAC3B,KAAO,EACf,CAAK,CAAC,EAKF,SAASH,GAAc,CACnBP,EAAW,MAAQ,GAEnBW,EAAY,wBAAwB,CAAC,YAAa,EAAI,CAAC,EACtD,KAAKC,GAAY,CACdd,EAAO,MAAQ,CAAA,EACfc,EAAS,KAAK,QAASC,GAAS,CACxBA,EAAK,KAAOV,EAAe,OAC3BU,EAAK,MAAQX,EAAa,MAC1BJ,EAAO,MAAM,QAAQe,CAAI,GAGzBf,EAAO,MAAM,KAAKe,CAAI,CAE7B,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