Skip to content

Commit 7cda9eb

Browse files
committed
docs(auth): fix JS examples
Fix syntax errors in JS authentication examples.
1 parent 7ff7db3 commit 7cda9eb

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

content/techniques/authentication.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,8 @@ import { AuthService } from './auth.service';
246246
@Dependencies(AuthService)
247247
export class LocalStrategy extends PassportStrategy(Strategy) {
248248
constructor(authService) {
249-
this.authService = authService
250249
super();
250+
this.authService = authService;
251251
}
252252

253253
async validate(username, password) {
@@ -345,7 +345,7 @@ import { AuthGuard } from '@nestjs/passport';
345345
export class AppController {
346346
@UseGuards(AuthGuard('local'))
347347
@Post('auth/login')
348-
@Bind(Req())
348+
@Bind(Request())
349349
async login(req) {
350350
return req.user;
351351
}
@@ -446,8 +446,7 @@ import { JwtService } from '@nestjs/jwt';
446446
@Dependencies(UsersService, JwtService)
447447
@Injectable()
448448
export class AuthService {
449-
constructor(usersService, jwtService)
450-
) {
449+
constructor(usersService, jwtService) {
451450
this.usersService = usersService;
452451
this.jwtService = jwtService;
453452
}
@@ -571,7 +570,7 @@ export class AppController {
571570

572571
@UseGuards(LocalAuthGuard)
573572
@Post('auth/login')
574-
@Bind(Req())
573+
@Bind(Request())
575574
async login(req) {
576575
return this.authService.login(req.user);
577576
}
@@ -740,25 +739,28 @@ export class AppController {
740739
}
741740
}
742741
@@switch
743-
import { Controller, Bind, Get, Request, Post, UseGuards } from '@nestjs/common';
742+
import { Controller, Dependencies, Bind, Get, Request, Post, UseGuards } from '@nestjs/common';
744743
import { JwtAuthGuard } from './auth/jwt-auth.guard';
745744
import { LocalAuthGuard } from './auth/local-auth.guard';
746745
import { AuthService } from './auth/auth.service';
747746

747+
@Dependencies(AuthService)
748748
@Controller()
749749
export class AppController {
750-
constructor(private authService: AuthService) {}
750+
constructor(authService) {
751+
this.authService = authService;
752+
}
751753

752754
@UseGuards(LocalAuthGuard)
753755
@Post('auth/login')
754-
@Bind(Req())
756+
@Bind(Request())
755757
async login(req) {
756758
return this.authService.login(req.user);
757759
}
758760

759761
@UseGuards(JwtAuthGuard)
760762
@Get('profile')
761-
@Bind(Req())
763+
@Bind(Request())
762764
getProfile(req) {
763765
return req.user;
764766
}

0 commit comments

Comments
 (0)