get error whe subscription Newsletter. How can fix?
Here is the problem and the solution to this bug:
When we enter an new email address (one that is not connected to an extisting subscriber), the subscriber object ($this) has no id ($this->getId(); // null) yet in Magento\Newsletter\Model\Subscriber::subscribe.
The verification email is sent out before the subscriber is saved, thus the subscriber id is missing from the verification link. The link does not do anything when you click on it because the verification method in Magento\Newsletter\Controller\Subscriber\Confirm::execute rejects the link because of the missing id.
You can easily mend the problem by calling $this->save() before calling $this->sendConfirmationRequestEmail();
try {
$this->save();
if($isConfirmNeed === true && $isOwnSubscribes === false)
{
$this->sendConfirmationRequestEmail();
} else {
$this->sendConfirmationSuccessEmail();
}
return $this->getStatus();
} catch (\Exception $e) {
throw new \Exception($e->getMessage());
}
I simply moved the ''save'''- call a few lines up. sendConfirmationRequestEmail and sendConfirmationSuccessEmail do not seem to alter the $thisobject, so this is a valid change that does not break anything else.
I just changed the "Disable Email Communications" to yes in Magento 2 ( Stores > Configuration > Advanced > System > Mail Sending Settings > Disable Email Communications).
Related
Good day!
I would like to create a Script on Google Sheets that will take the name (as an ID) from the "Your Name" column and tie it to an email address so that once the "x" on the "Completed" column is added, it will automatically send an alert to the email address of the person who made the request.
Screenshot of the Information collected
(the data is filled in Spanish, my apologies)
This should get you started
function onMyEdit(e) {
const sh = e.range.getSheet();
if(sh.getName() == "Your sheet name" && e.range.rowStart > 1 && e.range.columnStart == 7 && e.value.toLowerCase() == "x") {
GmailApp.sendEmail(e.user.email,"Subject","Message");
}
}
I think it should be an installable onEdit since sending emails requires permission
I made the following login function:
#objc func handleSignIn() {
guard let email = emailField.text else { return }
guard let pass = passwordField.text else { return }
Auth.auth().signIn(withEmail: email, password: pass) { user, error in
if error == nil && user != nil && (user!.user.isEmailVerified){
self.dismiss(animated: false, completion: nil)
}; if user != nil && !(user?.user.isEmailVerified)! {
self.lblStatus.text = "Please Verify Your Email"
}
else {
self.lblStatus.text = "Error logging in: \(error!.localizedDescription)"
resetForm()
}
}
Yet the user can still log in without verifying their email despite my attempts to prevent this with the && (user!.user.isEmailVerified) stipulation. What am I missing here?
The completion of a sign in just means that the user identified themselves, and you know which account represents their chosen identity. A sign-in does not imply authorization to do anything with that account, other than to update its profile information.
You'll notice there's a bit of a chicken and egg problem here. A sign-in has to complete successfully in order to get a User object, and that user object has the property which indicates if their email has been verified. So you have to allow a sign-in if you want read that property.
You could, in theory, sign the user out immediately if they haven't verified, but all that does is prevent them from requesting another email verification, in case they deleted the first one, or it wasn't able to be delivered. So now you just have an upset user who can't take any action to resolve the issue.
If you want to prevent the user from doing anything in other Firebase products until they're verified, you should use security rules to prevent whatever read and write access shouldn't be allowed. You can check the email verification flag in your rules. Look into using auth.token.emailVerified. Example for Realtime Database here.
I am using the email verification feature that Parse offers and would like my users to be able to resend the email verification if it fails to send or they cannot see it. Last I saw, Parse does not offer an intrinsic way to do this (stupid) and people have been half-hazzerdly writing code to change the email and then change it back to trigger a re-send. Has there been any updates to this or is changing the email from the original and back still the only way? Thanks
You should only need to update the email to its existing value. This should trigger another email verification to be sent. I haven't been able to test the code, but this should be how you do it for the various platforms.
// Swift
PFUser.currentUser().email = PFUser.currentUser().email
PFUser.currentUser().saveInBackground()
// Java
ParseUser.getCurrentUser().setEmail(ParseUser.getCurrentUser().getEmail());
ParseUser.getCurrentUser().saveInBackground();
// JavaScript
Parse.User.current().set("email", Parse.User.current().get("email"));
Parse.User.current().save();
You have to set the email address to a fake one save and then set it back to the original and then parse will trigger the verification process. Just setting it to what it was will not trigger the process.
iOS
if let email = PFUser.currentUser()?.email {
PFUser.currentUser()?.email = email+".verify"
PFUser.currentUser()?.saveInBackgroundWithBlock({ (success, error) -> Void in
if success {
PFUser.currentUser()?.email = email
PFUser.currentUser()?.saveEventually()
}
})
}
Poking around the source code for Parse server, there doesn't seem to be any public api to manually resend verification emails. However I was able to find 2 undocumented ways to access the functionality.
The first would be to use the internal UserController on the server (for instance from a Cloud function) like this:
import { AppCache } from 'parse-server/lib/cache'
Cloud.define('resendVerificationEmail', async request => {
const userController = AppCache.get(process.env.APP_ID).userController
await userController.resendVerificationEmail(
request.user.get('username')
)
return true
})
The other is to take advantage of an endpoint that is used for the verification webpage:
curl -X "POST" "http://localhost:5000/api/apps/press-play-development/resend_verification_email" \
-H 'Content-Type: application/json; charset=utf-8' \
-d $'{ "username": "7757429624" }'
Both are prone to break if you update Parse and internals get changed, but should be more reliable than changing the users email and then changing it back.
We were setting emails to an empty string, but found that there was a race condition where 2 users would hit it at the same time and 1 would fail because Parse considered it to be a duplicate of the other blank email. In other cases, the user's network connection would fail between the 2 requests and they would be stuck without an email.
Now, with Parse 3.4.1 that I'm testing, you can do (for Javascript):
Parse.User.requestEmailVerification(Parse.User.current().get("email"));
BUT NOTE that it will throw error if user is already verified.
Reference:
http://parseplatform.org/Parse-SDK-JS/api/3.4.1/Parse.User.html#.requestEmailVerification
To resend the verification email, as stated above, you have to modify then reset the user email address. To perform this operation in secure and efficient way, you can use the following cloud code function:
Parse.Cloud.define("resendVerificationEmail", async function(request, response) {
var originalEmail = request.params.email;
const User = Parse.Object.extend("User");
const query = new Parse.Query(User);
query.equalTo("email", originalEmail);
var userObject = await query.first({useMasterKey: true});
if(userObject !=null)
{
userObject.set("email", "tmp_email_prefix_"+originalEmail);
await userObject.save(null, {useMasterKey: true}).catch(error => {response.error(error);});
userObject.set("email", originalEmail);
await userObject.save(null, {useMasterKey: true}).catch(error => {response.error(error);});
response.success("Verification email is well resent to the user email");
}
});
After that, you just need to call the cloud code function from your client code. From Android client, you can use the following code (Kotlin):
fun resendVerificationEmail(email:String){
val progress = ProgressDialog(this)
progress.setMessage("Loading ...")
progress.show()
val params: HashMap<String, String> = HashMap<String,String>()
params.put("email", email)
ParseCloud.callFunctionInBackground("resendVerificationEmail", params,
FunctionCallback<Any> { response, exc ->
progress.dismiss()
if (exc == null) {
// The function executed, but still has to check the response
Toast.makeText(baseContext, "Verification email is well sent", Toast.LENGTH_SHORT)
.show()
} else {
// Something went wrong
Log.d(TAG, "$TAG: ---- exeception: "+exc.message)
Toast.makeText(
baseContext,
"Error encountered when resending verification email:"+exc.message,
Toast.LENGTH_LONG
).show()
}
})
}
this is a wordpress related question. I was wondering while using the ninja forms plugin, if it is possible to restrict the submission process to only allow #example.com email address to successfully submit the form.
Any ideas? I appreciate the time and responses from you all.
Please post the code for your form (even the generated html) so that the question stands the test of time!
You can do something like this in jQuery:
$('#signup').submit(function() {
validateEmail($('input').val());
return false;
});
function validateEmail(email) {
var re = /^\s*[\w\-\+_]+(\.[\w\-\+_]+)*\#[\w\-\+_]+\.[\w\-\+_]+(\.[\w\-\+_]+)*\s*$/;
if (re.test(email)) {
if (email.indexOf('#c-e.com', email.length - '#c-e.com'.length) !== -1) {
alert('Submission was successful.');
} else {
alert('Email must be a CE e-mail address (your.name#c-e.com).');
}
} else {
alert('Not a valid e-mail address.');
}
}
I found it in this working fiddle by Erik Woods:
http://jsfiddle.net/AkuXC/86/
I previously asked a similar question about ejabberd, however ejabberd was giving other problems, so I switched to openfire. For the sake of not making the original qestion to cluttered, I decided to create a new question, since this question pertains to openfire and is a different issue than the one I was having with ejabberd.
So, here goes the question:
I have a strophe.js xmpp client, which connects to an openfire 3.10.0 alpha server running on the Amazon cloud. I need 3.10.0 alpha over 3.9.3 because of a bfix which is included in the former, but not the latter.Anyway, since this is a strophe client, I have enabled bosh, and I can see it running at myAWSDNS.com:7070. I am able to connect to the server via my client using this bosh service and existing accounts, and send messages back and forth so it seems to be functioning ok.
I would also like to add in-band registration, for which I use strophe.register.js
This is the code I use for this:
var tempConn = new Strophe.Connection("http//myAWSDNS.com:7070/http-bind/");
tempConn.register.connect("myAWSDNS.com", function (status) {
if (status === Strophe.Status.REGISTER) {
// fill out the fields
connection.register.fields.username = "juliet";
connection.register.fields.password = "R0m30";
// calling submit will continue the registration process
connection.register.submit();
} else if (status === Strophe.Status.REGISTERED) {
console.log("registered!");
// calling login will authenticate the registered JID.
connection.authenticate();
} else if (status === Strophe.Status.CONFLICT) {
console.log("Contact already existed!");
} else if (status === Strophe.Status.NOTACCEPTABLE) {
console.log("Registration form not properly filled out.")
} else if (status === Strophe.Status.REGIFAIL) {
console.log("The Server does not support In-Band Registration")
} else if (status === Strophe.Status.CONNECTED) {
// do something after successful authentication
} else {
// Do other stuff
}
});
This seems to work fine, as it enters the first if-bracket (status === Strophe.Status.REGISTER), and tries to set connection.register.fields.username = "juliet";
However, here, when executing that line, it jumps into strophe.js line 2476:
if (this.connect_callback) {
try {
this.connect_callback(status, condition);
} catch (err) {
Strophe.error("User connection callback caused an " +
"exception: " + err);
}
}
where 2476 is the code in the catch(err) { ...... } bracket.
If I inspect err, this is what I get:
So message: connection is not defined and, obviously, the regstration doesnt work, and I am not sure why. Does anyone have any input on this?
Thanks, and best regards,
Chris
You might not like this answer... The reason for connection == undefined is because you named it tempConn.