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