diff --git a/app/controller/auth.controller.ts b/app/controller/auth.controller.ts index 7f612ee..7ddda02 100644 --- a/app/controller/auth.controller.ts +++ b/app/controller/auth.controller.ts @@ -10,6 +10,7 @@ import { MessageQueueChannelType, MessageQueueProvider, PostgreSqlProvider, + QueryFilters, QueueMessage, ResponseCode, TokenUtil, @@ -379,8 +380,7 @@ export class AuthController { oauth?: any, twoFA?: any, username?: string, - offset?: number, - limit?: number + filters?: QueryFilters, ) => { const userRepository = new UserRepository( db ); @@ -400,12 +400,17 @@ export class AuthController { twoFA = false; } - if ( !offset ) { - offset = 0; - } + let offset = 0; + let limit = 20; + + if ( filters ) { + if ( filters.offset ) { + offset = filters.offset; + } - if ( !limit ) { - limit = 20; + if ( filters.limit ) { + limit = filters.limit; + } } let users: any[] = []; diff --git a/app/route/auth.route.ts b/app/route/auth.route.ts index 937c388..c0c09e7 100644 --- a/app/route/auth.route.ts +++ b/app/route/auth.route.ts @@ -20,7 +20,7 @@ const subRoutes = { user: '/user', submittedPhoneNumber: '/submitted-phone-number', users: '/users' -} +}; export const router = Router(); @@ -185,23 +185,25 @@ router.delete( ); router.get( - subRoutes.users, - authorizedBy([UserRole.ADMIN, UserRole.DEFAULT]), - async(req: Request, res: Response) => { - const authController = new AuthController(); - const context = res.locals.ctx; + subRoutes.users, + authorizedBy( [ UserRole.ADMIN, UserRole.DEFAULT ] ), + async ( req: Request, res: Response ) => { + const authController = new AuthController(); + const context = res.locals.ctx; - const users = await authController.getUsers( - context.postgresql_provider, - req.query.role as string, - req.query.verified as string, - req.query.oauth as string, - req.query.twoFA as string, - req.query.username as string, - +(req.query.offset as string), - +(req.query.limit as string) - ); - - res.status(ResponseCode.OK).json(users); - } -) + const users = await authController.getUsers( + context.postgresql_provider, + req.query.role as string, + req.query.verified as string, + req.query.oauth as string, + req.query.twoFA as string, + req.query.username as string, + { + offset: +( req.query.offset as string ), + limit: +( req.query.limit as string ) + }, + ); + + res.status( ResponseCode.OK ).json( users ); + } +); diff --git a/docs/OUTDATED.md b/docs/OUTDATED.md index 0075645..d60d1de 100644 --- a/docs/OUTDATED.md +++ b/docs/OUTDATED.md @@ -13,10 +13,6 @@ Open Template Hub - Auth Server Template v4 Following packages are not updated in the develop branch yet. So, if you want to update outdated packages on your own risk, update the package.json and install dependencies. -| Package | Current | Wanted | Latest | Location | -| --- | --- | --- | --- | --- | -| axios | 0.27.2 | 0.27.2 | 1.1.3 | node_modules/axios | -| uuid | 8.3.2 | 8.3.2 | 9.0.0 | node_modules/uuid |
Open Template Hub © 2021 |