-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
Error thrown when trying to promote guest user to admin #892
Conversation
It works, but Zod is throwing a type error. @rmunn will follow up on this with more details. |
When you use the z.refine() function, it changes the type from ZodObject to ZodEffects, and some Zod type definitions don't apply to ZodEffects. Thankfully it's simple enough to split the schema and the refined schema into two objects and pass each one to the appropriate functions.
Type error fixed with commit 4085759. |
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 couple of changes needed, then this can be merged.
frontend/src/routes/(authenticated)/admin/EditUserAccount.svelte
Outdated
Show resolved
Hide resolved
frontend/src/routes/(authenticated)/admin/EditUserAccount.svelte
Outdated
Show resolved
Hide resolved
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.
the user must also have a verified email address, so the refinement needs to include that.
Nice job figuring out how zod works and getting the error to show up when there's an issue across multiple fields!
frontend/src/routes/(authenticated)/admin/EditUserAccount.svelte
Outdated
Show resolved
Hide resolved
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.
looks good to me, nice work.
When trying to promote guest user without an email to site admin, it throws an error.
To prevent this error, we can define a custom validation check on the schema.