diff --git a/content/security/authentication.md b/content/security/authentication.md index e3d75def0a..4ffb5f0fab 100644 --- a/content/security/authentication.md +++ b/content/security/authentication.md @@ -111,7 +111,7 @@ import { UsersService } from '../users/users.service'; @Injectable() export class AuthService { - constructor(private usersService: UsersService) {} + constructor(private readonly usersService: UsersService) {} async signIn(username: string, pass: string): Promise { const user = await this.usersService.findOne(username); @@ -188,7 +188,7 @@ import { AuthService } from './auth.service'; @Controller('auth') export class AuthController { - constructor(private authService: AuthService) {} + constructor(private readonly authService: AuthService) {} @HttpCode(HttpStatus.OK) @Post('login') @@ -373,7 +373,7 @@ import { Request } from 'express'; @Injectable() export class AuthGuard implements CanActivate { - constructor(private jwtService: JwtService) {} + constructor(private readonly jwtService: JwtService) {} async canActivate(context: ExecutionContext): Promise { const request = context.switchToHttp().getRequest(); @@ -425,7 +425,7 @@ import { AuthService } from './auth.service'; @Controller('auth') export class AuthController { - constructor(private authService: AuthService) {} + constructor(private readonly authService: AuthService) {} @HttpCode(HttpStatus.OK) @Post('login') @@ -506,7 +506,7 @@ Lastly, we need the `AuthGuard` to return `true` when the `"isPublic"` metadata ```typescript @Injectable() export class AuthGuard implements CanActivate { - constructor(private jwtService: JwtService, private reflector: Reflector) {} + constructor(private readonly jwtService: JwtService, private reflector: Reflector) {} async canActivate(context: ExecutionContext): Promise { const isPublic = this.reflector.getAllAndOverride(IS_PUBLIC_KEY, [