Skip to content

Commit b925771

Browse files
committed
added some logger and bug fixed
1 parent 4b4c139 commit b925771

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

src/log/services/log.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export class LogService {
1111
) {}
1212
async createLog(log: any) {
1313
Logger.log(
14-
`Storing log to db: ${log.method} ${log.path} ${log.statusCode} ${log.contentLenght} ${log.userAgent} ${log.appId}`,
14+
`Storing log to db: ${log.method} ${log.path} ${log.statusCode} ${log.contentLength} ${log.userAgent} ${log.appId}`,
1515
'LogService',
1616
);
1717

src/utils/guards/access.gaurd.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
ExecutionContext,
55
ForbiddenException,
66
Injectable,
7+
Logger,
78
} from '@nestjs/common';
89
import { Reflector } from '@nestjs/core';
910
import { ACCESS_KEY } from '../customDecorator/access.decorator';
@@ -13,16 +14,21 @@ export class AccessGuard implements CanActivate {
1314
constructor(private reflector: Reflector) {}
1415

1516
canActivate(context: ExecutionContext): boolean {
17+
Logger.log('Insdie AccessGaurd');
1618
const requiredPermissions = this.reflector.get<string[]>(
1719
ACCESS_KEY,
1820
context.getHandler(),
1921
);
22+
Logger.debug(requiredPermissions, 'AccessGuard');
2023
if (!requiredPermissions) return true;
2124
const req = context.switchToHttp().getRequest();
2225
const tokenPermissions: string[] = req.user?.accessList ?? [];
26+
Logger.debug(tokenPermissions, 'AccessGuard');
27+
2328
const authorized = requiredPermissions.every((p) =>
2429
tokenPermissions.includes(p),
2530
);
31+
Logger.debug(`authorized: ${authorized}`, 'AccessGuard');
2632
if (!authorized) {
2733
throw new ForbiddenException([
2834
'Permission denied: Missing access rights',

src/utils/interceptor/http-interceptor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export class AppLoggerMiddleware implements NestMiddleware {
2121
let { url: path } = request;
2222
const { statusCode } = response;
2323
const contentLength = response.get('content-length');
24-
const app = request['app'];
24+
const app = request['user'];
2525
const { appId } = app as any;
2626
if (path.includes('credential/issue')) {
2727
const reqBody = request.body;

0 commit comments

Comments
 (0)