Skip to content
Snippets Groups Projects
Commit 0b0239cd authored by Sebastian Mihalache's avatar Sebastian Mihalache
Browse files

feat(component-user-manager): remove author from fragment on delete

parent df447880
No related branches found
No related tags found
1 merge request!13Sprint #14
......@@ -10,6 +10,7 @@ module.exports = models => async (req, res) => {
return res.status(400).json({
error: `Fragment ${fragmentId} does not match collection ${collectionId}`,
})
const fragment = await models.Fragment.find(fragmentId)
const teamHelper = new Team({ TeamModel: models.Team, fragmentId })
const team = await teamHelper.getTeam({
......@@ -20,7 +21,12 @@ module.exports = models => async (req, res) => {
await teamHelper.removeTeamMember({ teamId: team.id, userId })
user.teams = user.teams.filter(userTeamId => team.id !== userTeamId)
delete user.passwordResetToken
await user.save()
user.save()
fragment.authors = fragment.authors || []
fragment.authors = fragment.authors.filter(author => author.id !== userId)
fragment.save()
return res.status(200).json({})
} catch (e) {
const notFoundError = await services.handleNotFoundError(e, 'item')
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment