Skip to content

Commit

Permalink
fix: compare (#18)
Browse files Browse the repository at this point in the history
* fix: compare
  • Loading branch information
rmagur1203 authored Mar 4, 2023
1 parent 95437fe commit 9f0f361
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/server/src/club/club.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class ClubService {

async update(admin: Admin, id: number, updateClubDto: UpdateClubDto) {
const item = await this.clubRepository.findOneBy({ id });
if (admin.role !== 'admin' && compare(admin.role, item?.name)) {
if (admin.role !== 'admin' && !compare(admin.role, item?.name)) {
throw new HttpException('Not admin of club', HttpStatus.UNAUTHORIZED);
}
return this.clubRepository.update(id, updateClubDto);
Expand Down
4 changes: 2 additions & 2 deletions packages/server/src/form/form.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class FormService {
if (!club) {
throw new HttpException('Club not found', HttpStatus.NOT_FOUND);
}
if (admin.role !== 'admin' && compare(admin.role, club?.name)) {
if (admin.role !== 'admin' && !compare(admin.role, club?.name)) {
throw new HttpException('Not admin of club', HttpStatus.UNAUTHORIZED);
}
const item = {
Expand All @@ -48,7 +48,7 @@ export class FormService {
if (!club) {
throw new HttpException('Club not found', HttpStatus.NOT_FOUND);
}
if (admin.role !== 'admin' && compare(admin.role, club?.name)) {
if (admin.role !== 'admin' && !compare(admin.role, club?.name)) {
throw new HttpException('Not admin of club', HttpStatus.UNAUTHORIZED);
}
const item = {
Expand Down
6 changes: 3 additions & 3 deletions packages/server/src/project/project.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class ProjectService {
) {}

async create(admin: Admin, createProjectDto: CreateProjectDto) {
if (admin.role !== 'admin' && compare(admin.role, createProjectDto.club)) {
if (admin.role !== 'admin' && !compare(admin.role, createProjectDto.club)) {
throw new HttpException('Not admin of club', HttpStatus.UNAUTHORIZED);
}
const project = this.projectRepository.create(createProjectDto);
Expand Down Expand Up @@ -57,7 +57,7 @@ export class ProjectService {
}

async update(admin: Admin, id: number, updateProjectDto: UpdateProjectDto) {
if (admin.role !== 'admin' && compare(admin.role, updateProjectDto.club)) {
if (admin.role !== 'admin' && !compare(admin.role, updateProjectDto.club)) {
throw new HttpException('Not admin of club', HttpStatus.UNAUTHORIZED);
}
if (admin.role !== 'admin') {
Expand All @@ -72,7 +72,7 @@ export class ProjectService {

async remove(admin: Admin, id: number) {
const item = await this.projectRepository.findOneBy({ id });
if (admin.role !== 'admin' && compare(admin.role, item?.club)) {
if (admin.role !== 'admin' && !compare(admin.role, item?.club)) {
throw new HttpException('Not admin of club', HttpStatus.UNAUTHORIZED);
}
return this.projectRepository.delete(id);
Expand Down

0 comments on commit 9f0f361

Please sign in to comment.