Skip to content

Commit

Permalink
Fixed users self patch API for new users (#2069)
Browse files Browse the repository at this point in the history
* Fixed users self patch API for new users

* Tests fixed

* Tests fixed
  • Loading branch information
lakshayman authored Aug 29, 2024
1 parent ec09023 commit 6c33d2a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion controllers/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ const updateSelf = async (req, res) => {
}
}

if (userRoles.in_discord) {
if (userRoles.in_discord && !user.incompleteUserDetails) {
const membersInDiscord = await getDiscordMembers();
const discordMember = membersInDiscord.find((member) => member.user.id === discordId);
if (discordMember) {
Expand Down
8 changes: 6 additions & 2 deletions test/integration/users.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2344,7 +2344,11 @@ describe("Users", function () {
});

describe("PATCH /users/self for developers", function () {
beforeEach(function () {
let id, jwtoken;

beforeEach(async function () {
id = await addUser();
jwtoken = authService.generateAuthToken({ userId: id });
fetchStub = Sinon.stub(global, "fetch");
const discordMembers = [...getDiscordMembers];
discordMembers[0].user.id = "12345";
Expand All @@ -2365,7 +2369,7 @@ describe("Users", function () {
chai
.request(app)
.patch("/users/self")
.set("cookie", `${cookieName}=${jwt}`)
.set("cookie", `${cookieName}=${jwtoken}`)
.send({
first_name: "Test first_name",
})
Expand Down

0 comments on commit 6c33d2a

Please sign in to comment.