adds user/about
This commit is contained in:
@ -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": {
|
||||
"type": "string"
|
||||
},
|
||||
"sentSlackInvite": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"resetPasswordExpires": {
|
||||
"type": "string"
|
||||
},
|
||||
@ -249,6 +245,13 @@
|
||||
"principalId": "$everyone",
|
||||
"permission": "ALLOW",
|
||||
"property": "doesExist"
|
||||
},
|
||||
{
|
||||
"accessType": "EXECUTE",
|
||||
"principalType": "ROLE",
|
||||
"principalId": "$everyone",
|
||||
"permission": "ALLOW",
|
||||
"property": "about"
|
||||
}
|
||||
],
|
||||
"methods": []
|
||||
|
Reference in New Issue
Block a user