mirror of
https://bitbucket.org/tagfer_team/tagfer-server.git
synced 2025-12-25 03:37:38 +00:00
T-954157790482088: add profileNumber validation check to updateProfile endpoint
This commit is contained in:
parent
50b6f9b0fa
commit
59d2530d09
@ -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})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user