refactor: Update methods to sensible names
This commit is contained in:
@ -472,7 +472,7 @@ module.exports = function(User) {
|
||||
}
|
||||
);
|
||||
|
||||
User.requestAuthLink = function requestAuthLink(email) {
|
||||
User.requestAuthEmail = function requestAuthEmail(email) {
|
||||
if (!isEmail(email)) {
|
||||
return Promise.reject(
|
||||
new Error('The submitted email not valid.')
|
||||
@ -545,7 +545,7 @@ module.exports = function(User) {
|
||||
};
|
||||
|
||||
User.remoteMethod(
|
||||
'requestAuthLink',
|
||||
'requestAuthEmail',
|
||||
{
|
||||
description: 'request a link on email with temporary token to sign in',
|
||||
accepts: [{
|
||||
@ -560,7 +560,7 @@ module.exports = function(User) {
|
||||
}
|
||||
);
|
||||
|
||||
User.prototype.updateEmail = function updateEmail(email) {
|
||||
User.prototype.requestUpdateEmail = function requestUpdateEmail(email) {
|
||||
const ownEmail = email === this.email;
|
||||
if (!isEmail('' + email)) {
|
||||
return Observable.throw(createEmailError());
|
||||
|
@ -277,7 +277,7 @@
|
||||
"principalType": "ROLE",
|
||||
"principalId": "$owner",
|
||||
"permission": "ALLOW",
|
||||
"property": "updateEmail"
|
||||
"property": "requestUpdateEmail"
|
||||
},
|
||||
{
|
||||
"accessType": "EXECUTE",
|
||||
@ -298,7 +298,7 @@
|
||||
"principalType": "ROLE",
|
||||
"principalId": "$everyone",
|
||||
"permission": "ALLOW",
|
||||
"property": "requestAuthLink"
|
||||
"property": "requestAuthEmail"
|
||||
}
|
||||
],
|
||||
"methods": {}
|
||||
|
@ -21,7 +21,7 @@ export default function settingsController(app) {
|
||||
|
||||
function updateMyEmail(req, res, next) {
|
||||
const { user, body: { email } } = req;
|
||||
return user.updateEmail(email)
|
||||
return user.requestUpdateEmail(email)
|
||||
.subscribe(
|
||||
(message) => res.json({ message }),
|
||||
next
|
||||
|
@ -248,7 +248,7 @@ module.exports = function(app) {
|
||||
return res.redirect('/');
|
||||
}
|
||||
|
||||
return User.requestAuthLink(req.body.email)
|
||||
return User.requestAuthEmail(req.body.email)
|
||||
.then(msg => {
|
||||
return res.status(200).send({ message: msg });
|
||||
})
|
||||
|
Reference in New Issue
Block a user