adds user/about
This commit is contained in:
@ -93,7 +93,7 @@ module.exports = function(User) {
|
|||||||
debug('where', where);
|
debug('where', where);
|
||||||
User.count(
|
User.count(
|
||||||
where,
|
where,
|
||||||
function (err, count) {
|
function(err, count) {
|
||||||
if (err) {
|
if (err) {
|
||||||
debug('err checking existance: ', err);
|
debug('err checking existance: ', err);
|
||||||
return cb(err);
|
return cb(err);
|
||||||
@ -132,4 +132,52 @@ module.exports = function(User) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
User.about = function about(username, cb) {
|
||||||
|
if (!username) {
|
||||||
|
// Zalgo!!
|
||||||
|
return process.nextTick(() => {
|
||||||
|
cb(
|
||||||
|
new TypeError('FCC: username should be a string but got %s', username)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
User.findOne({ where: { username } }, (err, user) => {
|
||||||
|
if (err) {
|
||||||
|
cb(err);
|
||||||
|
}
|
||||||
|
if (!user || user.username !== username) {
|
||||||
|
cb(new Error('FCC: no user found for %s', username));
|
||||||
|
}
|
||||||
|
const aboutUser = {
|
||||||
|
username: user.username,
|
||||||
|
bio: user.bio,
|
||||||
|
github: user.githubProfile
|
||||||
|
};
|
||||||
|
cb(null, aboutUser);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
User.remoteMethod(
|
||||||
|
'about',
|
||||||
|
{
|
||||||
|
description: 'get public info about user',
|
||||||
|
accepts: [
|
||||||
|
{
|
||||||
|
arg: 'username',
|
||||||
|
type: 'string'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
returns: [
|
||||||
|
{
|
||||||
|
arg: 'about',
|
||||||
|
type: 'object'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
http: {
|
||||||
|
path: '/about',
|
||||||
|
verb: 'get'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
@ -126,10 +126,6 @@
|
|||||||
"resetPasswordToken": {
|
"resetPasswordToken": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"sentSlackInvite": {
|
|
||||||
"type": "boolean",
|
|
||||||
"default": false
|
|
||||||
},
|
|
||||||
"resetPasswordExpires": {
|
"resetPasswordExpires": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
@ -249,6 +245,13 @@
|
|||||||
"principalId": "$everyone",
|
"principalId": "$everyone",
|
||||||
"permission": "ALLOW",
|
"permission": "ALLOW",
|
||||||
"property": "doesExist"
|
"property": "doesExist"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"accessType": "EXECUTE",
|
||||||
|
"principalType": "ROLE",
|
||||||
|
"principalId": "$everyone",
|
||||||
|
"permission": "ALLOW",
|
||||||
|
"property": "about"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"methods": []
|
"methods": []
|
||||||
|
Reference in New Issue
Block a user