Refactors verify_email, adds public html

This commit is contained in:
Florent Vilmart
2016-02-25 19:04:27 -05:00
parent 0b307bc22f
commit 7dd765256c
14 changed files with 455 additions and 63 deletions

View File

@@ -0,0 +1,32 @@
var DatabaseAdapter = require('../DatabaseAdapter');
export class UserController {
constructor(appId) {
this.appId = appId;
}
verifyEmail(username, token) {
var database = DatabaseAdapter.getDatabaseConnection(this.appId);
return new Promise((resolve, reject) => {
database.collection('_User').then(coll => {
// Need direct database access because verification token is not a parse field
return coll.findAndModify({
username: username,
_email_verify_token: token,
}, null, {$set: {emailVerified: true}}, (err, doc) => {
if (err || !doc.value) {
reject();
} else {
resolve();
}
});
});
});
}
}
export default UserController;