xMerge branch 'stage' of github.com:whitef0x0/tellform into stage

This commit is contained in:
David Baldwynn 2016-07-04 20:46:22 -04:00
commit 05bfd4c13b
2 changed files with 23 additions and 0 deletions

View File

@ -133,6 +133,28 @@ UserSchema.plugin(mUtilities.timestamp, {
});
UserSchema.pre('find', function (next) {
//Change username if it is still the user's email
if (this.username === this.email) {
var emailUsername = this.email.split('@')[0];
this.username = querystring.stringify({query: emailUsername});
var mailOptions = {
from: '"TellForm Support" <noreply@tellform.com>', // sender address
to: this.email, // list of receivers
subject: 'Your TellForm Username has Changed', // Subject line
text: 'Due to upgrades, your TellForm username has change from ' + this.email + ' to ' + this.username + '. Please use your new username to login.\n Using your old username will not work.\n We apologize for the inconvenience,\n - the TellForm team', // plaintext body
};
transporter.sendMail(mailOptions, function (error, info) {
if (error) {
return console.error(error);
}
console.log('Username change message sent: ' + info.response);
});
}
});
UserSchema.pre('save', function (next) {
//Change username if it is still the user's email

View File

@ -72,6 +72,7 @@ module.exports = function(db) {
var subdomains = req.subdomains;
var host = req.hostname;
if(subdomains.slice(0, 4).join('.')+'' === '1.0.0.127'){
subdomains = subdomains.slice(4);
}