mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2024-11-22 13:29:22 +00:00
Fix issue with ComunicWeb
This commit is contained in:
parent
db686075f0
commit
190e047bd8
@ -28,7 +28,23 @@ export class UserController {
|
|||||||
* Get information about multiple users
|
* Get information about multiple users
|
||||||
*/
|
*/
|
||||||
public static async GetMultiple(handler : RequestHandler) {
|
public static async GetMultiple(handler : RequestHandler) {
|
||||||
|
|
||||||
|
let list = {};
|
||||||
|
const IDs = handler.postNumbersList("usersID");
|
||||||
|
|
||||||
|
for (const id of IDs) {
|
||||||
|
if(list.hasOwnProperty(id))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
const user = await UserHelper.GetUserInfo(id);
|
||||||
|
|
||||||
|
if(!user)
|
||||||
|
handler.error(404, "One user was not found!");
|
||||||
|
|
||||||
|
list[id] = this.UserToAPI(user, handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
handler.send(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static UserToAPI(user : User, handler: RequestHandler) : Object {
|
private static UserToAPI(user : User, handler: RequestHandler) : Object {
|
||||||
|
@ -90,6 +90,30 @@ export class RequestHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a list of integeres included in the request
|
||||||
|
*
|
||||||
|
* @param name The name of the post field
|
||||||
|
*/
|
||||||
|
public postNumbersList(name: string) : Array<number> {
|
||||||
|
const param = this.postString(name);
|
||||||
|
let list = [];
|
||||||
|
for (const el of param.split(",")) {
|
||||||
|
|
||||||
|
if(el == "")
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if(Number.parseInt(el).toString() != el)
|
||||||
|
this.error(400, "Invalid number detected in '"+name+"'!");
|
||||||
|
|
||||||
|
list.push(Number.parseInt(el));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate API tokens
|
* Validate API tokens
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user