Skip to content

Instantly share code, notes, and snippets.

View funador's full-sized avatar

Jesse Heaslip funador

View GitHub Profile
const { CLIENT_ORIGIN } = require('../config')
// This file is exporting an Object with a single key/value pair.
// However, because this is not a part of the logic of the application
// it makes sense to abstract it to another file. Plus, it is now easily
// extensible if the application needs to send different email templates
// (eg. unsubscribe) in the future.
module.exports = {
confirm: id => ({
module.exports = {
confirm: 'Email sent, please check your inbox to confirm',
confirmed: 'Your email is confirmed!',
resend: 'Confirmation email resent, maybe check your spam?',
couldNotFind: 'Could not find you!',
alreadyConfirmed: 'Your email was already confirmed'
}
const nodemailer = require('nodemailer')
// The credentials for the email account you want to send mail from.
const credentials = {
host: 'smtp.gmail.com',
port: 465,
secure: true,
auth: {
// These environment variables will be pulled from the .env file
user: process.env.MAIL_USER,
const mongoose = require('mongoose')
const Schema = mongoose.Schema
// Data we need to collect/confirm to have the app go.
const fields = {
email: {
type: String
},
confirmed: {
type: Boolean,
const User = require('../user.model')
const sendEmail = require('./email.send')
const msgs = require('./email.msgs')
const templates = require('./email.templates')
// The callback that is invoked when the user submits the form on the client.
exports.collectEmail = (req, res) => {
const { email } = req.body
User.findOne({ email })
require('dotenv').config()
const express = require('express')
const mongoose = require('mongoose')
const cors = require('cors')
const app = express()
const emailController = require('./email/email.controller')
const { PORT, CLIENT_ORIGIN, DB_URL } = require('./config')
// Only allow requests from our client
import React from 'react'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faSync } from '@fortawesome/free-solid-svg-icons'
export default props =>
<div className={`fadeIn ${props.spinning}`}>
<FontAwesomeIcon icon={faSync} size={props.size} />
</div>
import React, {Component} from 'react'
import { Link } from 'react-router-dom'
import { notify } from 'react-notify-toast'
import Spinner from './Spinner'
import { API_URL } from '../config'
export default class Confirm extends Component {
// A bit of state to give the user feedback while their email
// address is being confirmed on the User model on the server.
import React, { Component } from 'react'
import { notify } from 'react-notify-toast'
import Spinner from './Spinner'
import { API_URL } from '../config'
export default class Landing extends Component {
// A bit of state to give the user feedback while their email address is being
// added to the User model on the server.
state = {
import React, { Component } from 'react'
import { BrowserRouter, Route, Redirect, Switch } from 'react-router-dom'
import Notifications from 'react-notify-toast'
import 'react-toastify/dist/ReactToastify.css'
import Landing from './components/Landing'
import Confirm from './components/Confirm'
import Spinner from './components/Spinner'
import Footer from './components/Footer/Footer'
import { API_URL } from './config'