mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 04:46:40 +07:00
comment locking initial
This commit is contained in:
parent
6eafc227da
commit
59d544c5f4
10 changed files with 139 additions and 44 deletions
|
@ -1,5 +1,5 @@
|
|||
import { USER_ROLES } from '~/redux/auth/constants';
|
||||
import { INode } from '~/redux/types';
|
||||
import { INode, IComment, ICommentGroup } from '~/redux/types';
|
||||
import { IUser } from '~/redux/auth/types';
|
||||
import path from 'ramda/es/path';
|
||||
import { NODE_TYPES } from '~/redux/node/constants';
|
||||
|
@ -8,6 +8,10 @@ export const canEditNode = (node: Partial<INode>, user: Partial<IUser>): boolean
|
|||
path(['role'], user) === USER_ROLES.ADMIN ||
|
||||
(path(['user', 'id'], node) && path(['user', 'id'], node) === path(['id'], user));
|
||||
|
||||
export const canEditComment = (comment: Partial<ICommentGroup>, user: Partial<IUser>): boolean =>
|
||||
path(['role'], user) === USER_ROLES.ADMIN ||
|
||||
(path(['user', 'id'], comment) && path(['user', 'id'], comment) === path(['id'], user));
|
||||
|
||||
export const canLikeNode = (node: Partial<INode>, user: Partial<IUser>): boolean =>
|
||||
path(['role'], user) && path(['role'], user) !== USER_ROLES.GUEST;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue