Add Update Email View
This commit: - Displays the user's email that we have on records - Adds a button in the settings to update email - Adds a form view to update the email - Fixes CSS for the Email icons and the email form ~ Credits to @hallaathrad - Linting fixes and updated with Berkeley's Comments - Streamline checks and fix scope - Add AJAX Calls - Add flash messages - Update the views & add XHR value
This commit is contained in:
@ -306,6 +306,50 @@ module.exports = function(User) {
|
||||
}
|
||||
);
|
||||
|
||||
User.prototype.updateEmail = function updateEmail(email) {
|
||||
if (this.email && this.email === email) {
|
||||
debug('same email as current User', email);
|
||||
return Promise.reject(new Error(
|
||||
`${email} is already associated with this account.`
|
||||
));
|
||||
}
|
||||
return User.doesExist(null, email)
|
||||
.then(exists => {
|
||||
if (!exists) {
|
||||
return this.update$({ email }).toPromise();
|
||||
}
|
||||
debug('same email as another User', email);
|
||||
return Promise.reject(new Error(
|
||||
`${email} is already associated with an account.`
|
||||
));
|
||||
});
|
||||
};
|
||||
|
||||
User.remoteMethod(
|
||||
'updateEmail',
|
||||
{
|
||||
isStatic: false,
|
||||
description: 'updates the email of the user object',
|
||||
accepts: [
|
||||
{
|
||||
arg: 'email',
|
||||
type: 'string',
|
||||
required: true
|
||||
}
|
||||
],
|
||||
returns: [
|
||||
{
|
||||
arg: 'status',
|
||||
type: 'object'
|
||||
}
|
||||
],
|
||||
http: {
|
||||
path: '/email-update',
|
||||
verb: 'POST'
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
User.giveBrowniePoints =
|
||||
function giveBrowniePoints(receiver, giver, data = {}, dev = false, cb) {
|
||||
const findUser = observeMethod(User, 'findOne');
|
||||
|
Reference in New Issue
Block a user