-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Adding an admin page to manage a specific user's status #521
Conversation
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.
Formik is okay, I used it one or two times before.
return ( | ||
<> | ||
<Head> | ||
<title>Open Assistant</title> |
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.
Manage Users - Open Assistant
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.
Done.
initialValues={user} | ||
onSubmit={(values) => { | ||
trigger(values); | ||
}} |
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.
nit: onSubmit:trigger
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.
npm run build
really didn't like that due to some type issues. Will leave as is for now.
const token = await getToken({ req }); | ||
|
||
// Return nothing if the user isn't registered or if the user isn't an admin. | ||
if (!token || token.role !== "admin") { | ||
res.status(403).end(); | ||
return; | ||
} |
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.
could we extract these to a middleware?
maybe something like:
const handler = withAdmin(async (token, req, res) => {
...
});
or maybe
const handler = withRole("admin", async (token, req, res) => {
...
});
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.
Done. I looked at using the actual middleware.ts
but it looks a bit too messy. A wrapper is a lot cleaner. makes me miss RedwoodJS where they built this into the graphQL handler.
This includes:
Not done yet: