From 60009c63469dfb5cc1ed8dbcd40a1ca4ca723941 Mon Sep 17 00:00:00 2001 From: Tim Alby Date: Tue, 26 Jun 2018 19:50:12 +0200 Subject: [PATCH] fix delete endpoint --- .../app/coffee/Features/User/UserEmailsController.coffee | 2 +- services/web/app/coffee/router.coffee | 2 +- .../factories/UserAffiliationsDataService.coffee | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/services/web/app/coffee/Features/User/UserEmailsController.coffee b/services/web/app/coffee/Features/User/UserEmailsController.coffee index bc53af4098..a6335521d6 100644 --- a/services/web/app/coffee/Features/User/UserEmailsController.coffee +++ b/services/web/app/coffee/Features/User/UserEmailsController.coffee @@ -33,7 +33,7 @@ module.exports = UserEmailsController = remove: (req, res, next) -> userId = AuthenticationController.getLoggedInUserId(req) - email = EmailHelper.parseEmail(req.params.email) + email = EmailHelper.parseEmail(req.body.email) return res.sendStatus 422 unless email? UserUpdater.removeEmailAddress userId, email, (error)-> diff --git a/services/web/app/coffee/router.coffee b/services/web/app/coffee/router.coffee index 4e7c3d9ddb..8993bb45dc 100644 --- a/services/web/app/coffee/router.coffee +++ b/services/web/app/coffee/router.coffee @@ -114,7 +114,7 @@ module.exports = class Router webRouter.post '/user/emails', AuthenticationController.requireLogin(), UserEmailsController.add - webRouter.delete '/user/emails/:email', + webRouter.post '/user/emails/delete', AuthenticationController.requireLogin(), UserEmailsController.remove webRouter.post '/user/emails/default', diff --git a/services/web/public/coffee/main/affiliations/factories/UserAffiliationsDataService.coffee b/services/web/public/coffee/main/affiliations/factories/UserAffiliationsDataService.coffee index 6bc5e8eb9f..f89c6410e1 100644 --- a/services/web/public/coffee/main/affiliations/factories/UserAffiliationsDataService.coffee +++ b/services/web/public/coffee/main/affiliations/factories/UserAffiliationsDataService.coffee @@ -78,9 +78,9 @@ define [ } removeUserEmail = (email) -> - $http.delete "/user/emails/#{ encodeURIComponent(email) }", { - headers: - "X-CSRF-Token": window.csrfToken + $http.post "/user/emails/delete", { + email, + _csrf: window.csrfToken } isDomainBlacklisted = (domain) ->