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

Error thrown when trying to promote guest user to admin #892

Merged
merged 5 commits into from
Jul 8, 2024

Conversation

psh0078
Copy link
Collaborator

@psh0078 psh0078 commented Jun 20, 2024

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.

@psh0078
Copy link
Collaborator Author

psh0078 commented Jun 20, 2024

It works, but Zod is throwing a type error. @rmunn will follow up on this with more details.

Copy link

github-actions bot commented Jun 20, 2024

UI unit Tests

11 tests  ±0   11 ✅ ±0   0s ⏱️ ±0s
 3 suites ±0    0 💤 ±0 
 1 files   ±0    0 ❌ ±0 

Results for commit 6dfbc05. ± Comparison against base commit 9fb48c4.

♻️ This comment has been updated with latest results.

@psh0078 psh0078 linked an issue Jun 20, 2024 that may be closed by this pull request
@psh0078 psh0078 marked this pull request as ready for review June 21, 2024 02:23
@psh0078 psh0078 self-assigned this Jun 25, 2024
@hahn-kev hahn-kev self-requested a review July 1, 2024 02:36
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.
@rmunn
Copy link
Contributor

rmunn commented Jul 1, 2024

Type error fixed with commit 4085759.

Copy link
Contributor

@rmunn rmunn left a 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.

@psh0078 psh0078 requested a review from rmunn July 1, 2024 06:05
Copy link
Collaborator

@hahn-kev hahn-kev left a 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!

@psh0078 psh0078 requested a review from hahn-kev July 4, 2024 07:12
Copy link
Collaborator

@hahn-kev hahn-kev left a 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.

@psh0078 psh0078 merged commit 00ec9a5 into develop Jul 8, 2024
9 checks passed
@myieye myieye deleted the bug/promote-guest-to-admin branch January 14, 2025 11:05
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.

error thrown when trying to promote guest user to admin
3 participants