Enabling Reset Password and email verification for parse-server hosted locally - parse-server

I am trying to enable reset password and email verification for my parse-server-example installed locally. I could see we have https://github.com/parse-server-modules/parse-mailgun.
But I am not clear how to use parse-mailgun in parse-server-example, I am completely lost with it.
Can somebody explain or suggest steps to enable it?
Regards
Atul

Create account with MailGun, and get apiKey and Domain from its website.
Copy and Paste below configuration under index.js file of your parse-server-example git folder at your local system.You can get this file under parse-server-example folder directly.
verifyUserEmails: true,
publicServerURL: 'https://yourproject.herokuapp.com/parse',
appName: 'Parse App',
emailAdapter: {
module: 'parse-server-simple-mailgun-adapter',
options: {
fromAddress: 'parse#example.com',
domain: '<domainProvidedFromMailGun>.mailgun.org',
apiKey: 'key-FromMailGun',
}
},
Push it to heroku app git, since I have piloted my parse-server to heroku so below cmd's will be valid.
git add .
git commit -m "mypush commit"
heroku git:remote -a fast-springs-29785
git push heroku master

https://github.com/ParsePlatform/parse-server
Email verification and password reset
Verifying user email addresses and enabling password reset via email requries an email adapter. As part of the parse-server package we provide an adapter for sending email through Mailgun. To use it, sign up for Mailgun, and add this to your initialization code:
var server = ParseServer({
...otherOptions,
// Enable email verification
verifyUserEmails: true,
// The public URL of your app.
// This will appear in the link that is used to verify email addresses and reset passwords.
// Set the mount path as it is in serverURL
publicServerURL: 'https://example.com/parse',
// Your apps name. This will appear in the subject and body of the emails that are sent.
appName: 'Parse App',
// The email adapter
emailAdapter: {
module: 'parse-server-simple-mailgun-adapter',
options: {
// The address that your emails come from
fromAddress: 'parse#example.com',
// Your domain from mailgun.com
domain: 'example.com',
// Your API key from mailgun.com
apiKey: 'key-mykey',
}
}
});
You can also use other email adapters contributed by the community such as parse-server-sendgrid-adapter or parse-server-mandrill-adapter.

Related

Google blocks smtp in react-native

I am having trouble with google smtp for sending emails from my app.
The app works fine in my mobile and I am able to send emails without any issue.
But When I publish the app and people start using it, I get a security email from google telling me that it has blocked a login try.
I have even enabled less secure login.
Is there any other settings I should enable?
Here is my code for sending emails
import RNSmtpMailer from 'react-native-smtp-mailer'
async sendEmail(email: string, htmlBody: string, subject: string) {
try {
var settings = await this.getAppSettings();
if (!settings)
throw "Could not find the smtp settings"
var success = await RNSmtpMailer.sendMail({
mailhost: settings.smtp,
port: settings.port,
ssl: true, // optional. if false, then TLS is enabled. Its true by default in android. In iOS TLS/SSL is determined automatically, and this field doesn't affect anything
username: settings.email,
password: settings.password,
fromName: "NovelManager", // optional
replyTo: undefined, // optional
recipients: email,
bcc: [], // optional
subject: subject,
htmlBody: htmlBody,
attachmentPaths: [], // optional
attachmentNames: [], // required in android, these are renames of original files. in ios filenames will be same as specified in path. In a ios-only application, no need to define it
});
return true;
} catch (error) {
return false;
}
}
and here is the smtp settings
{
smtp: "smtp.gmail.com",
port: "465",
email: "test#gmail.com", // not the real email
password: "test"
}
Ok at last I found a solution, And that is using app password instead of simple password.
I am posting the solution here incase anyone is intressted.

Cypress: Login Authentication redirects to another domain: Workaround?

I understand that Cypress does not allow flipping from one domain to another domain because it will error with:
chrome-error://chromewebdata/
However, I need a workaround. I am providing a test set for multiple environments: STAGE, DEMO, PROD.
With DEMO and PROD, during the authentication phase (username/password), stay within the same domain:
VISIT: https://[demo|www].foo.com
AUTH: https://account.foo.com/auth >> username >> password
CONSENT: https://[demo|www].foo.com/action...
With STAGE, the authentication phase flips to another domain:
VISIT: https://[stage].foo.com
AUTH: https://account.bar.com/auth >> username >> password
CONSENT: https://[stage].foo.com/action...
Thereby, Cypress fails to redirect from VISIT to AUTH because of domain flip. This is blocking testing of STAGE.
What recommended workaround approaches?
Puppeteer?
Native Cypress using cy.request()?
Referenced:
Handling Cypress url redirect
Error with authentication in e2e tests using cypress: chrome-error://chromewebdata
Thank you, much appreciate the assistance.
The approach I took is similar to the Cypress Recipe Login with CSRF token
As mentioned, each deployment has its own website URL followed by account login URL.
Needed first is the CSRF token from account login page, which its URL is referred here as $baseUrl:
Cypress.Commands.add('cmdGetCSRF', ($baseUrl) => {
cy.log('COMMAND cmdGetCSRF');
expect($baseUrl)
.to.be.a('string')
.not.empty
cy.request($baseUrl)
.its('body')
.then(($body) => {
const $html = Cypress.$($body)
cy.log('html', $html)
const csrf = $html.find('input[name="__RequestVerificationToken"]').val()
expect(csrf)
.to.be.a('string')
.not.empty
return cy.wrap(csrf)
})
})
Then within body of requestOptions provided to cy.request() which will performing the login, provide one-time CSRF token:
const body: { [key: string]: string } = {
email: $envCypress.account_username,
password: $envCypress.account_password,
__RequestVerificationToken: $csrfToken
};
Cypress has recently add a new experimental feature for running test on multiple origins here. There are examples for cross origin login too. More on experimentalSessionAndOrigin feature:
https://docs.cypress.io/api/commands/origin
https://docs.cypress.io/api/commands/session

How to send encrypted/TLS emails with NodeJS from localhost using send mail

I want to be able to send emails from my local domain without using gmail or other SMTP servers.
I'm currently using SendMail:
const sendmail = require('sendmail') ({
logger: {
debug: console.log,
info: console.info,
warn: console.warn,
error: console.error
},
dkim: {
privateKey: dkimPrivateKey,
keySelector: 'default'
},
});
sendmail({
from: 'foo#mydomain.com',
to: 'mygmail#gmail.com',
subject: 'test sendmail',
html: 'Mail of test sendmail ',
}, function(err, reply) {
console.log(err && err.stack);
console.dir(reply);
});
and this DOES work, BUT when I receive the email in my Gmail account, and I view the message information, Google is marking this as 'security: No encryption'
From what I understand I need to use TLS to create a 'secure' connection. I already have a certificate and keys from LetsEncrypt and my domain is already using HTTPS. How do I encrypt/use TLS my outgoing emails?
Or is there a better package for this? I've tried using NodeMailer and my emails only get added to a 'queue' and never sent. What is the problem?

Parse-server: Reset Password

I am trying to implement my own local parse-server with my application. Everything is working fine except for reseting password for users.
I receive the following error
(node:8729) UnhandledPromiseRejectionWarning: Unhandledpromiserejection
(rejection id: 2): Error: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>404 Not Found</title><h1>Not Found</h1><p>The requested URL was not found on
the server.</p>
<p>If you entered the URL manually please check your spelling and try again.</p>
Do you have the email adapter configured in index.js? As per documentation,
Email verification and password reset
Verifying user email addresses and enabling password reset via email requires an email adapter. As part of the parse-server package we provide an adapter for sending email through Mailgun. To use it, sign up for Mailgun, and add this to your initialization code:
var server = ParseServer({
...otherOptions,
// Your apps name. This will appear in the subject and body of the emails that are sent.
appName: 'Parse App',
// The email adapter
emailAdapter: {
module: 'parse-server-simple-mailgun-adapter',
options: {
// The address that your emails come from
fromAddress: 'parse#example.com',
// Your domain from mailgun.com
domain: 'example.com',
// Your API key from mailgun.com
apiKey: 'key-mykey',
}
},
...otherOptions
});

Sending email through Appcelerator Cloud API

I was trying to send email through Appcelerator Cloud Service, in my Titanium app. The code I'm using is the standart one, given at the documentation site. But the email is not being sent.
Cloud.Emails.send({
template: 'welcome',
recipients: '*******#gmail.com'
},
function (e) {
if (e.success) {
Titanium.API.info('Email sent successfully.');
} else {
Titanium.API.info('Error:\\n' +
((e.error && e.message) || JSON.stringify(e)));
}
});
It give the this error, 'Email template welcome is not found'. I was thinking that template is the message to be sent in email. There is no help on API about this attribute , template. Can anybody explain it to me? I'll be thankful.
Thanx
The error shows that you haven't created an email template on the ACS website yet. The following steps will help you to create email template
Log in to your Appcelerator App Console
click "Manage ACS" under the app you're working on
click the "Email Templates" tab
"Create an Email Template".
also you can setup your SMTP settings as follows which worked for me.
Username: ________#gmail.com
Password: gmail account password
TLS: true/ false (both will work)
SMTP Address: smtp.gmail.com
Port: 587
Domain : www.gmail.com
That error means you haven't created an email template on the ACS website yet. Log in to your Appcelerator App Console, click "Manage ACS" under the app you're working on, then click the "Email Templates" tab, and "Create an Email Template".