feature: Delete_user_as_admin_through_API_only

This commit is contained in:
ogerly 2020-02-13 13:40:20 +01:00 committed by roschaefer
parent 066506838f
commit 3d8fe4d850
2 changed files with 4 additions and 3 deletions

View File

@ -133,7 +133,7 @@ export default shield(
CreateComment: isAuthenticated, CreateComment: isAuthenticated,
UpdateComment: isAuthor, UpdateComment: isAuthor,
DeleteComment: isAuthor, DeleteComment: isAuthor,
DeleteUser: isDeletingOwnAccount, DeleteUser: or(isDeletingOwnAccount, isAdmin),
requestPasswordReset: allow, requestPasswordReset: allow,
resetPassword: allow, resetPassword: allow,
AddPostEmotions: isAuthenticated, AddPostEmotions: isAuthenticated,

View File

@ -175,6 +175,7 @@ export default {
DeleteUser: async (object, params, context, resolveInfo) => { DeleteUser: async (object, params, context, resolveInfo) => {
const { resource } = params const { resource } = params
const session = context.driver.session() const session = context.driver.session()
const { id: userId } = params
try { try {
if (resource && resource.length) { if (resource && resource.length) {
await session.writeTransaction(transaction => { await session.writeTransaction(transaction => {
@ -190,7 +191,7 @@ export default {
RETURN author RETURN author
`, `,
{ {
userId: context.user.id, userId,
}, },
) )
}) })
@ -212,7 +213,7 @@ export default {
DETACH DELETE socialMedia DETACH DELETE socialMedia
RETURN user RETURN user
`, `,
{ userId: context.user.id }, { userId },
) )
log(deleteUserTransactionResponse) log(deleteUserTransactionResponse)
return deleteUserTransactionResponse.records.map(record => record.get('user').properties) return deleteUserTransactionResponse.records.map(record => record.get('user').properties)