-
Notifications
You must be signed in to change notification settings - Fork 47
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
Conversation
✅ Tests will run for this PR. Once they succeed it can be merged. |
isAdminFlag = false | ||
} else { | ||
isAdminFlag = true | ||
} |
There was a problem hiding this comment.
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)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
@@ -18,6 +18,7 @@ describe('CampaignApplicationController', () => { | |||
let controller: CampaignApplicationController | |||
let service: CampaignApplicationService | |||
let personService: PersonService | |||
const { isAdmin } = require('../auth/keycloak') |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above.
No description provided.