Lookup for email in username field to match docs if email is undefined (#2732)

* Lookup for email in username field to match docs if email is undefined

* Adds support for sendMail option to when email is selected

* Proper does not exists clause
This commit is contained in:
Florent Vilmart
2016-09-18 18:32:34 -04:00
committed by GitHub
parent 7e037ffa72
commit e30989c7d3
3 changed files with 53 additions and 3 deletions

View File

@@ -125,7 +125,7 @@ export class UserController extends AdaptableController {
}
setPasswordResetToken(email) {
return this.config.database.update('_User', { email }, { _perishable_token: randomString(25) }, {}, true)
return this.config.database.update('_User', { $or: [{email}, {username: email, email: {$exists: false}}] }, { _perishable_token: randomString(25) }, {}, true)
}
sendPasswordResetEmail(email) {
@@ -181,7 +181,7 @@ export class UserController extends AdaptableController {
"You requested to reset your password for " + appName + ".\n\n" +
"" +
"Click here to reset it:\n" + link;
let to = user.get("email");
let to = user.get("email") || user.get('username');
let subject = 'Password Reset for ' + appName;
return { text, to, subject };
}