forked from bloom-housing/bloom
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(backend): Add user delete endpoint and expose leasingAgentInList… (
bloom-housing#1996) * feat(backend): Add user delete endpoint and expose leasingAgentInListings in UserUpdateDto * feat(backend): Add DELETE and GET /user/:id endpoints * fix(backend): set bigger timeout for email.service.spec.ts * test(backend): fix SETEX impossible to process * Fix code style issues with Prettier Co-authored-by: Lint Action <[email protected]>
- Loading branch information
1 parent
f313775
commit a13f735
Showing
12 changed files
with
158 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
backend/core/src/migration/1634210584036-add-cascade-to-user-roles-user-relation.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { MigrationInterface, QueryRunner } from "typeorm" | ||
|
||
export class addCascadeToUserRolesUserRelation1634210584036 implements MigrationInterface { | ||
name = "addCascadeToUserRolesUserRelation1634210584036" | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(` | ||
ALTER TABLE "user_roles" DROP CONSTRAINT IF EXISTS "FK_87b8888186ca9769c960e926870"`) | ||
await queryRunner.query( | ||
`ALTER TABLE "user_roles" ADD CONSTRAINT "FK_87b8888186ca9769c960e926870" FOREIGN KEY ("user_id") REFERENCES "user_accounts"("id") ON DELETE CASCADE ON UPDATE CASCADE` | ||
) | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(` | ||
ALTER TABLE "user_roles" DROP CONSTRAINT IF EXISTS "FK_87b8888186ca9769c960e926870"`) | ||
await queryRunner.query( | ||
`ALTER TABLE "user_roles" ADD CONSTRAINT "FK_87b8888186ca9769c960e926870" FOREIGN KEY ("user_id") REFERENCES "user_accounts"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -570,4 +570,39 @@ describe("Applications", () => { | |
true | ||
) | ||
}) | ||
|
||
it("should get and delete a user by ID", async () => { | ||
const user = await userService._createUser( | ||
{ | ||
dob: new Date(), | ||
email: "[email protected]", | ||
firstName: "test", | ||
jurisdictions: [], | ||
language: Language.en, | ||
lastName: "", | ||
middleName: "", | ||
roles: { isPartner: true, isAdmin: false }, | ||
updatedAt: undefined, | ||
passwordHash: "abcd", | ||
}, | ||
null | ||
) | ||
|
||
const res = await supertest(app.getHttpServer()) | ||
.get(`/user/${user.id}`) | ||
.set(...setAuthorization(adminAccessToken)) | ||
.expect(200) | ||
expect(res.body.id).toBe(user.id) | ||
expect(res.body.email).toBe(user.email) | ||
|
||
await supertest(app.getHttpServer()) | ||
.delete(`/user/${user.id}`) | ||
.set(...setAuthorization(adminAccessToken)) | ||
.expect(200) | ||
|
||
await supertest(app.getHttpServer()) | ||
.get(`/user/${user.id}`) | ||
.set(...setAuthorization(adminAccessToken)) | ||
.expect(404) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters