From f7d84ceea5ab0d172a3108cc7089e93e9c56c737 Mon Sep 17 00:00:00 2001 From: Okechi Onyeje Date: Tue, 1 Jan 2019 20:38:42 -0500 Subject: [PATCH] T-954157790456099: Remove unnesseceary else statements --- src/ups/profiles/handlers.js | 46 +++++++++++++++++------------------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/src/ups/profiles/handlers.js b/src/ups/profiles/handlers.js index b0717ae..6085056 100644 --- a/src/ups/profiles/handlers.js +++ b/src/ups/profiles/handlers.js @@ -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 }) } }