remove email verification step.
users are marked for future uses
This commit is contained in:
@@ -12,6 +12,7 @@ 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;
|
||||
@@ -41,4 +42,51 @@ module.exports = function(app) {
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
// set email varified false on user email signup
|
||||
// should not be set with oauth signin methods
|
||||
User.beforeRemote('create', function(ctx, user, next) {
|
||||
var body = ctx.req.body;
|
||||
if (body) {
|
||||
body.emailVerified = false;
|
||||
}
|
||||
next();
|
||||
});
|
||||
|
||||
// send welcome email to new camper
|
||||
User.afterRemote('create', function(ctx, user, next) {
|
||||
debug('user created, sending email');
|
||||
if (!user.email) { return next(); }
|
||||
|
||||
var mailOptions = {
|
||||
type: 'email',
|
||||
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: ',
|
||||
'blog.freecodecamp.com.\n',
|
||||
'Good luck with the challenges!\n\n',
|
||||
'- the Free Code Camp Volunteer Team'
|
||||
].join('')
|
||||
};
|
||||
|
||||
debug('sending welcome email');
|
||||
Email.send(mailOptions, function(err) {
|
||||
if (err) { return next(err); }
|
||||
ctx.req.logIn(user, function(err) {
|
||||
if (err) { return next(err); }
|
||||
|
||||
ctx.req.flash('success', {
|
||||
msg: [ 'thanks for joining freecodecamp!' ]
|
||||
});
|
||||
ctx.res.redirect('/');
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
Reference in New Issue
Block a user