-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Conditional email verification #7144
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
Thanks for suggesting. I added the link to your forum post for reference.
There may also be other places where a change is necessary, for example on login. I'm not sure this should be an option in the sign-up method, because a malicious user could just change that option and do a REST sign-up to circumvent the restriction. Therefore I think a solution that is completely controlled server side would make more sense. Since you already talk about "multiple groups of users", maybe this could be depending on the Role a user is assigned, but there might be simpler approaches. Do you want to look into the email verification mechanism (mainly in |
Possible approaches to discuss:
To extend the existing
|
That has been suggested by @Samigos and that is not an approach we'd pursue. It allows the client to determine whether an email needs to be verified. Only the server should have that authority. If you want to let the client decide you could use the
You can currently use the For example: Parse.Cloud.beforeSave(Parse.User, async req => {
console.log(req.requireEmailVerification); // prints "true" or "false" depending on the Parse Server option setting
req.requireEmailVerification = true; // override Parse Server option and require email verification for the user
req.requireEmailVerification = false; // override Parse Server option and don't require email verification for the user
}); |
The changes in the PR ignore the value of |
Equipping a client with the master key is something we do not advice, so this becomes a non-feature for most applications. Since we don't want to provide the same feature in multiple ways, we'd look for a solution that is universal and usable for most applications. I've added an example to maybe give a better idea of (a). Do you think that would cover your required feature? |
The clients do not have the master key, so they won't have the option to bypass the verification. I don't immediately see how (a) would be useful to us, as the information about whether the email verification should be bypassed or not would not be available to the trigger, but to the party issuing the request (with the master key). |
I had another look at your PR. If I understand it correctly, you want to set the user email to be verified, without the user verifying it. But in the issue you also write:
That is something that seems to be related to this feature here. With (a) you would disable the email verification for the user (i.e. suppress sending of the verification email), then in Cloud Code you would use the master key to set So the scope of #8230 is actually 2 functionalities:
Is that correct? |
True. In #8231, these two functionalities are atomic with respect to each other. Using the masterKey to set |
I think we'd want to split this into 2 separate features, it seems each of them have valid use cases on their own, so they shouldn't be depending on each other. Can we address them in 2 separate PRs? |
The master key can already set the |
The context object in the # method. Whatever you add to the Parse.Cloud.beforeSave(Parse.User, async req => {
console.log(req.context.sendEmailVerificationEmail); // prints "true" or "false" depending what is passed in `Parse.User.#(context)`
console.log(req.requireEmailVerification); // prints "true" or "false" depending on the Parse Server option setting
// Override Parse Server behavior
req.setEmailVerified = true; // sets the email to verified for the user
req.setEmailVerified = false; // sets the email to unverified for the user
req.setSendEmailVerificationEmail = true; // Sends the email verification email
req.setSendEmailVerificationEmail = false; // Doesn't send the email verification email
}); Maybe Such a concept allows for example to set the Parse Server option to not require email verification for users by default. For a certain user (e.g. with suspicious activity) email verification could be required. |
I don't see why the master key should not be able to bypass email verification. Sounds like a step backwards to me compared to #8231.
My point exactly. The master key can already set
That's a good point. The server deciding, during the # process, whether the user should be verified certainly is a different use case. This can be implemented using #8231, but it is somewhat tricky: One would need to disallow direct #s by removing public write permission from the _User CLP and create a cloud function that creates # requests using the master key with the Or we could modify #8231 such that |
Some insight on the last point in my previous message for future reference: RestWrite.js runs beforeSave triggers first, and then calls |
Yes, I agree that the master key should be able to do that just like with any other non-internal field. Maybe your PR can focus on that part only.
As I said, we don't encourage (even though you may have a use case for it), to use the master key on the client side. So any feature suggestion that requires the master key to be used on the client side is considered a "non-feature", or at most it can be a supplemental functionality, but the main feature must be usable without exposing the master key to a client. Good that you've already studied the code for possible implementations. On a more conceptual level, it seems we are talking about separate functionalities:
I'm still not entirely sure from #8231 how your process would be, but it may only require (a) and not even (b).
The benefit of not using (b) is that you don't "fake-verify" the user's email address, which would pollute your data and there would be no way of telling which verification is genuine. If at a later point you decide to require verification also from that user, you would simply change the trigger logic, without having to deal with polluted data. |
🎉 This change has been released in version 6.3.0-alpha.2 |
🎉 This change has been released in version 6.4.0-beta.1 |
🎉 This change has been released in version 6.4.0-alpha.1 |
🎉 This change has been released in version 6.4.0 |
New Feature / Enhancement Checklist
Current Limitation
There are occasions where there are multiple groups of users in an app and email verification is needed only to some of them! Right now, Parse Server offers an option of enabling email verification upon #, but it becomes unconditional... it either works for everyone, or it does not at all.
Feature / Enhancement Description
To address this limitation, I think there could be a
Boolean
parameter at the#
function that indicates whether email verification is required, or not.Also, see initial forum post.
The text was updated successfully, but these errors were encountered: