mirror of
https://github.com/wekan/wekan.git
synced 2025-09-22 01:50:48 +02:00
Add the ability to call get_user operation with username
This commit is contained in:
parent
b47794cbc1
commit
fd20a9218f
1 changed files with 7 additions and 3 deletions
|
@ -1460,13 +1460,18 @@ if (Meteor.isServer) {
|
||||||
*
|
*
|
||||||
* @description Only the admin user (the first user) can call the REST API.
|
* @description Only the admin user (the first user) can call the REST API.
|
||||||
*
|
*
|
||||||
* @param {string} userId the user ID
|
* @param {string} userId the user ID or username
|
||||||
* @return_type Users
|
* @return_type Users
|
||||||
*/
|
*/
|
||||||
JsonRoutes.add('GET', '/api/users/:userId', function(req, res) {
|
JsonRoutes.add('GET', '/api/users/:userId', function(req, res) {
|
||||||
try {
|
try {
|
||||||
Authentication.checkUserId(req.userId);
|
Authentication.checkUserId(req.userId);
|
||||||
const id = req.params.userId;
|
let id = req.params.userId;
|
||||||
|
let user = Meteor.users.findOne({ _id: id });
|
||||||
|
if (!user) {
|
||||||
|
user = Meteor.users.findOne({ username: id });
|
||||||
|
id = user._id;
|
||||||
|
}
|
||||||
|
|
||||||
// get all boards where the user is member of
|
// get all boards where the user is member of
|
||||||
let boards = Boards.find(
|
let boards = Boards.find(
|
||||||
|
@ -1485,7 +1490,6 @@ if (Meteor.isServer) {
|
||||||
return u;
|
return u;
|
||||||
});
|
});
|
||||||
|
|
||||||
const user = Meteor.users.findOne({ _id: id });
|
|
||||||
user.boards = boards;
|
user.boards = boards;
|
||||||
JsonRoutes.sendResult(res, {
|
JsonRoutes.sendResult(res, {
|
||||||
code: 200,
|
code: 200,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue