mirror of
https://github.com/wassname/talk.git
synced 2026-06-30 03:31:01 +08:00
a7e9c0c776
- Updated enum values to be uppercase - Updated services to expose service models - Updated models to only export the mongoose model - Moved all mongoose static methods over to new services - Updated tests to refelct new setup BREAKING - Status that were uppercased (caps) have caused issues with the admin pages
32 lines
743 B
JavaScript
32 lines
743 B
JavaScript
const UsersService = require('../../services/users');
|
|
|
|
/**
|
|
* Updates a users settings.
|
|
* @param {Object} user the user performing the request
|
|
* @param {String} bio the new user bio
|
|
* @return {Promise}
|
|
*/
|
|
const updateUserSettings = ({user}, {bio}) => {
|
|
return UsersService.updateSettings(user.id, {bio});
|
|
};
|
|
|
|
module.exports = (context) => {
|
|
|
|
// TODO: refactor to something that'll return an error in the event an attempt
|
|
// is made to mutate state while not logged in. There's got to be a better way
|
|
// to do this.
|
|
if (context.user) {
|
|
return {
|
|
User: {
|
|
updateSettings: (settings) => updateUserSettings(context, settings)
|
|
}
|
|
};
|
|
}
|
|
|
|
return {
|
|
User: {
|
|
updateSettings: () => {}
|
|
}
|
|
};
|
|
};
|