feat: add gdpr privacy and terms

This commit is contained in:
Mrugesh Mohapatra
2018-05-27 17:29:04 +05:30
parent d68c568490
commit 3ad70a7926
6 changed files with 195 additions and 2 deletions

View File

@@ -1,5 +1,4 @@
import { check } from 'express-validator/check';
import {
ifNoUser401,
createValidatorErrorHandler
@@ -147,6 +146,36 @@ export default function settingsController(app) {
);
}
const updatePrivacyTerms = (req, res, next) => {
const {
user,
body: { quincyemails }
} = req;
const update = {
acceptedPrivacyTerms: true,
sendQuincyEmail: !!quincyemails
};
return user.update$(update)
.do(() => {
req.user = Object.assign(req.user, update);
})
.subscribe(
() => {
res.status(200).json({
message: 'We have updated your preferences. ' +
'You can now continue using freeCodeCamp.'
});
},
next
);
};
api.post(
'/update-privacy-terms',
ifNoUser401,
updatePrivacyTerms
);
api.post(
'/refetch-user-completed-challenges',
ifNoUser401,