Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add findAll and findOne for admin only usage #661

Merged
merged 6 commits into from
Aug 28, 2024

Conversation

Martbul
Copy link
Contributor

@Martbul Martbul commented Aug 14, 2024

No description provided.

Copy link

github-actions bot commented Aug 14, 2024

✅ Tests will run for this PR. Once they succeed it can be merged.

isAdminFlag = false
} else {
isAdminFlag = true
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for the isAdminFlag. isAdmin already returns a boolean.
You can just do const isAdmin = isAdmin(user) and pass isAdmin to the the findOne service.

throw new NotFoundException('No person found in database')
}
let isAdminFlag
if (!isAdmin(user)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

@sashko9807 sashko9807 added the run tests Allows running the tests workflows for forked repos label Aug 26, 2024
@github-actions github-actions bot removed the run tests Allows running the tests workflows for forked repos label Aug 26, 2024
@@ -18,6 +18,7 @@ describe('CampaignApplicationController', () => {
let controller: CampaignApplicationController
let service: CampaignApplicationService
let personService: PersonService
const { isAdmin } = require('../auth/keycloak')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the ES6 import import {isAdmin} from ../auth/keycloak`, over the require() statement

}
}

async findOne(id: string, isAdminFlag: boolean, person: Person) {
Copy link
Member

@sashko9807 sashko9807 Aug 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit ugly but set the type of the person argument to be

Prisma.PersonGetPayload<{ include: { organizer: {select:{id:true}}}}>

instead of Person to prevent the linter complaint. Also make sure that organizer.id is optional(e.g. person.organizer?.id)

}

findOne(id: string) {
return `This action returns a #${id} campaignApplication`
async deleteFile(id: string, isAdminFlag: boolean, person: Person) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above.

@sashko9807 sashko9807 added the run tests Allows running the tests workflows for forked repos label Aug 28, 2024
@github-actions github-actions bot removed the run tests Allows running the tests workflows for forked repos label Aug 28, 2024
@sashko9807 sashko9807 merged commit d2704c4 into podkrepi-bg:master Aug 28, 2024
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants