Password reset & Email verification using Parse server


This part covers the how to send email for password reset and email verification as like parse.com’s earlier feature, but using your own hosted parse server. This tutorial assumes you have already hosted your parse server and your app is working fine using Heroku & mLab as parse server and database.

Hope you have already installed and deployed Heroku CLI on your system, if not, follow below steps. same steps are listed under your deploy option in the heroku app.

Install the Heroku Toolbelt

Download and install the Heroku Toolbelt or learn more about the Heroku Command Line Interface.

$ heroku login

Clone the repository
Use Git to clone app’s source code to your local machine.

$ heroku git:clone -a your-app-name
$ cd appsstudio

Deploy your changes

Make some changes to the code you just cloned and deploy them to Heroku using Git.

$ git add .
$ git commit -am "make it better"
$ git push heroku master

Usually you may get error like below .

fatal: 'heroku' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

And solution for that is connecting your app for remote using

heroku git:remote -a your-app-name

Now you would have folder on your system with your app-name, copy required files to it, at least you need below files:

  1. index.js
  2. package.json
  3. create “cloud” folder — this would be used for cloud code
  4. create “certificates” folder – this would be used for storing push notification for iOS

Add below blue code into index.js and that would enable the password reset & email verification.

var api = new ParseServer({
  databaseURI: databaseUri || 'mongodb://localhost:27017/dev',
  cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
  appId: process.env.APP_ID || "Car Express",
  masterKey: process.env.MASTER_KEY || '', //Add your master key here. Keep it secret!
  serverURL: process.env.SERVER_URL || 'https://car-express.herokuapp.com/parse',  // Don't forget to change to https if needed
  liveQuery: {
    classNames: ["Posts", "Comments"] // List of classes to support for query subscriptions
  },
emailAdapter: {
 module: 'parse-server-simple-mailgun-adapter',
 options: {
 fromAddress: process.env.EMAIL_FROM || "email-from@example.com",
 domain: process.env.MAILGUN_DOMAIN || "example.com",
 apiKey: process.env.MAILGUN_API_KEY || "API-Key",
 // Verification email subject
 verificationSubject: 'Please verify your e-mail for %appname%',
 // Verification email body
 verificationBody: 'Hi,\n\nYou are being asked to confirm the e-mail address %email% with %appname%\n\nClick here to confirm it:\n%link%',

// Password reset email subject
 passwordResetSubject: 'Password Reset Request for %appname%',
 // Password reset email body
 passwordResetBody: 'Hi,\n\nYou requested a password reset for %appname%.\n\nClick here to reset it:\n%link%',
 //OPTIONAL (will send HTML version of email):
 passwordResetBodyHTML: "<!--DOCTYPE html>........"
 }
 }
});

If you have Mailgun account, add below config variables under Settings –> Reveal Configs Vars

  • EMAIL_FROM                                  — info@example.com
  • MAILGUN_API_KEY                      — key-xxxxxxx (get from your mailgun account)
  • MAILGUN_DOMAIN                      — example.com
  • MAILGUN_PUBLIC_KEY              — public-xxxx (get from your mailgun account)
  • MAILGUN_SMTP_LOGIN             — usually postmaster@your-domain.com
  • MAILGUN_SMTP_PASSWORD   — xxxxxxxxxx (default STMP password)

You’re all set with setup for password reset and email verification functionality, you can start using these features just like on parse.com

I’ve recently did migration for my apps which were hosted on the Parse.com, so thought to put all steps together here for different parts of the migrations. Parse itself has great documentation on Github, with some minor changes, you should be able to use that documentation. Here I’m covering the parts which may be questions for newbies who don’t know much about Node.js or overall backend and any issues I came across during migration. I would be covering below topics either in this blog or subsequent blogs.

  1. Migrate from Parse.com to Parse server on Heroku & mLab
  2. Hosting Parse Dashboard
  3. Password reset & Email verification using Parse server
  4. Cloud code on Parse server
  5. Push notification using Parse server

Gmail is getting smarter


In recent time there has been great innovation from Google on email service. Be it Inbox, or option to recall the email within few seconds from the time you sent it or predictive analysis. Screen Shot 2015-06-09 at 10.45.41 PM

Inbox started well but overall nothing much new apart from reorganizing the Gmail! But when it comes to other features it’s great innovative thinking and solving the problem. Many times when we send email and realize OOPS! and there comes Gmail’s recall feature comes to help. Another excellent feature avoids another OOPS movement, after sending email realizing missed to attach the attachment. Gmail checks the text and proactively alerts you didn’t attach the attachment but your text shows you wanted to attached. Good catch. Keep up Gmail team!

New New Distractions


Apple CEO, Tim Cook took dig at Google user saying “You’re Not the Customer. You’re the Product”.  With the new consumer services and social phenomenon, it’s quite obvious with many of services we use every day for majority of the time in the day.

How many times it happens as you open your laptop or smartphones to do something like reading an article and you end up from one link to another to some other news or video on YouTube to some update from Facebook friend and at the end spending couple of hours on it? It’s like going to Grocery store for buying Gallon of milk and end up spending $100 and cart full of goods.

Some apps we see as productivity tool and that end up with another distraction from main course. Whether its Facebook feeds , twitters updates, notification on iPhone/Smartphone with one or other update may be for new message on WhatsApp or some new update for software, all are taking one step away from focused time.

Certainly, we can’t bluntly say, get the crap out and focus on something. These new way to connect people or get notified are required but with controlled access. We can do many things starting from turning off wi-fi to deleting few apps or blocking some sites but most important thing is “Self Control” and focus to get the task done and forget everything else.

One way, to get away from distracting thoughts is, give them a way by spelling it out. I mean write them down so they are out of your mind. That means even if you require, any of that, you have them written down.

Email trick for subscription


I’ve few email subscription for my personal email id, like Seth Godin or Robin Sharma’s blog email. These are something I would like to read when I have some time. Whenever we see new email, its human tendency to see the email and either read or ignore. For me, it use to be half way, open the email but may not be completing it due to one or other reason. Reading those blog’s is important but not urgent. I was thinking for option to get best of these email without spending much time.

Other day, I added one new rule for my incoming email that mark those “Subscription” and change status from unread to read email. Now I don’t see those emails when I open my inbox but I do have those email cumulate at one place to read whenever I’ve some time and right mindset.

This trick worked very well.