Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions content/security/authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<any> {
const user = await this.usersService.findOne(username);
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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<boolean> {
const request = context.switchToHttp().getRequest();
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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<boolean> {
const isPublic = this.reflector.getAllAndOverride<boolean>(IS_PUBLIC_KEY, [
Expand Down