mirror of
https://github.com/hcengineering/platform.git
synced 2024-11-22 03:14:40 +03:00
Add accessDenied error (#5788)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
parent
fb7679ae5b
commit
8b87de46c8
@ -56,7 +56,7 @@ import {
|
||||
type TabItem
|
||||
} from '@hcengineering/ui'
|
||||
import view, { type Filter } from '@hcengineering/view'
|
||||
import { FilterQuery } from '@hcengineering/view-resources'
|
||||
import { FilterQuery, accessDeniedStore } from '@hcengineering/view-resources'
|
||||
import { derived, get, writable } from 'svelte/store'
|
||||
|
||||
import contact from './plugin'
|
||||
@ -262,6 +262,7 @@ async function generateLocation (loc: Location, id: Ref<Contact>): Promise<Resol
|
||||
const client = getClient()
|
||||
const doc = await client.findOne(contact.class.Contact, { _id: id })
|
||||
if (doc === undefined) {
|
||||
accessDeniedStore.set(true)
|
||||
console.error(`Could not find contact ${id}.`)
|
||||
return undefined
|
||||
}
|
||||
|
@ -11,19 +11,20 @@
|
||||
//
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
import slugify from 'slugify'
|
||||
import { type Ref, type Client, type Doc } from '@hcengineering/core'
|
||||
import { getClient } from '@hcengineering/presentation'
|
||||
import { type Location, type ResolvedLocation, getCurrentResolvedLocation, getPanelURI } from '@hcengineering/ui'
|
||||
import view, { type ObjectPanel } from '@hcengineering/view'
|
||||
import documents, {
|
||||
documentsId,
|
||||
getDocumentId,
|
||||
type ControlledDocument,
|
||||
type Document,
|
||||
type Project,
|
||||
type ProjectDocument,
|
||||
documentsId,
|
||||
getDocumentId
|
||||
type ProjectDocument
|
||||
} from '@hcengineering/controlled-documents'
|
||||
import { type Client, type Doc, type Ref } from '@hcengineering/core'
|
||||
import { getClient } from '@hcengineering/presentation'
|
||||
import { getCurrentResolvedLocation, getPanelURI, type Location, type ResolvedLocation } from '@hcengineering/ui'
|
||||
import view, { type ObjectPanel } from '@hcengineering/view'
|
||||
import { accessDeniedStore } from '@hcengineering/view-resources'
|
||||
import slugify from 'slugify'
|
||||
|
||||
export function getPanelFragment<T extends Doc> (object: Pick<T, '_class' | '_id'>): string {
|
||||
const hierarchy = getClient().getHierarchy()
|
||||
@ -40,6 +41,7 @@ async function generateDocumentLocation (
|
||||
|
||||
const doc = await client.findOne(documents.class.ControlledDocument, { _id: document })
|
||||
if (doc === undefined) {
|
||||
accessDeniedStore.set(true)
|
||||
console.error(`Could not find document ${document}.`)
|
||||
return undefined
|
||||
}
|
||||
@ -68,12 +70,14 @@ async function generateProjectDocumentLocation (
|
||||
|
||||
const doc = await client.findOne(documents.class.ControlledDocument, { _id: document })
|
||||
if (doc === undefined) {
|
||||
accessDeniedStore.set(true)
|
||||
console.error(`Could not find document ${document}.`)
|
||||
return undefined
|
||||
}
|
||||
|
||||
const prjdoc = await client.findOne(documents.class.ProjectDocument, { document, project })
|
||||
if (prjdoc === undefined) {
|
||||
accessDeniedStore.set(true)
|
||||
console.error(`Could not find project document ${project} ${document}.`)
|
||||
return undefined
|
||||
}
|
||||
|
@ -14,20 +14,21 @@
|
||||
//
|
||||
|
||||
import {
|
||||
getCollaborativeDoc,
|
||||
getCollaborativeDocId,
|
||||
type AttachedData,
|
||||
type Client,
|
||||
type Ref,
|
||||
type TxOperations,
|
||||
getCollaborativeDoc,
|
||||
getCollaborativeDocId
|
||||
type TxOperations
|
||||
} from '@hcengineering/core'
|
||||
import { type Document, type Teamspace, documentId } from '@hcengineering/document'
|
||||
import { documentId, type Document, type Teamspace } from '@hcengineering/document'
|
||||
import { getMetadata, translate } from '@hcengineering/platform'
|
||||
import presentation, { getClient } from '@hcengineering/presentation'
|
||||
import { type Location, type ResolvedLocation, getCurrentResolvedLocation, getPanelURI } from '@hcengineering/ui'
|
||||
import { getCurrentResolvedLocation, getPanelURI, type Location, type ResolvedLocation } from '@hcengineering/ui'
|
||||
import { workbenchId } from '@hcengineering/workbench'
|
||||
import slugify from 'slugify'
|
||||
|
||||
import { accessDeniedStore } from '@hcengineering/view-resources'
|
||||
import document from './plugin'
|
||||
|
||||
export async function createEmptyDocument (
|
||||
@ -83,6 +84,7 @@ export async function generateLocation (loc: Location, id: Ref<Document>): Promi
|
||||
|
||||
const doc = await client.findOne(document.class.Document, { _id: id })
|
||||
if (doc === undefined) {
|
||||
accessDeniedStore.set(true)
|
||||
console.error(`Could not find document ${id}.`)
|
||||
return undefined
|
||||
}
|
||||
|
@ -14,10 +14,11 @@
|
||||
//
|
||||
|
||||
import type { Doc, Ref } from '@hcengineering/core'
|
||||
import drive, { type Drive, type Folder, driveId } from '@hcengineering/drive'
|
||||
import drive, { driveId, type Drive, type Folder } from '@hcengineering/drive'
|
||||
import { getClient } from '@hcengineering/presentation'
|
||||
import { type Location, type ResolvedLocation, getCurrentResolvedLocation, getPanelURI } from '@hcengineering/ui'
|
||||
import { getCurrentResolvedLocation, getPanelURI, type Location, type ResolvedLocation } from '@hcengineering/ui'
|
||||
import view, { type ObjectPanel } from '@hcengineering/view'
|
||||
import { accessDeniedStore } from '@hcengineering/view-resources'
|
||||
|
||||
export function getPanelFragment<T extends Doc> (object: Pick<T, '_class' | '_id'>): string {
|
||||
const hierarchy = getClient().getHierarchy()
|
||||
@ -77,6 +78,7 @@ export async function generateFolderLocation (loc: Location, id: Ref<Folder>): P
|
||||
|
||||
const doc = await client.findOne(drive.class.Folder, { _id: id })
|
||||
if (doc === undefined) {
|
||||
accessDeniedStore.set(true)
|
||||
console.error(`Could not find folder ${id}.`)
|
||||
return undefined
|
||||
}
|
||||
@ -101,6 +103,7 @@ export async function generateDriveLocation (loc: Location, id: Ref<Drive>): Pro
|
||||
|
||||
const doc = await client.findOne(drive.class.Drive, { _id: id })
|
||||
if (doc === undefined) {
|
||||
accessDeniedStore.set(true)
|
||||
console.error(`Could not find drive ${id}.`)
|
||||
return undefined
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
import { type Person, type PersonAccount } from '@hcengineering/contact'
|
||||
import { getCurrentAccount, type Ref } from '@hcengineering/core'
|
||||
import { createQuery, getClient } from '@hcengineering/presentation'
|
||||
import {
|
||||
RequestStatus,
|
||||
type DevicesPreference,
|
||||
@ -11,6 +10,7 @@ import {
|
||||
type ParticipantInfo,
|
||||
type Room
|
||||
} from '@hcengineering/love'
|
||||
import { createQuery, getClient } from '@hcengineering/presentation'
|
||||
import { derived, writable } from 'svelte/store'
|
||||
import love from './plugin'
|
||||
|
||||
|
@ -12,6 +12,7 @@ import {
|
||||
} from '@hcengineering/recruit'
|
||||
import { getCurrentResolvedLocation, getPanelURI, type Location, type ResolvedLocation } from '@hcengineering/ui'
|
||||
import view from '@hcengineering/view'
|
||||
import { accessDeniedStore } from '@hcengineering/view-resources'
|
||||
import { workbenchId } from '@hcengineering/workbench'
|
||||
import recruit from './plugin'
|
||||
|
||||
@ -67,6 +68,7 @@ async function generateIdLocation (loc: Location, shortLink: string): Promise<Re
|
||||
}
|
||||
const doc = await client.findOne(_class, { _id: _id as Ref<Doc> })
|
||||
if (doc === undefined) {
|
||||
accessDeniedStore.set(true)
|
||||
console.error(`Could not find ${_class} with id ${_id}.`)
|
||||
return undefined
|
||||
}
|
||||
@ -113,6 +115,7 @@ async function generateLocation (loc: Location, shortLink: string): Promise<Reso
|
||||
}
|
||||
const doc = await client.findOne(_class, { number })
|
||||
if (doc === undefined) {
|
||||
accessDeniedStore.set(true)
|
||||
console.error(`Could not find ${_class} with number ${number}.`)
|
||||
return undefined
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ import { getMetadata } from '@hcengineering/platform'
|
||||
import presentation, { getClient } from '@hcengineering/presentation'
|
||||
import { trackerId, type Component, type Issue, type Milestone } from '@hcengineering/tracker'
|
||||
import { getCurrentResolvedLocation, getPanelURI, type Location, type ResolvedLocation } from '@hcengineering/ui'
|
||||
import { accessDeniedStore } from '@hcengineering/view-resources'
|
||||
import { workbenchId } from '@hcengineering/workbench'
|
||||
import { writable } from 'svelte/store'
|
||||
import tracker from './plugin'
|
||||
@ -73,6 +74,7 @@ export async function generateIssueLocation (loc: Location, issueId: string): Pr
|
||||
const client = getClient()
|
||||
const issue = await client.findOne(tracker.class.Issue, { identifier: issueId })
|
||||
if (issue === undefined) {
|
||||
accessDeniedStore.set(true)
|
||||
console.error(`Could not find issue ${issueId}.`)
|
||||
return undefined
|
||||
}
|
||||
|
@ -1375,6 +1375,8 @@ export function checkMyPermission (_id: Ref<Permission>, space: Ref<TypedSpace>,
|
||||
return (store.whitelist.has(space) || store.ps[space]?.has(_id)) ?? false
|
||||
}
|
||||
|
||||
export const accessDeniedStore = writable<boolean>(false)
|
||||
|
||||
export const permissionsStore = writable<PermissionsStore>({
|
||||
ps: {},
|
||||
ap: {},
|
||||
|
@ -27,6 +27,7 @@
|
||||
"ServerUnderMaintenance": "Server is under maintenance",
|
||||
"MobileNotSupported": "Sorry, mobile devices support coming soon. In the meantime, please use Desktop",
|
||||
"LogInAnyway": "Log in anyway",
|
||||
"WorkspaceCreating": "Creation in progress..."
|
||||
"WorkspaceCreating": "Creation in progress...",
|
||||
"AccessDenied": "Object doesn't exist or you are not permitted to access it."
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,7 @@
|
||||
"ServerUnderMaintenance": "El servidor está en mantenimiento",
|
||||
"MobileNotSupported": "Disculpa, el soporte para dispositivos móviles estará disponible próximamente. Mientras tanto, por favor usa el escritorio.",
|
||||
"LogInAnyway": "Iniciar sesión de todas formas",
|
||||
"WorkspaceCreating": "Creation in progress..."
|
||||
"WorkspaceCreating": "Creation in progress...",
|
||||
"AccessDenied": "El objeto no existe o no tienes permiso para acceder a él."
|
||||
}
|
||||
}
|
@ -27,6 +27,7 @@
|
||||
"ServerUnderMaintenance": "Servidor em manutenção",
|
||||
"MobileNotSupported": "Desculpe, o suporte para dispositivos móveis estará disponível em breve. Enquanto isso, por favor, use o Desktop.",
|
||||
"LogInAnyway": "Entrar de qualquer maneira",
|
||||
"WorkspaceCreating": "Creation in progress..."
|
||||
"WorkspaceCreating": "Creation in progress...",
|
||||
"AccessDenied": "O objeto não existe ou você não tem permissão para acessá-lo."
|
||||
}
|
||||
}
|
@ -27,6 +27,7 @@
|
||||
"ServerUnderMaintenance": "Обслуживание сервера",
|
||||
"MobileNotSupported": "Простите, поддержка мобильных устройств скоро будет доступна. Пока воспользуйтесь компьютером.",
|
||||
"LogInAnyway": "Все равно войти",
|
||||
"WorkspaceCreating": "Пространство создается..."
|
||||
"WorkspaceCreating": "Пространство создается...",
|
||||
"AccessDenied": "Объект не существует или у вас нет прав доступа."
|
||||
}
|
||||
}
|
||||
|
@ -65,6 +65,7 @@
|
||||
ActionHandler,
|
||||
ListSelectionProvider,
|
||||
NavLink,
|
||||
accessDeniedStore,
|
||||
migrateViewOpttions,
|
||||
updateFocus
|
||||
} from '@hcengineering/view-resources'
|
||||
@ -282,6 +283,7 @@
|
||||
}
|
||||
|
||||
async function syncLoc (loc: Location): Promise<void> {
|
||||
accessDeniedStore.set(false)
|
||||
const originalLoc = JSON.stringify(loc)
|
||||
|
||||
if (loc.path.length > 3 && getSpecialComponent(loc.path[3]) === undefined) {
|
||||
@ -412,6 +414,7 @@
|
||||
(props[4] ?? undefined) as AnyComponent
|
||||
)
|
||||
} else {
|
||||
accessDeniedStore.set(true)
|
||||
closePanel(false)
|
||||
}
|
||||
} else {
|
||||
@ -799,6 +802,10 @@
|
||||
is={currentView.component}
|
||||
props={{ ...currentView.componentProps, currentView, visibleNav, navFloat, appsDirection }}
|
||||
/>
|
||||
{:else if $accessDeniedStore}
|
||||
<div class="flex-center h-full">
|
||||
<h2><Label label={workbench.string.AccessDenied} /></h2>
|
||||
</div>
|
||||
{:else}
|
||||
<SpaceView {currentSpace} {currentView} {createItemDialog} {createItemLabel} />
|
||||
{/if}
|
||||
|
@ -44,7 +44,8 @@ export default mergeIds(workbenchId, workbench, {
|
||||
PleaseUpdate: '' as IntlString,
|
||||
MobileNotSupported: '' as IntlString,
|
||||
LogInAnyway: '' as IntlString,
|
||||
WorkspaceCreating: '' as IntlString
|
||||
WorkspaceCreating: '' as IntlString,
|
||||
AccessDenied: '' as IntlString
|
||||
},
|
||||
metadata: {
|
||||
MobileAllowed: '' as Metadata<boolean>
|
||||
|
Loading…
Reference in New Issue
Block a user