Password Change Graph Support

This commit is contained in:
Wyatt Johnson
2018-04-16 12:29:37 -06:00
parent f23f962adb
commit 0fcb0be360
7 changed files with 107 additions and 21 deletions
+1
View File
@@ -19,4 +19,5 @@ module.exports = {
UPDATE_ASSET_STATUS: 'UPDATE_ASSET_STATUS',
UPDATE_SETTINGS: 'UPDATE_SETTINGS',
DELETE_USER: 'DELETE_USER',
CHANGE_PASSWORD: 'CHANGE_PASSWORD',
};
+9
View File
@@ -1,8 +1,17 @@
const { isString } = require('lodash');
const { check } = require('../utils');
const types = require('../constants');
module.exports = (user, perm) => {
switch (perm) {
case types.CHANGE_PASSWORD:
// Only users with a local account where they have a password set can
// actually change their password.
return (
user.profiles.some(({ provider }) => provider === 'local') &&
isString(user.password) &&
user.password.length > 0
);
case types.CHANGE_USERNAME:
return user.status.username.status === 'REJECTED';