-
Notifications
You must be signed in to change notification settings - Fork 3
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
Siddev3 #427
base: main
Are you sure you want to change the base?
Siddev3 #427
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,35 @@ | ||||||||
import { AccessControlList } from '@stex-react/api'; | ||||||||
import { NextApiRequest, NextApiResponse } from 'next'; | ||||||||
import { executeAndEndSet500OnError, executeDontEndSet500OnError } from '../comment-utils'; | ||||||||
import { ACLMembership } from './acl-membership'; | ||||||||
|
||||||||
export default async function handler(req: NextApiRequest, res: NextApiResponse) { | ||||||||
const id = req.query.id as string; | ||||||||
if (!id) return res.status(422).send(`Missing param id.`); | ||||||||
const acls: any[] = await executeAndEndSet500OnError( | ||||||||
`SELECT * FROM AccessControlList where id = ?`, | ||||||||
[id], | ||||||||
res | ||||||||
); | ||||||||
const dbAcl = acls?.[0]; | ||||||||
if (!dbAcl) return res.status(404).send(`No ACL with id [${id}].`); | ||||||||
Comment on lines
+14
to
+15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
|
||||||||
const members: ACLMembership[] = await executeAndEndSet500OnError( | ||||||||
'SELECT * FROM ACLMembership WHERE parentACLId = ?', | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
[id], | ||||||||
res | ||||||||
); | ||||||||
const directMembers = members.map((m) => m.memberUserId).filter((u) => u); | ||||||||
if (directMembers.length === 0) { | ||||||||
return res.status(200).send([]); | ||||||||
} | ||||||||
const result: { firstname: string; lastname: string; userId: string }[] = | ||||||||
await executeDontEndSet500OnError( | ||||||||
`select firstname, lastname, userId from userInfo where userId IN (?)`, | ||||||||
[directMembers], | ||||||||
res | ||||||||
); | ||||||||
res | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make sure to also return the members whose entry is not found the database. Return empty string from this API. |
||||||||
.status(200) | ||||||||
.send(result.map((c) => ({ fullName: `${c.firstname} ${c.lastname}`, userId: `${c.userId}` }))); | ||||||||
} |
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.
don't
select *
,select id
is sufficient