Add email verification and notifications

This commit
- [x] Fixes the flash notice color (Trivial)
- [x] Adds flash message for user with no email.
- [x] Adds checks to see if user's email is verified, and displays corresponding notification.
- [x] Adds email templates.
This commit is contained in:
Mrugesh Mohapatra
2016-05-07 17:46:39 +05:30
parent bbacbd3d81
commit ff4dfb09da
8 changed files with 135 additions and 64 deletions

View File

@@ -1,6 +1,7 @@
import { Observable } from 'rx';
import debugFactory from 'debug';
import { isEmail } from 'validator';
import path from 'path';
const debug = debugFactory('fcc:user:remote');
@@ -15,7 +16,6 @@ module.exports = function(app) {
var User = app.models.User;
var UserIdentity = app.models.UserIdentity;
var UserCredential = app.models.UserCredential;
var Email = app.models.Email;
User.observe('before delete', function(ctx, next) {
debug('removing user', ctx.where);
var id = ctx.where && ctx.where.id ? ctx.where.id : null;
@@ -70,21 +70,18 @@ module.exports = function(app) {
to: user.email,
from: 'Team@freecodecamp.com',
subject: 'Welcome to Free Code Camp!',
redirect: '/',
text: [
'Greetings from San Francisco!\n\n',
'Thank you for joining our community.\n',
'Feel free to email us at this address if you have ',
'any questions about Free Code Camp.\n',
'And if you have a moment, check out our blog: ',
'medium.freecodecamp.com.\n\n',
'Good luck with the challenges!\n\n',
'- the Free Code Camp Team'
].join('')
template: path.join(
__dirname,
'..',
'views',
'emails',
'a-extend-user-welcome.ejs'
),
redirect: '/'
};
debug('sending welcome email');
return Email.send(mailOptions, function(err) {
return user.verify(mailOptions, function(err) {
if (err) { return next(err); }
return req.logIn(user, function(err) {
if (err) { return next(err); }