T-954157790456099: Remove unnesseceary else statements

This commit is contained in:
Okechi Onyeje 2019-01-01 20:38:42 -05:00
parent b49d62c151
commit f7d84ceea5

View File

@ -18,18 +18,17 @@ async function updateUserProfile(req, res) {
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})
}
}
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})
}
}
@ -37,18 +36,17 @@ async function getUserProfile(req, res) {
const profileNumber = req.params.profileNumber;
if (!utils.isProfileNumberValid(profileNumber)) {
return;
} else {
const sessionId = utils.getSessionIdFromAuthHeader(req, res);
try {
const tagferId = authDao.getSession(sessionId).tagferId;
profileDao.getProfile(profileNumber,tagferId).then((profile) => {
res.status(http.OK).json({profile})
}).catch(error => {
res.status(http.INTERNAL_SERVER_ERROR).json({error: error.code})
})
} catch (error) {
res.status(http.UNAUTHORIZED).json({ error })
}
}
const sessionId = utils.getSessionIdFromAuthHeader(req, res);
try {
const tagferId = authDao.getSession(sessionId).tagferId;
profileDao.getProfile(profileNumber,tagferId).then((profile) => {
res.status(http.OK).json({profile})
}).catch(error => {
res.status(http.INTERNAL_SERVER_ERROR).json({error: error.code})
})
} catch (error) {
res.status(http.UNAUTHORIZED).json({ error })
}
}