mirror of
https://github.com/ClaytonWWilson/CS307-Team24.git
synced 2026-03-10 21:25:04 +00:00
Redux saves user data on login
This commit is contained in:
@@ -214,3 +214,20 @@ exports.getUserDetails = (req, res) => {
|
||||
return res.status(500).json({ error: err.code });
|
||||
});
|
||||
};
|
||||
|
||||
exports.getAuthenticatedUser = (req, res) => {
|
||||
let userData = {};
|
||||
db.doc(`/users/${req.user.handle}`)
|
||||
.get()
|
||||
.then((doc) => {
|
||||
if (doc.exists) {
|
||||
userData.credentials = doc.data();
|
||||
return res.status(200).json({userData});
|
||||
} else {
|
||||
return res.status(400).json({error: "User not found."})
|
||||
}})
|
||||
.catch((err) => {
|
||||
console.error(err);
|
||||
return res.status(500).json({ error: err.code });
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user