Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions backend/middleware/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const verifyToken = async (req, res, next) => {
uid: decodedToken.uid,
email: decodedToken.email,
displayName: decodedToken.name || '',
idToken,
};
} else {
const apiKey = getEnvValue('FIREBASE_API_KEY');
Expand Down Expand Up @@ -62,6 +63,7 @@ const verifyToken = async (req, res, next) => {
uid: userInfo.localId,
email: userInfo.email,
displayName: userInfo.displayName || '',
idToken,
};
}

Expand Down
2 changes: 1 addition & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "safeguard-backend",
"name": "abhaya-backend",
"version": "1.0.0",
"description": "SafeGuard Women Safety App - Backend API",
"main": "server.js",
Expand Down
9 changes: 3 additions & 6 deletions backend/routes/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -572,13 +572,12 @@ router.get('/profile', verifyToken, async (req, res) => {
});
if (!apiKey) return;

const idToken = req.headers.authorization.split('Bearer ')[1];
const { data } = await firebaseJson(
`${IDENTITY_URL}:lookup?key=${apiKey}`,
{
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ idToken }),
body: JSON.stringify({ idToken: req.user.idToken }),
},
'profileLookup'
);
Expand Down Expand Up @@ -676,8 +675,7 @@ router.put('/profile', verifyToken, async (req, res) => {
});
if (!apiKey) return;

const idToken = req.headers.authorization.split('Bearer ')[1];
const updateData = { idToken, returnSecureToken: false };
const updateData = { idToken: req.user.idToken, returnSecureToken: false };
if (displayName !== undefined) updateData.displayName = displayName;
if (photoURL !== undefined) updateData.photoUrl = photoURL;

Expand Down Expand Up @@ -743,13 +741,12 @@ router.delete('/account', verifyToken, async (req, res) => {
});
if (!apiKey) return;

const idToken = req.headers.authorization.split('Bearer ')[1];
const { data } = await firebaseJson(
`${IDENTITY_URL}:delete?key=${apiKey}`,
{
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ idToken }),
body: JSON.stringify({ idToken: req.user.idToken }),
},
'accountDelete'
);
Expand Down