Skip to content

Commit

Permalink
sonar fix + dependency update
Browse files Browse the repository at this point in the history
  • Loading branch information
furknyavuz committed Nov 11, 2022
1 parent 9307ea8 commit 84e6907
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 32 deletions.
19 changes: 12 additions & 7 deletions app/controller/auth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
MessageQueueChannelType,
MessageQueueProvider,
PostgreSqlProvider,
QueryFilters,
QueueMessage,
ResponseCode,
TokenUtil,
Expand Down Expand Up @@ -379,8 +380,7 @@ export class AuthController {
oauth?: any,
twoFA?: any,
username?: string,
offset?: number,
limit?: number
filters?: QueryFilters,
) => {
const userRepository = new UserRepository( db );

Expand All @@ -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[] = [];
Expand Down
42 changes: 22 additions & 20 deletions app/route/auth.route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const subRoutes = {
user: '/user',
submittedPhoneNumber: '/submitted-phone-number',
users: '/users'
}
};

export const router = Router();

Expand Down Expand Up @@ -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 );
}
);
4 changes: 0 additions & 4 deletions docs/OUTDATED.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |

<table align="right"><tr><td><a href="https://opentemplatehub.com"><img src="https://raw.githubusercontent.com/open-template-hub/open-template-hub.github.io/master/assets/logo/brand-logo.png" width="50px" alt="oth"/></a></td><td><b>Open Template Hub © 2021</b></td></tr></table>

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"outdated": "node dependency-checker.ts > docs/OUTDATED.md"
},
"dependencies": {
"@open-template-hub/common": "^4.0.2",
"@open-template-hub/common": "^4.0.5",
"@types/bcrypt": "^5.0.0",
"@types/capitalize": "^2.0.0",
"@types/cors": "^2.8.9",
Expand Down

0 comments on commit 84e6907

Please sign in to comment.