Skip to content

Commit

Permalink
Merge pull request #124 from Prometheus7-creator/multitenant
Browse files Browse the repository at this point in the history
added device id update endpoint
  • Loading branch information
abhinovpankaj authored Jul 19, 2024
2 parents 25f27ea + 3cc11a7 commit 083387b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
6 changes: 3 additions & 3 deletions model/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,10 @@ var removeUser = async function (user, callback) {
if (result.deletedCount == 1) {
callback(null, { status: 201, message: "User deleted successfully." });
} else {
var error2 = new Error(
"Error occurred. Didn't remove user. " + err.message
var error2 = new Error(
"Error occurred. Didn't remove user. "
);
error2.status = err.status;
error2.status = 500;
callback(error2);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion routes/login-endpoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ router.route("/login").post(async function (req, res) {
users.updateDevideId(username,deviceId,function(err,result){
if (err) {
console.log(err);
res.status(500),send('internal server error');
res.status(500).send('internal server error');
}
});
}else{
Expand Down
22 changes: 20 additions & 2 deletions routes/user-endpoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -419,12 +419,12 @@ router
.delete(async function (req, res) {
try {
const username = req.params.username;
users.removeUser(username, async function (err, record) {
users.removeUser({username}, async function (err, record) {
if (err) {
res.status(err.status).send(err.message);
} else {
if (record) {
res.status(201).send("user delete successfully");
res.status(201).json({message: "user delete successfully"});
} else res.status(401).send("user not found.");
}
});
Expand Down Expand Up @@ -578,4 +578,22 @@ router.route("/loginSuperUser").post(async function (req, res) {
}
});

router.route("/deviceId")
.put(async function (req, res) {
try {
const {username, deviceId} = req.body;
users.updateDevideId(username,deviceId,function(err,result){
if (err) {
console.log(err);
res.status(500).send('internal server error');
}
else{
res.status(201).json(result);
}
});
} catch {
res.status(500).send("Internal server error.");
}
});

module.exports = router;

0 comments on commit 083387b

Please sign in to comment.