Default reset password email not sent via Appcelerator backend, nor emails with a template, only email configuration changes are sent - titanium

When I execute the following code,
Cloud.Users.requestResetPassword({
email: myUsersEmailAddress
}, function (e) {
if (e.success) {
Ti.API.info('Success: Reset Request Sent ' + JSON.stringify(e));
} else {
Ti.API.error('Error:\n' + ((e.error && e.message) || JSON.stringify(e)));
}
});
I should receive an email to reset my password, as seen in the documentation:
GET users/request_reset_password.json Sends an email to a user
containing a link to recover a lost password. You can use the default
email template provided by ACS, or specify a custom email template
that you have created. When using a custom email template, the email
must contain a properly formatted URL, as explained in the template
method parameter documentation below.
When the alert pops up, I can see that there was a match and that an email should have been sent.
However, I do not receive an email, nor do I see anything in the logs of my email backend (which does receive an email when I adapt my email configuration on the appc backend, thus my email is correctly configured)
I don't have any email templates configured, but according to the documentation it should use appc's default reset password email.
Does anyone has an idea about what I am doing wrong, or does this indicate an issue with appc's documentation or backend?
UPDATE: I have another function which sends email using a self-defined email template. When I invoke this function, i receive the following event(between the {}):
[INFO] : Deactivation email sent. {"success":true,"error":false,"meta":{"status":"ok","code":200,"method_name":"emailFromTemplate"}}
However, nothing is seen on our smtp backend. The only things we do see (and which we receive in our mailbox) are the emails which are sent when you adapt your email configuration settings in Appcelerator's backend, eg.
Subject: Appcelerator Cloud Services SMTP Test
Appcelerator Logo Hi Peter,
Your SMTP settings have been updated successfully!
Onward,
The Appcelerator Platform Team
Thanks,
David

It turned out to be a configuration issue, which could only be discovered by doing some curl calls against the api. So a good advice, test your config with curl too, and don't rely on the emails which are sent after you made a configuration change!

Related

Firebase functions auth.generateEmailVerificationLink() generating link with wrong apiKey

I have a Firebase functions project with dev and prod versions. There I'm using auth.generateEmailVerificationLink() to send email verification for a newly created user. Everything works well except in prod environment (testing locally or hosted) the apiKey in the link generated by auth.generateEmailVerificationLink() is not same as Firebase's default apiKey. And clicking that link I get the page with error code:
Try verifying your email again
Your request to verify your email has expired or the link has already been used
Note that when I get the link with the wrong apiKey, if I change it to the right apiKey. the verification works. So it seems the whole problem is related to the wrong apiKey in generated email verification link.
Also to note that the wrong apiKey is not random key but used in project front end for Google Maps apis.
The code itself is simple. (I'm leaving out code which creates user etc as those parts all work perfectly)
-Initializing Admin SDK:
import { initializeApp } from 'firebase-admin/app';
import { getAuth } from 'firebase-admin/auth';
initializeApp();
const auth = getAuth();
export { auth };
-Generating email verification email
const sendEmail = async () => {
const actionCodeSettings = {
// This url is working correctly, it is the same as in Firebase console
// and when changing the wrong apiKey to correct redirecting works correctly
url: process.env.DOMAIN as string,
};
await auth
.generateEmailVerificationLink(email, actionCodeSettings) // email is the email of newly created user
.then((link) => {
// generate email message with link
// generate mailOptions
// use transporter to send email
});
};
Thank you for any help
EDIT
I tested deleting that "wrong" apiKey from GCP credentials page and replaced it with another. Then running the function locally everything worked normally but the "wrong" is still in the verification email link even tho it doesn't exist anymore.
Firebase strongly recommends that if Admin SDK is used in Cloud Functions, among others, initializing the app should be done without parameters.
https://firebase.google.com/docs/admin/setup#initialize-without-parameters
For me it seems something is for some reason pulling that "wrong" and now even deleted apiKey from somewhere to usage.
I solved this by noticing that, unlike in dev project, Web Api Key (Project Settings>General) is different than Web App's firebaseConfig apiKey.
So I added correct permission to this Web Api Key (Identity Toolkit API is required for email verification email) found in GCP credentials and now the cloud function sends email verification emails with correct and working apiKey.

Gmail sending problems

So i try smtplib to send gmail automatically, however it fail because of a error, after some checking, my username and pass are True. So i want to ask if there were any mistakes that can lead to this error.
Here is my code, the port is 465 and i don't want anyone know my pass and my username.
The error message "username and password not accepted" is the standard error message you get from the smtp server when sending the users actual google password.
This method of authentication is not acceptable by the SMTP server after (May 30, 2022). Partially due to the removal of Less secure apps & your Google Account mostly because client login is not considered to be secure.
Your options are to to enable 2fa on our google account and use and create an apps password. Simply use it in place of the password in your code.
smtp.login(username, appsPasswrod)
Or to use XOauth2 and authenticate the application.
Create a sendEmail() function, which will help to send emails to one or more than one recipient by calling the function.
def sendEmail(to, content):
server = smtplib.SMTP('smtp.gmail.com', 587)
server.ehlo()
server.starttls()
server.login('youremail#gmail.com', 'your-password')
server.sendmail('youremail#gmail.com', to, content)
server.close()
content = "Message to send"
to = "useremail#gmail.com"
sendEmail(to, content)
NOTE: Do not forget to make sure that the smtplib requires 'enable the less secure apps' feature in your Gmail account. Otherwise, the sendEmail function will not work properly..
Create App Password: App Passwords

Auth0 verification email not sending email parameter in return URL parameters

I have auth0 setup to send a Verification Email (using Link) and a redirect URL - http://localhost:3000/app/registration
When I create a user it’s working and they get the email, and it redirects with this URL:
http://localhost:3000/app/registration?supportSignUp=true&supportForgotPassword=true&message=Your%20email%20was%20verified.%20You%20can%20continue%20using%20the%20application.&success=true&code=success#
The problem is: according to this link, it should include the email address of the registered user; however, it is not. Is there a reason for this? If I could simply pass the email, I could make an API call and complete the registration process through the auth0 API.
My intention is to send the user to a special registration page on my single page application site where they can finish the registration process and set their password. Any help with this would be appreciated - thanks!

AWS Cognito - Resend Verification Link to an User

I'm building an application with AWS Cognito and AWS AppSync.
My Problem:
I want to an User, after signUp, for some reason (not important) he did not receive the Verification E-mail (which is a Link, not a Code).
The user goes back to the application and asks for another Verification E-mail.
Tried:
I tried the following solutions,
-> Using resendConfirmationCode function of AWS-SDK.
-> Using Auth Amplify API with the function resendSignUp[
-> Using the following npm package (https://www.npmjs.com/package/amazon-cognito-identity-js) Use Case #3
I Always end up on this message: "Cannot reset password for the user as there is no registered/verified email or phone_number"
I want that the function resends the verification Link to an User, so he does not have a E-mail verified yet.
What do I expect?
If the user does not receive an E-mail with the verification Link, he can use a function to call again for this e-mail.
As I'm working with Links, I would rather prefer a Link for this, but if is not possible, a Code will be fine, and I change it on Cognito Lambda-Triggers.
Hope you guys be able to help me :)

How to generate tokens for mail verify or forgot password without FusionAuth sending mail?

Until yesterday I was using the default mechanism of sending mails like "verify mail" or "forgot password mail". These mails have specials tokens included inside the mail. Both of these endpoint also returns tokens in the response body.
I am now changing the way of sending mails in my application and I want to do it with a separate service. So to activate my users or change their password I need these tokens, but I dont want FusionAuth to send emails. When disabling "verify mails" or "forgot password", calling these endpoints results in a 403. Is there a way to get this tokens without starting the process of sending a mail by FusionAuth ?
The workaround is to add a fake host to the mail config. But it isn't the best idea since I see then an error in logs when generating tokens.
You can use the /api/user/forgot-password API and set sendForgotPasswordEmail to false.
In the Forgot Password API it is the second example :
Start the forgot password workflow using an API key
This will create you a token and will not send the email. You can then build the link yourself and send the email through an external service.