fix(curriculum): updated auth with socket.io explanation (#43066)

* fix: updated auth with socket.io explanation

* Update wording to improve the clarity

Co-authored-by: Kristofer Koishigawa <scissorsneedfoodtoo@gmail.com>

* Update wording to improve the clarity

Co-authored-by: Kristofer Koishigawa <scissorsneedfoodtoo@gmail.com>

* Update wording to improve the clarity

Co-authored-by: Kristofer Koishigawa <scissorsneedfoodtoo@gmail.com>

* Update wording to improve the clarity

* Update curriculum/challenges/english/06-quality-assurance/advanced-node-and-express/authentication-with-socket.io.md

Co-authored-by: Shaun Hamilton <shauhami020@gmail.com>

Co-authored-by: Kristofer Koishigawa <scissorsneedfoodtoo@gmail.com>
Co-authored-by: Shaun Hamilton <shauhami020@gmail.com>
This commit is contained in:
Mykyta Ivanchenko
2021-08-09 10:25:46 +03:00
committed by GitHub
parent e0abfc5cf6
commit 959a6bce69

View File

@ -33,7 +33,11 @@ io.use(
);
```
Be sure to add the `key` and `store` to the `session` middleware mounted on the app. This is necessary to tell *SocketIO* which session to relate to.
Note that configuring Passport authentication for Socket.IO is very similar to the way we configured the `session` middleware for the API. This is because they are meant to use the same authentication method — get the session id from a cookie and validate it.
Previously, when we configured the `session` middleware, we didn't explicitly set the cookie name for session (`key`). This is because the `session` package was using the default value. Now that we've added another package which needs access to the same value from the cookies, we need to explicitly set the `key` value in both configuration objects.
Be sure to add the `key` with the cookie name to the `session` middleware that matches the Socket.IO key. Also, add the `store` reference to the options, near where we set `saveUninitialized: true`. This is necessary to tell Socket.IO which session to relate to.
<hr>