fix: Unable to delete user via API (#3619)

Remove requirement to pass 'confirmation' to users.delete
closes #3604
This commit is contained in:
Tom Moor
2022-06-02 12:56:27 -07:00
committed by GitHub
parent 68dd76cfa3
commit 2d7dd558a1
5 changed files with 13 additions and 32 deletions

View File

@@ -299,16 +299,6 @@ describe("#users.invite", () => {
});
describe("#users.delete", () => {
it("should not allow deleting without confirmation", async () => {
const user = await buildUser();
const res = await server.post("/api/users.delete", {
body: {
token: user.getJwtToken(),
},
});
expect(res.status).toEqual(400);
});
it("should not allow deleting last admin if many users", async () => {
const user = await buildAdmin();
await buildUser({
@@ -318,13 +308,12 @@ describe("#users.delete", () => {
const res = await server.post("/api/users.delete", {
body: {
token: user.getJwtToken(),
confirmation: true,
},
});
expect(res.status).toEqual(400);
});
it("should allow deleting user account with confirmation", async () => {
it("should allow deleting user account", async () => {
const user = await buildUser();
await buildUser({
teamId: user.teamId,
@@ -332,30 +321,28 @@ describe("#users.delete", () => {
const res = await server.post("/api/users.delete", {
body: {
token: user.getJwtToken(),
confirmation: true,
},
});
expect(res.status).toEqual(200);
});
it("should allow deleting pending user account with admin", async () => {
const user = await buildAdmin();
const pending = await buildUser({
teamId: user.teamId,
it("should allow deleting user account with admin", async () => {
const admin = await buildAdmin();
const user = await buildUser({
teamId: admin.teamId,
lastActiveAt: null,
});
const res = await server.post("/api/users.delete", {
body: {
token: user.getJwtToken(),
id: pending.id,
confirmation: true,
token: admin.getJwtToken(),
id: user.id,
},
});
expect(res.status).toEqual(200);
});
it("should not allow deleting another user account", async () => {
const user = await buildAdmin();
const user = await buildUser();
const user2 = await buildUser({
teamId: user.teamId,
});
@@ -363,7 +350,6 @@ describe("#users.delete", () => {
body: {
token: user.getJwtToken(),
id: user2.id,
confirmation: true,
},
});
expect(res.status).toEqual(403);