Skip to content

Commit

Permalink
removed feature flag from /users?profile=true (#2235)
Browse files Browse the repository at this point in the history
  • Loading branch information
vikasosmium authored Oct 28, 2024
1 parent 0e41470 commit cedce5b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 32 deletions.
22 changes: 9 additions & 13 deletions controllers/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,20 +116,16 @@ const getUsers = async (req, res) => {
const profile = req.query.profile === "true";

if (profile) {
if (dev) {
if (!req.userData.id) {
return res.boom.badRequest("User ID not provided.");
}
if (!req.userData.id) {
return res.boom.badRequest("User ID not provided.");
}

try {
const result = await dataAccess.retrieveUsers({ id: req.userData.id });
return res.send(result.user);
} catch (error) {
logger.error(`Error while fetching user: ${error}`);
return res.boom.serverUnavailable(INTERNAL_SERVER_ERROR);
}
} else {
return res.boom.badRequest("Route not found");
try {
const result = await dataAccess.retrieveUsers({ id: req.userData.id });
return res.send(result.user);
} catch (error) {
logger.error(`Error while fetching user: ${error}`);
return res.boom.serverUnavailable(INTERNAL_SERVER_ERROR);
}
}

Expand Down
22 changes: 3 additions & 19 deletions test/integration/users.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -904,10 +904,10 @@ describe("Users", function () {
});
});

it("Should return the logged-in user's details when profile and dev is true", function (done) {
it("Should return the logged-in user's details when profile is true", function (done) {
chai
.request(app)
.get("/users?profile=true&dev=true")
.get("/users?profile=true")
.set("cookie", `${cookieName}=${jwt}`)
.end((err, res) => {
if (err) {
Expand All @@ -923,26 +923,10 @@ describe("Users", function () {
});
});

it("Should throw an error when there is no feature flag given", function (done) {
chai
.request(app)
.get("/users?profile=true")
.set("cookie", `${cookieName}=${jwt}`)
.end((err, res) => {
if (err) {
return done(err);
}
expect(res).to.have.status(400);
expect(res.body).to.be.an("object");
expect(res.body.message).to.equal("Route not found");
return done();
});
});

it("Should return 401 if not logged in", function (done) {
chai
.request(app)
.get("/users?profile=true&dev=true")
.get("/users?profile=true")
.set("cookie", `${cookieName}=invalid_token`)
.end((err, res) => {
if (err) {
Expand Down

0 comments on commit cedce5b

Please sign in to comment.