T-954157790482088: add profileNumber validation check to updateProfile endpoint

This commit is contained in:
Okechi Onyeje 2019-01-01 16:43:59 -05:00
parent 50b6f9b0fa
commit 59d2530d09

View File

@ -14,16 +14,22 @@ const _ = require('lodash');
*/
async function updateUserProfile(req, res) {
const profileObj = req.body;
const sessionId = utils.getSessionIdFromAuthHeader(req, res);
try {
const tagferId = authDao.getSession(sessionId).tagferId;
profileDao.updateProfile(profileObj, req.params.profileNumber, tagferId).then( () => {
res.status(http.CREATED).json({})
}).catch( (error) => {
res.status(http.INTERNAL_SERVER_ERROR).json({error: errors.APP_FIREBASE_DATABASE_ERROR})
});
} catch (error) {
res.status(http.UNAUTHORIZED).json({error})
const profileNumber = req.params.profileNumber;
if (!utils.isProfileNumberValid(profileNumber, res)) {
return;
} else {
const sessionId = utils.getSessionIdFromAuthHeader(req, res);
try {
const tagferId = authDao.getSession(sessionId).tagferId;
profileDao.updateProfile(profileObj, profileNumber, tagferId).then( () => {
res.status(http.CREATED).json({})
}).catch( (error) => {
res.status(http.INTERNAL_SERVER_ERROR).json({error: errors.APP_FIREBASE_DATABASE_ERROR})
});
} catch (error) {
res.status(http.UNAUTHORIZED).json({error})
}
}
}