File tree Expand file tree Collapse file tree 3 files changed +8
-2
lines changed
Expand file tree Collapse file tree 3 files changed +8
-2
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 44 ExecutionContext ,
55 ForbiddenException ,
66 Injectable ,
7+ Logger ,
78} from '@nestjs/common' ;
89import { Reflector } from '@nestjs/core' ;
910import { 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' ,
Original file line number Diff line number Diff 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 ;
You can’t perform that action at this time.
0 commit comments