add user stores/actions

construct fetchr on every request
This commit is contained in:
Berkeley Martinez
2015-07-24 17:52:07 -07:00
parent 77a0a82118
commit a1a4ac883d
10 changed files with 131 additions and 34 deletions

30
server/services/user.js Normal file
View File

@@ -0,0 +1,30 @@
import debugFactory from 'debug';
import assign from 'object.assign';
const censor = '**********************:P********';
const debug = debugFactory('freecc:services:user');
const protectedUserFields = {
id: censor,
password: censor,
profiles: censor
};
export default function userServices(/* app */) {
return {
name: 'user',
read: (req, resource, params, config, cb) => {
let { user } = req;
if (user) {
debug('user is signed in');
// Zalgo!!!
return process.nextTick(() => {
cb(null, assign({}, user.toJSON(), protectedUserFields));
});
}
debug('user is not signed in');
return process.nextTick(() => {
cb(null, {});
});
}
};
}