You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/recipes/passport.md
+18-1Lines changed: 18 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -943,7 +943,8 @@ Then, you refer to this via a decorator like `@UseGuards(AuthGuard('myjwt'))`.
943
943
944
944
#### GraphQL
945
945
946
-
In order to use an AuthGuard with [GraphQL](https://docs.nestjs.com/graphql/quick-start), extend the built-in AuthGuard class and override the getRequest() method.
946
+
In order to use an AuthGuard with [GraphQL](https://docs.nestjs.com/graphql/quick-start), extend the built-in AuthGuard class and override the getRequest() method.
947
+
In the case of passport-local strategy you will also have to attach the GraphQL context's arguments into the request's body so that Passport can use them for validation.
947
948
948
949
```typescript
949
950
@Injectable()
@@ -955,6 +956,22 @@ export class GqlAuthGuard extends AuthGuard('jwt') {
955
956
}
956
957
```
957
958
959
+
In the case of passport-local strategy you will also have to attach the GraphQL context's arguments into the request's body so that Passport can access them for validation (if not done so an Unauthorized error gets issued).
0 commit comments