bugfix
This commit is contained in:
parent
30011213b7
commit
ba3ca6365d
@ -19,7 +19,6 @@ class Roles extends ApiEndpoint
|
|||||||
this.methods = [
|
this.methods = [
|
||||||
[ 'get', this.getRoles.bind(this) ],
|
[ 'get', this.getRoles.bind(this) ],
|
||||||
[ 'post', this.createRole.bind(this), server.auth.createAuthoriser('administrator:roles:create') ],
|
[ 'post', this.createRole.bind(this), server.auth.createAuthoriser('administrator:roles:create') ],
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
this.subpaths = [
|
this.subpaths = [
|
||||||
@ -35,11 +34,11 @@ class Roles extends ApiEndpoint
|
|||||||
async getRoles (req: Request, res: Response): Promise<void>
|
async getRoles (req: Request, res: Response): Promise<void>
|
||||||
{
|
{
|
||||||
const { query } = req;
|
const { query } = req;
|
||||||
const pageSize = query.amount ? parseInt(query.amount as string) : 10;
|
const pageSize = query.pageSize ? parseInt(query.pageSize as string) : 10;
|
||||||
let page = query.page ? parseInt(query.page as string) - 1 : 0;
|
let page = query.page ? parseInt(query.page as string) - 1 : 0;
|
||||||
if (query.page && isNaN(page))
|
if (query.page && isNaN(page))
|
||||||
return void res.status(400).send('Invalid page number');
|
return void res.status(400).send('Invalid page number');
|
||||||
if (query.amount && isNaN(pageSize))
|
if (query.pageSize && isNaN(pageSize))
|
||||||
return void res.status(400).send('Invalid amount');
|
return void res.status(400).send('Invalid amount');
|
||||||
|
|
||||||
const amts = await this.#users.count();
|
const amts = await this.#users.count();
|
||||||
@ -80,11 +79,11 @@ class Roles extends ApiEndpoint
|
|||||||
if (!role)
|
if (!role)
|
||||||
return void res.status(404).end();
|
return void res.status(404).end();
|
||||||
|
|
||||||
const pageSize = query.amount ? parseInt(query.amount as string) : 10;
|
const pageSize = query.pageSize ? parseInt(query.pageSize as string) : 10;
|
||||||
let page = query.page ? parseInt(query.page as string) - 1 : 0;
|
let page = query.page ? parseInt(query.page as string) - 1 : 0;
|
||||||
if (query.page && isNaN(page))
|
if (query.page && isNaN(page))
|
||||||
return void res.status(400).send('Invalid page number');
|
return void res.status(400).send('Invalid page number');
|
||||||
if (query.amount && isNaN(pageSize))
|
if (query.pageSize && isNaN(pageSize))
|
||||||
return void res.status(400).send('Invalid amount');
|
return void res.status(400).send('Invalid amount');
|
||||||
|
|
||||||
const amt = await this.#users.countUsersWithRole(roleId);
|
const amt = await this.#users.countUsersWithRole(roleId);
|
||||||
|
Loading…
Reference in New Issue
Block a user