fix(settings/updateEmail): Show message from server
This commit is contained in:
@@ -24,15 +24,29 @@ export default function settingsController(app) {
|
||||
);
|
||||
};
|
||||
|
||||
const updateMyEmailValidators = [
|
||||
check('email')
|
||||
.isEmail()
|
||||
.withMessage('Email format is invalid.')
|
||||
];
|
||||
|
||||
function updateMyEmail(req, res, next) {
|
||||
const { user, body: { email } } = req;
|
||||
return user.requestUpdateEmail(email)
|
||||
.subscribe(
|
||||
(message) => res.json({ message }),
|
||||
message => res.sendFlash(alertTypes.info, message),
|
||||
next
|
||||
);
|
||||
}
|
||||
|
||||
api.post(
|
||||
'/update-my-email',
|
||||
ifNoUser401,
|
||||
updateMyEmailValidators,
|
||||
createValidatorErrorHandler(alertTypes.danger),
|
||||
updateMyEmail
|
||||
);
|
||||
|
||||
function updateMyLang(req, res, next) {
|
||||
const { user, body: { lang } = {} } = req;
|
||||
const langName = supportedLanguages[lang];
|
||||
@@ -130,11 +144,6 @@ export default function settingsController(app) {
|
||||
ifNoUser401,
|
||||
toggleUserFlag('sendQuincyEmail')
|
||||
);
|
||||
api.post(
|
||||
'/update-my-email',
|
||||
ifNoUser401,
|
||||
updateMyEmail
|
||||
);
|
||||
api.post(
|
||||
'/update-my-lang',
|
||||
ifNoUser401,
|
||||
|
Reference in New Issue
Block a user