Browse Source

fix(gui): show error message if user tried to access unauthorized project

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/4134/head
Pranav C 2 years ago
parent
commit
b110b9482a
  1. 7
      packages/nc-gui/lang/en.json
  2. 16
      packages/nc-gui/pages/[projectType]/[projectId]/index.vue

7
packages/nc-gui/lang/en.json

@ -105,8 +105,8 @@
"editor": "Editor",
"commenter": "Commenter",
"viewer": "Viewer",
"orgLevelCreator" : "Organization Level Creator",
"orgLevelViewer" : "Organization Level Viewer"
"orgLevelCreator": "Organization Level Creator",
"orgLevelViewer": "Organization Level Viewer"
},
"sqlVIew": "SQL View"
},
@ -663,7 +663,8 @@
"theAcceptedFileTypesAreXlsXlsxXlsmOdsOts": "The accepted file types are .xls, .xlsx, .xlsm, .ods, .ots",
"parameterKeyCannotBeEmpty": "Parameter key cannot be empty",
"duplicateParameterKeysAreNotAllowed": "Duplicate parameter keys are not allowed",
"fieldRequired": "{value} cannot be empty."
"fieldRequired": "{value} cannot be empty.",
"projectNotAccessible": "Project not accessible"
},
"toast": {
"exportMetadata": "Project metadata exported successfully",

16
packages/nc-gui/pages/[projectType]/[projectId]/index.vue

@ -24,6 +24,7 @@ import {
useUIPermission,
} from '#imports'
import { TabType } from '~/lib'
import { extractSdkResponseErrorMsg } from '~/utils'
definePageMeta({
hideHeader: true,
@ -152,7 +153,17 @@ onKeyStroke(
clearTabs()
onBeforeMount(async () => {
await loadProject()
try {
await loadProject()
} catch (e: any) {
if (e.response?.status === 403) {
// Project is not accessible
message.error(t('msg.error.projectNotAccessible'))
router.replace('/')
return
}
message.error(await extractSdkResponseErrorMsg(e))
}
if (!route.params.type && isUIAllowed('teamAndAuth')) {
addTab({ type: TabType.AUTH, title: t('title.teamAndAuth') })
@ -299,7 +310,8 @@ onBeforeUnmount(reset)
<!-- Copy Auth Token -->
<a-menu-item key="copy">
<div v-e="['a:navbar:user:copy-auth-token']" class="nc-project-menu-item group" @click.stop="copyAuthToken">
<div v-e="['a:navbar:user:copy-auth-token']" class="nc-project-menu-item group"
@click.stop="copyAuthToken">
<MdiScriptTextKeyOutline class="group-hover:text-accent" />
{{ $t('activity.account.authToken') }}
</div>

Loading…
Cancel
Save