Skip to content

πŸ“š The open-source, offline-first Notion, Obsidian & Confluence alternative. Advanced Markdown, multi-tenant teams, OIDC/SSO, and local S3 backups. Deploy in one command.

New permissions management in backend (authorizer) + fixes in frontend

Smaug673971081d71366e
diff --git a/backend/controllers/index.go b/backend/controllers/index.go
index d2a03999..366f606a 100644
--- a/backend/controllers/index.go
+++ b/backend/controllers/index.go
@@ -2,8 +2,10 @@ package controllers
import (
"alexandrie/app"
+ "alexandrie/permissions"
)
type Controller struct {
- app *app.App
+ app *app.App
+ authorizer permissions.Authorizer
}
diff --git a/backend/controllers/nodes.controller.go b/backend/controllers/nodes.controller.go
index a0871893..2b5076c4 100644
--- a/backend/controllers/nodes.controller.go
+++ b/backend/controllers/nodes.controller.go
@@ -3,6 +3,7 @@ package controllers
import (
"alexandrie/app"
"alexandrie/models"
+ "alexandrie/permissions"
"alexandrie/utils"
"net/http"
"time"
@@ -22,7 +23,8 @@ type NodeController interface {
func NewNodeController(app *app.App) NodeController {
return &Controller{
- app: app,
+ app: app,
+ authorizer: permissions.NewAuthorizer(app.Services.Permissions),
}
}
@@ -36,7 +38,7 @@ func NewNodeController(app *app.App) NodeController {
// @Failure 400 {object} Error
// @Failure 401 {object} Error
func (ctr *Controller) GetPublicNode(c *gin.Context) (int, any) {
- nodeId, err := utils.GetIdParam(c, c.Param("id"))
+ nodeId, err := utils.GetTargetUserId(c, c.Param("id"))
if err != nil {
return http.StatusBadRequest, err
}
@@ -56,11 +58,22 @@ func (ctr *Controller) GetPublicNode(c *gin.Context) (int, any) {
// @Failure 400 {object} Error
// @Failure 401 {object} Error
func (ctr *Controller) GetSharedNodes(c *gin.Context) (int, any) {
- id, err := utils.SelfOrPermission(c, utils.ADMINISTRATOR)
+ // Get connected user ID and role from context
+ connectedUserId, connectedUserRole, err := utils.GetUserContext(c)
if err != nil {
return http.StatusUnauthorized, err
}
- nodes, err := ctr.app.Services.Nodes.GetSharedNodes(id)
+ // Target user ID from param
+ targetUserId, err := utils.GetTargetUserId(c, c.Param("userId"))
+ if err != nil {
+ return http.StatusBadRequest, err
+ }
+ allowed, err := ctr.authorizer.CanAccessUser(connectedUserId, targetUserId, connectedUserRole)
+ if !allowed || err != nil {
+ return http.StatusUnauthorized, err
+ }
+
+ nodes, err := ctr.app.Services.Nodes.GetSharedNodes(targetUserId)
if err != nil {
return http.StatusInternalServerError, err
}
@@ -70,17 +83,29 @@ func (ctr *Controller) GetSharedNodes(c *gin.Context) (int, any) {
// Get nodes
// @Summary Get all nodes
// @Method GET
-// @Router /nodes [get]
+// @Router /nodes/:userId [get]
// @Security Authenfification: Auth
// @Success 200 {object} Success([]models.Node)
// @Failure 400 {object} Error
// @Failure 401 {object} Error
func (ctr *Controller) GetNodes(c *gin.Context) (int, any) {
- id, err := utils.SelfOrPermission(c, utils.ADMINISTRATOR)
+ // Get connected user ID and role from context
+ connectedUserId, connectedUserRole, err := utils.GetUserContext(c)
if err != nil {
return http.StatusUnauthorized, err
}
- nodes, err := ctr.app.Services.Nodes.GetAllNodes(id)
+ // Target user ID from param
+ targetUserId, err := utils.GetTargetUserId(c, c.Param("userId"))
+ if err != nil {
+ return http.StatusBadRequest, err
+ }
+
+ allowed, err := ctr.authorizer.CanAccessUser(connectedUserId, targetUserId, connectedUserRole)
+ if !allowed || err != nil {
+ return http.StatusUnauthorized, err
+ }
+
+ nodes, err := ctr.app.Services.Nodes.GetAllNodes(targetUserId)
if err != nil {
return http.StatusInternalServerError, err
}
@@ -97,29 +122,35 @@ func (ctr *Controller) GetNodes(c *gin.Context) (int, any) {
// @Failure 400 {object} Error
// @Failure 401 {object} Error
func (ctr *Controller) GetNode(c *gin.Context) (int, any) {
- nodeId, err := utils.GetIdParam(c, c.Param("id"))
+ nodeId, err := utils.GetTargetUserId(c, c.Param("id"))
if err != nil {
return http.StatusBadRequest, err
}
- node, err := ctr.app.Services.Nodes.GetNode(nodeId)
+ dbNode, err := ctr.app.Services.Nodes.GetNode(nodeId)
if err != nil {
return http.StatusInternalServerError, err
}
- connectedUserId, _, err := utils.NodePermission(c, node, ctr.app.Services.Permissions, utils.READ)
+ // Get connected user ID and role from context
+ connectedUserId, connectedUserRole, err := utils.GetUserContext(c)
if err != nil {
return http.StatusUnauthorized, err
}
+
+ allowed, _, err := ctr.authorizer.CanAccessNode(connectedUserId, connectedUserRole, dbNode, permissions.ActionRead)
+ if !allowed || err != nil {
+ return http.StatusUnauthorized, err
+ }
perms, err := ctr.app.Services.Permissions.GetNodePermission(nodeId)
if err != nil {
return http.StatusInternalServerError, err
}
filteredPerms := []*models.Permission{}
for _, p := range perms {
- if p.UserId == connectedUserId || node.UserId == connectedUserId {
+ if p.UserId == connectedUserId || dbNode.UserId == connectedUserId {
filteredPerms = append(filteredPerms, p)
}
}
- return http.StatusOK, gin.H{"node": node, "permissions": filteredPerms}
+ return http.StatusOK, gin.H{"node": dbNode, "permissions": filteredPerms}
}
// Create node
@@ -136,7 +167,7 @@ func (ctr *Controller) CreateNode(c *gin.Context) (int, any) {
if err := c.ShouldBind(node); err != nil {
return http.StatusBadRequest, err
}
- userId, err := utils.GetUserIdCtx(c)
+ userId, _, err := utils.GetUserContext(c)
if err != nil {
return http.StatusUnauthorized, err
}
@@ -179,16 +210,26 @@ func (ctr *Controller) CreateNode(c *gin.Context) (int, any) {
// @Failure 400 {object} Error
// @Failure 401 {object} Error
func (ctr *Controller) UpdateNode(c *gin.Context) (int, any) {
- nodeId, err := utils.GetIdParam(c, c.Param("id"))
+ nodeId, err := utils.GetTargetUserId(c, c.Param("id"))
if err != nil {
return http.StatusBadRequest, err
}
- db_node, err := ctr.app.Services.Nodes.GetNode(nodeId)
+
+ // Get connected user ID and role from context
+ connectedUserId, connectedUserRole, err := utils.GetUserContext(c)
+ if err != nil {
+ return http.StatusUnauthorized, err
+ }
+
+ dbNode, err := ctr.app.Services.Nodes.GetNode(nodeId)
if err != nil {
return http.StatusInternalServerError, err
}
- connectedUserId, userConnectedLevel, err := utils.NodePermission(c, db_node, ctr.app.Services.Permissions, utils.WRITE)
- if err != nil && (db_node.Access < 2 || *db_node.Accessibility != 3) {
+
+ allowed, level, err := ctr.authorizer.CanAccessNode(connectedUserId, connectedUserRole, dbNode, permissions.ActionUpdate)
+
+ // Special case: The document is public (accessibility = 3) and access < 2 (write or admin)
+ if !allowed && (dbNode.Access < 2 || *dbNode.Accessibility != 3) {
return http.StatusUnauthorized, err
}
node := &models.Node{}
@@ -196,12 +237,12 @@ func (ctr *Controller) UpdateNode(c *gin.Context) (int, any) {
return http.StatusBadRequest, err
}
- if db_node.UserId != connectedUserId && userConnectedLevel < utils.OWNER {
+ if dbNode.UserId != connectedUserId && level < utils.OWNER {
// If the user is not owner or admin of the node he cannot change some fields
- node.ParentId = db_node.ParentId
- node.UserId = db_node.UserId
- node.Accessibility = db_node.Accessibility
- node.Access = db_node.Access
+ node.ParentId = dbNode.ParentId
+ node.UserId = dbNode.UserId
+ node.Accessibility = dbNode.Accessibility
+ node.Access = dbNode.Access
}
node = &models.Node{
Id: nodeId,
@@ -242,21 +283,28 @@ func (ctr *Controller) UpdateNode(c *gin.Context) (int, any) {
// @Failure 400 {object} Error
// @Failure 401 {object} Error
func (ctr *Controller) DeleteNode(c *gin.Context) (int, any) {
- nodeId, err := utils.GetIdParam(c, c.Param("id"))
+ nodeId, err := utils.GetTargetUserId(c, c.Param("id"))
if err != nil {
return http.StatusBadRequest, err
}
- db_node, err := ctr.app.Services.Nodes.GetNode(nodeId)
+
+ // Get connected user ID and role from context
+ connectedUserId, connectedUserRole, err := utils.GetUserContext(c)
if err != nil {
- return http.StatusInternalServerError, err
+ return http.StatusUnauthorized, err
}
- _, _, err = utils.NodePermission(c, db_node, ctr.app.Services.Permissions, utils.ADMIN)
+
+ dbNode, err := ctr.app.Services.Nodes.GetNode(nodeId)
if err != nil {
+ return http.StatusInternalServerError, err
+ }
+ allowed, _, err := ctr.authorizer.CanAccessNode(connectedUserId, connectedUserRole, dbNode, permissions.ActionDelete)
+ if !allowed || err != nil {
return http.StatusUnauthorized, err
}
err = ctr.app.Services.Nodes.DeleteNode(nodeId)
if err != nil {
return http.StatusInternalServerError, err
}
- return http.StatusOK, db_node
+ return http.StatusOK, "OK"
}
diff --git a/backend/controllers/permissions.controller.go b/backend/controllers/permissions.controller.go
index b2130e1d..61f3aa13 100644
--- a/backend/controllers/permissions.controller.go
+++ b/backend/controllers/permissions.controller.go
@@ -33,7 +33,7 @@ func NewPermissionsController(app *app.App) PermissionsController {
// @Failure 400 {object} Error
// @Failure 401 {object} Error
func (ctr *Controller) GetNodePermissions(c *gin.Context) (int, any) {
- nodeId, err := utils.GetIdParam(c, c.Param("nodeId"))
+ nodeId, err := utils.GetTargetUserId(c, c.Param("nodeId"))
if err != nil {
return http.StatusBadRequest, err
}
@@ -99,7 +99,7 @@ func (ctr *Controller) CreatePermission(c *gin.Context) (int, any) {
// @Failure 400 {object} Error
// @Failure 401 {object} Error
func (ctr *Controller) UpdatePermission(c *gin.Context) (int, any) {
- permId, err := utils.GetIdParam(c, c.Param("id"))
+ permId, err := utils.GetTargetUserId(c, c.Param("id"))
if err != nil {
return http.StatusBadRequest, err
}
@@ -136,7 +136,7 @@ func (ctr *Controller) UpdatePermission(c *gin.Context) (int, any) {
// @Failure 400 {object} Error
// @Failure 401 {object} Error
func (ctr *Controller) DeletePermission(c *gin.Context) (int, any) {
- permId, err := utils.GetIdParam(c, c.Param("id"))
+ permId, err := utils.GetTargetUserId(c, c.Param("id"))
if err != nil {
return http.StatusBadRequest, err
}
diff --git a/backend/controllers/ressources.controller.go b/backend/controllers/ressources.controller.go
index ec9ff7e5..996dbe84 100644
--- a/backend/controllers/ressources.controller.go
+++ b/backend/controllers/ressources.controller.go
@@ -213,7 +213,7 @@ func (ctr *Controller) DeleteUpload(c *gin.Context) (int, any) {
if ctr.app.MinioClient == nil {
return http.StatusInternalServerError, errors.New("minio client not initialized")
}
- id, err := utils.GetIdParam(c, c.Param("id"))
+ id, err := utils.GetTargetUserId(c, c.Param("id"))
if err != nil {
return http.StatusBadRequest, errors.New("invalid id format")
}
diff --git a/backend/middlewares/authentification.go b/backend/middlewares/authentification.go
index 1caa70be..742ff407 100644
--- a/backend/middlewares/authentification.go
+++ b/backend/middlewares/authentification.go
@@ -1,6 +1,7 @@
package middlewares
import (
+ "alexandrie/permissions"
"alexandrie/utils"
"net/http"
"os"
@@ -47,8 +48,8 @@ func Auth() gin.HandlerFunc {
c.Abort() // Stop further processing if unauthorized
return
}
- c.Set("user_id", user_id) // Set user ID in context
- c.Set("user_role", user_role) // Set user role in context
+ c.Set("user_id", user_id) // Set user ID in context
+ c.Set("user_role", permissions.UserRole(user_role))
c.Set("claims", claims)
c.Next() // Proceed to the next handler if authorized
}
diff --git a/backend/permissions/constants.go b/backend/permissions/constants.go
new file mode 100644
index 00000000..7c01f5f8
--- /dev/null
+++ b/backend/permissions/constants.go
@@ -0,0 +1,45 @@
+package permissions
+
+// UserRole define global user roles (app level)
+type UserRole int
+
+const (
+ RoleNone UserRole = 0
+ RoleAdministrator UserRole = 1 << 1
+ RoleManager UserRole = 1 << 2
+ RoleModerator UserRole = 1 << 3
+)
+
+// NodePermissionLevel define permission levels on nodes
+type NodePermissionLevel int
+
+const (
+ PermNone NodePermissionLevel = iota
+ PermRead
+ PermWrite
+ PermAdmin
+ PermOwner
+)
+
+// NodeAction define actions that can be performed on nodes
+type NodeAction int
+
+const (
+ ActionRead NodeAction = iota + 1
+ ActionUpdate
+ ActionDelete
+ ActionShare
+)
+
+func (a NodeAction) RequiredLevel() NodePermissionLevel {
+ switch a {
+ case ActionRead:
+ return PermRead
+ case ActionUpdate:
+ return PermWrite
+ case ActionDelete, ActionShare:
+ return PermAdmin
+ default:
+ return PermNone
+ }
+}
diff --git a/backend/permissions/service.go b/backend/permissions/service.go
new file mode 100644
index 00000000..db923edb
--- /dev/null
+++ b/backend/permissions/service.go
@@ -0,0 +1,61 @@
+package permissions
+
+import (
+ "alexandrie/models"
+ "alexandrie/services"
+ "alexandrie/types"
+ "errors"
+)
+
+type Authorizer interface {
+ CanAccessNode(userID types.Snowflake, userRole UserRole, node *models.Node, action NodeAction) (bool, NodePermissionLevel, error)
+ CanAccessUser(connectedID, targetID types.Snowflake, userRole UserRole) (bool, error)
+ IsAppAdmin(userRole UserRole) bool
+}
+
+type DefaultAuthorizer struct {
+ permService services.PermissionService
+}
+
+func NewAuthorizer(permService services.PermissionService) Authorizer {
+ return &DefaultAuthorizer{permService: permService}
+}
+
+// Check access to a node resource
+func (a *DefaultAuthorizer) CanAccessNode(userID types.Snowflake, userRole UserRole, node *models.Node, action NodeAction) (bool, NodePermissionLevel, error) {
+ // Case 1: Owner of the node
+ if userID == node.UserId {
+ return true, PermOwner, nil
+ }
+
+ // Case 2: Global app admin
+ if a.IsAppAdmin(userRole) {
+ return true, PermOwner, nil
+ }
+
+ // Case 3: Check in DB via PermissionService
+ hasPermission, level := a.permService.HasPermission(userID, node.Id, int(action.RequiredLevel()))
+ if hasPermission {
+ return true, NodePermissionLevel(level), nil
+ }
+
+ return false, PermNone, errors.New("unauthorized")
+}
+
+// Check access to a user resource
+func (a *DefaultAuthorizer) CanAccessUser(connectedID, targetID types.Snowflake, userRole UserRole) (bool, error) {
+ if connectedID == targetID {
+ return true, nil
+ }
+
+ // Here we need to check the global role from the context (via middleware or db)
+ if a.IsAppAdmin(userRole) {
+ return true, nil
+ }
+
+ return false, errors.New("unauthorized")
+}
+
+func (a *DefaultAuthorizer) IsAppAdmin(userRole UserRole) bool {
+ return userRole == RoleAdministrator
+}
diff --git a/backend/utils/permissions.go b/backend/utils/permissions.go
index 4520d113..b3ca311d 100644
--- a/backend/utils/permissions.go
+++ b/backend/utils/permissions.go
@@ -2,6 +2,7 @@ package utils
import (
"alexandrie/models"
+ "alexandrie/permissions"
"alexandrie/services"
"alexandrie/types"
"errors"
@@ -26,34 +27,35 @@ const (
)
// CheckPermission checks if the user has the required permission.
-func CheckPermission(userRole, requiredRole int) bool {
+func CheckPermission(userRole, requiredRole permissions.UserRole) bool {
return userRole&requiredRole == requiredRole
}
-func CheckUserRequestPermission(ctx *gin.Context, requiredRole int) bool {
+func CheckUserRequestPermission(ctx *gin.Context, requiredRole permissions.UserRole) bool {
// Check if the user has the required permission
role, exists := ctx.Get("user_role")
if !exists {
return false
}
- if CheckPermission(role.(int), requiredRole) {
+ if CheckPermission(role.(permissions.UserRole), requiredRole) {
return true
}
return false
}
-func GetIdParam(ctx *gin.Context, param string) (types.Snowflake, error) {
+func GetTargetUserId(ctx *gin.Context, param string) (types.Snowflake, error) {
if param == "" {
return 0, errors.New("parameter is empty")
}
- if param != "@me" {
- id_param, err := strconv.ParseUint(param, 10, 64)
- if err != nil {
- return 0, errors.New("invalid parameter")
- }
- return types.Snowflake(id_param), nil
+ if param == "@me" {
+ return GetUserIdCtx(ctx)
}
- return GetUserIdCtx(ctx)
+
+ id_param, err := strconv.ParseUint(param, 10, 64)
+ if err != nil {
+ return 0, errors.New("invalid parameter")
+ }
+ return types.Snowflake(id_param), nil
}
func GetUserIdCtx(ctx *gin.Context) (types.Snowflake, error) {
@@ -68,14 +70,31 @@ func GetUserIdCtx(ctx *gin.Context) (types.Snowflake, error) {
return types.Snowflake(id), nil
}
-func SelfOrPermission(ctx *gin.Context, allowed int) (types.Snowflake, error) {
+// Return the user ID and user role from the context
+func GetUserContext(ctx *gin.Context) (types.Snowflake, permissions.UserRole, error) {
+ userId, exists := ctx.Get("user_id")
+ if !exists {
+ return 0, 0, errors.New("user ID not found in context")
+ }
+ id, ok := userId.(uint64)
+ if !ok {
+ return 0, 0, errors.ErrUnsupported
+ }
+ role, exists := ctx.Get("user_role")
+ if !exists {
+ return 0, 0, errors.New("user role not found in context")
+ }
+ return types.Snowflake(id), role.(permissions.UserRole), nil
+}
+
+func SelfOrPermission(ctx *gin.Context, allowed permissions.UserRole) (types.Snowflake, error) {
// Check if the c.Param("id") is "@me" or c.Param("id") is the same as the user ID in the context
// If not, check if the user has the required permission
// If one of the above is true, return the user ID from the context
// Otherwise, return an error
// --- 1. Get the target user ID
- targetUserId, err := GetIdParam(ctx, ctx.Param("userId"))
+ targetUserId, err := GetTargetUserId(ctx, ctx.Param("userId"))
if err != nil {
return 0, err
}
@@ -93,13 +112,13 @@ func SelfOrPermission(ctx *gin.Context, allowed int) (types.Snowflake, error) {
if !exists {
return 0, errors.New("user role not found in context")
}
- if CheckPermission(role.(int), allowed) {
+ if CheckPermission(role.(permissions.UserRole), allowed) {
return targetUserId, nil
}
return 0, errors.New("unauthorized")
}
-func NodePermission(ctx *gin.Context, node *models.Node, permissionService services.PermissionService, permission int) (connectedId types.Snowflake, level int, err error) {
+func NodePermission(ctx *gin.Context, node *models.Node, permissionService services.PermissionService, permission permissions.NodePermissionLevel) (connectedId types.Snowflake, level permissions.NodePermissionLevel, err error) {
// Check if the connected user has access to the resource
// Case 1: User is the owner of the node (connectedUserId == targetId) => allow
// Case 2: The user is an app administrator => allow
@@ -120,7 +139,7 @@ func NodePermission(ctx *gin.Context, node *models.Node, permissionService servi
if !exists {
return connectedUserId, 0, errors.New("user role not found in context")
}
- if CheckPermission(role.(int), ADMINISTRATOR) {
+ if CheckPermission(role.(permissions.UserRole), ADMINISTRATOR) {
return connectedUserId, OWNER, nil
}
@@ -129,10 +148,10 @@ func NodePermission(ctx *gin.Context, node *models.Node, permissionService servi
//}
// Case 3: User has the required permission on the resource
- hasPermission, level := permissionService.HasPermission(connectedUserId, node.Id, permission)
+ hasPermission, levelInt := permissionService.HasPermission(connectedUserId, node.Id, int(permission))
if hasPermission {
- return connectedUserId, level, nil
+ return connectedUserId, permissions.NodePermissionLevel(levelInt), nil
}
return 0, 0, errors.New("unauthorized")
diff --git a/frontend/app/pages/dashboard/categories/[id]/index.vue b/frontend/app/pages/dashboard/categories/[id]/index.vue
index ca01125d..eb9d84b6 100644
--- a/frontend/app/pages/dashboard/categories/[id]/index.vue
+++ b/frontend/app/pages/dashboard/categories/[id]/index.vue
@@ -4,7 +4,7 @@
<h1 style="font-size: 20px">Documents of category <tag class="blue">New</tag></h1>
<div style="display: flex; align-items: center; gap: 8px">
<NuxtLink @click="openPermissionsModal"><Icon name="manage_access" :big="true" fill="var(--font-color)" /></NuxtLink>
- <NuxtLink :to="`/dashboard/categories/${categoryId}/edit`"><Icon name="settings" :big="true" fill="var(--font-color)" /></NuxtLink>
+ <NuxtLink :to="`/dashboard/categories/${node?.id}/edit`"><Icon name="settings" :big="true" fill="var(--font-color)" /></NuxtLink>
<ViewSelection v-model="view" />
</div>
</header>
@@ -23,24 +23,44 @@
</template>
<script setup lang="ts">
-import NodePermissions from '@/components/Node/NodePermissions.vue';
+import NodePermissions from '@/components/Node/NodePermissions.modal.vue';
+import type { Node } from '~/stores';
const route = useRoute();
const categoryId = route.params.id as string;
const nodesStore = useNodesStore();
const view: Ref<'table' | 'list'> = ref('list');
-const node = computed(() => nodesStore.getById(categoryId));
+const node = ref<Node | undefined>();
+const error = ref<string>('');
// definePageMeta({
// breadcrumb: () => {
// const category = nodesStore.getById(route.params.id as string);
// return category?.name || '';
// },
// });
+
+watchEffect(async () => {
+ const nodeFromStore = nodesStore.getById(categoryId);
+ if (!nodeFromStore) {
+ if (nodesStore.isFetching) return;
+ return (error.value = 'Document not found');
+ }
+ node.value = undefined;
+ if (nodeFromStore.partial) {
+ try {
+ error.value = '';
+ node.value = await nodesStore.fetch({ id: categoryId });
+ } catch (err: unknown) {
+ error.value = (err as Error).message || 'Failed to fetch document';
+ }
+ } else node.value = nodeFromStore;
+});
+
const openPermissionsModal = () => {
if (node.value) useModal().add(new Modal(shallowRef(NodePermissions), { props: { node: node.value }, size: 'small' }));
};
const documents = computed(() => {
- return nodesStore.getAllChildrens(categoryId).filter(d => d.role == 3);
+ return nodesStore.getAllChildrens(node.value?.id || '').filter(d => d.role == 3);
});
</script>
diff --git a/frontend/app/stores/nodes.store.ts b/frontend/app/stores/nodes.store.ts
index a2ac894c..56dde0e3 100644
--- a/frontend/app/stores/nodes.store.ts
+++ b/frontend/app/stores/nodes.store.ts
@@ -148,6 +148,9 @@ export const useNodesStore = defineStore('nodes', {
if (node.tags) {
parseTags(node.tags).forEach(tag => tags.add(tag));
}
+ if (node.parent_id && !this.nodes.find(n => n.id === node.parent_id)) {
+ node.parent_id = '';
+ }
});
this.allTags = Array.from(tags).sort();
},