Skip to content

Commit

Permalink
allow rolemembers to remove themselves from church (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
Himali-Malvawala authored Jul 6, 2024
1 parent 0fe5bb1 commit 429c0b4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/controllers/RoleMemberController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ export class RoleMemberController extends MembershipBaseController {
});
}

@httpDelete("/self/:churchId/:userId")
public async deleteSelf(@requestParam("churchId") churchId: string, @requestParam("userId") userId: string, req: express.Request<{}, {}, []>, res: express.Response): Promise<any> {
return this.actionWrapper(req, res, async (au) => {
await this.repositories.roleMember.deleteSelf(churchId, userId);
return this.json([], 200);
})
}

private async checkAccess(members: RoleMember[], permission: IPermission, au: AuthenticatedUser) {
const hasAccess = au.checkAccess(permission);
/*
Expand Down
5 changes: 5 additions & 0 deletions src/repositories/RoleMemberRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,9 @@ export class RoleMemberRepository {
return DB.query(query, [userId])
}

public deleteSelf(churchId: string, userId: string) {
const query = "DELETE FROM roleMembers WHERE churchId=? AND userId=?;"
return DB.query(query, [churchId, userId]);
}

}

0 comments on commit 429c0b4

Please sign in to comment.