mirror of
https://github.com/wassname/talk.git
synced 2026-09-09 11:38:08 +08:00
update backend with the can() method
This commit is contained in:
@@ -45,7 +45,7 @@ const deleteAction = ({user}, {id}) => {
|
||||
};
|
||||
|
||||
module.exports = (context) => {
|
||||
if (context.user && context.user.can('mutation:createAction', 'mutation:deleteAction')) {
|
||||
if (context.user && context.user.can('CREATE_ACTION', 'DELETE_ACTION')) {
|
||||
return {
|
||||
Action: {
|
||||
create: (action) => createAction(context, action),
|
||||
|
||||
@@ -236,19 +236,19 @@ module.exports = (context) => {
|
||||
}
|
||||
};
|
||||
|
||||
if (context.user && context.user.can('mutation:createComment')) {
|
||||
if (context.user && context.user.can('CREATE_COMMENT')) {
|
||||
mutators.Comment.create = (comment) => createPublicComment(context, comment);
|
||||
}
|
||||
|
||||
if (context.user && context.user.can('mutation:setCommentStatus')) {
|
||||
if (context.user && context.user.can('SET_COMMENT_STATUS')) {
|
||||
mutators.Comment.setCommentStatus = (action) => setCommentStatus(context, action);
|
||||
}
|
||||
|
||||
if (context.user && context.user.can('mutation:addCommentTag')) {
|
||||
if (context.user && context.user.can('ADD_COMMENT_TAG')) {
|
||||
mutators.Comment.addCommentTag = (action) => addCommentTag(context, action);
|
||||
}
|
||||
|
||||
if (context.user && context.user.can('mutation:removeCommentTag')) {
|
||||
if (context.user && context.user.can('REMOVE_COMMENT_TAG')) {
|
||||
mutators.Comment.removeCommentTag = (action) => removeCommentTag(context, action);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,11 +31,11 @@ module.exports = (context) => {
|
||||
}
|
||||
};
|
||||
|
||||
if (context.user && context.user.can('mutation:setUserStatus')) {
|
||||
if (context.user && context.user.can('SET_USER_STATUS')) {
|
||||
mutators.User.setUserStatus = (action) => setUserStatus(context, action);
|
||||
}
|
||||
|
||||
if (context.user && context.user.can('mutation:suspendUser')) {
|
||||
if (context.user && context.user.can('SUSPEND_USER')) {
|
||||
mutators.User.suspendUser = (action) => suspendUser(context, action);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user