Skip to content

Handle missing Discord email sooner. Make sure emails are verified. #390

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

Merged
merged 1 commit into from
Feb 28, 2025

Conversation

infomiho
Copy link
Collaborator

@infomiho infomiho commented Feb 26, 2025

This PR:

  • Prevents user to sign up with Discord if they don't have an email
  • Makes sure that the provided OAuth email is verified before used to set the isAdmin field
  • Shows error message on the pricing page if something goes wrong
Screenshot 2025-02-26 at 15 29 26

@infomiho infomiho requested review from sodic and vincanger February 26, 2025 14:32
Copy link
Collaborator

@sodic sodic 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.

I left just one question out of curiosity

'User needs an email to make a payment. If using the usernameAndPassword Auth method, switch to an Auth method that provides an email.'
);
// If using the usernameAndPassword Auth method, switch to an Auth method that provides an email.
throw new HttpError(403, 'User needs an email to make a payment.');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to double check: you removed the details because this is a user-facing error?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it didn't feel correct to give developer instructions in a user-facing error.

Comment on lines +16 to +19
- isAdmin: (data) => {
- const emailData = emailDataSchema.parse(data);
- return adminEmails.includes(emailData.email);
- },
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How come the example app removes this isAdmin check.

I can see it also does this in the old version of the code, but why?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the example app everyone is an admin so they can test out the admin panel :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you visit https://opensaas.sh/admin you'll notice you can see it with any account.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I had a feeling it has something to do with that.

But does that mean that the default behavior is that "if "adminicity" isn't defined, everyone is an admin?"

you'll notice you can see it with any account.

For this feature, I'd expect isAdmin to be a function that just returns true.

Copy link
Collaborator Author

@infomiho infomiho Feb 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default is set to true in the Prisma schema in the opensaas.sh. Should we create an issue to change that? I think this is fine, it's a demo app we maintain.

@infomiho infomiho merged commit 4368b12 into main Feb 28, 2025
1 check passed
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.

2 participants