Skip to content

New lesson: Sessions #29082

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 33 commits into
base: main
Choose a base branch
from

Conversation

MaoShizhong
Copy link
Contributor

Because

As part of the Node revamp's 2nd milestone

This PR

Issue

Closes #28847

Additional Information

Pull Request Requirements

  • I have thoroughly read and understand The Odin Project curriculum contributing guide
  • The title of this PR follows the location of change: brief description of change format, e.g. Intro to HTML and CSS lesson: Fix link text
  • The Because section summarizes the reason for this PR
  • The This PR section has a bullet point list describing the changes in this PR
  • If this PR addresses an open issue, it is linked in the Issue section
  • If any lesson files are included in this PR, they have been previewed with the Markdown preview tool to ensure it is formatted correctly
  • If any lesson files are included in this PR, they follow the Layout Style Guide

'Persisting logins' was a glorified intro anyway
Only up to the original login process
Reordered setup code blocks for easier content flow.
Decided to introduce the session store and secret explanations here
instead of their own sections later on (not really needed there).
New order allows for a more natural way of explaining how
express-session populates req.session.
That can be explained at the start and options explained to reflect
that, instead of explaining options in a bit of a black hole then
provide the context later in the lesson.
Made more sense to talk about logging out after logging in, then talk
about password hashing afterwords.
Use subsections for better content organisation and linking
@github-actions github-actions bot added the Content: NodeJS Involves the NodeJS course label Nov 13, 2024
"Session-based authentication" is a more appropriate title for the
lesson than just "Sessions", given that sessions are not exclusively
used for auth purposes.
@01zulfi 01zulfi self-requested a review November 13, 2024 16:19
Makes sense to showcase them directly rather than just via text example after the fact
@01zulfi 01zulfi added the Project Node Revamp Issues/PRs related to the Node Revamp project label Dec 11, 2024
Copy link
Member

@01zulfi 01zulfi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great stuff, left a few comments below

MaoShizhong and others added 3 commits March 16, 2025 19:18
Link to connect-pg-simple's SQL queries for this may be useful for learners to look at.
Explicit `.save()` call required as per docs to force saving the
session before a redirect potentially triggers a page load:
https://expressjs.com/en/resources/middleware/session.html#:~:text=Session.save(callback)
@MaoShizhong MaoShizhong requested a review from 01zulfi March 18, 2025 15:53
Prefixes only necessary if
TheOdinProject#28372 gets merged.
Until then, they are not necessary.
@MaoShizhong MaoShizhong force-pushed the node-revamp-sessions branch from aba84a1 to ebbf606 Compare March 24, 2025 16:44
IMHO, pairs a little better with a 'JSON Web Tokens' lesson since it doesn't follow the '*-based authentication' pattern
} else {
const { rows } = await pool.query(
"SELECT * FROM users WHERE id = $1",
[req.session.userId],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this might feel a bit magical to the learner. Hopefully some changes above might help

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me know how the changes feel in regards to this bit.

@MaoShizhong MaoShizhong changed the title New lesson: Session-based authentication New lesson: Sessions Apr 17, 2025
Quotes changed to double for lesson consistency
@MaoShizhong MaoShizhong force-pushed the node-revamp-sessions branch from 635e27a to 165df10 Compare April 17, 2025 22:40
@MaoShizhong MaoShizhong requested a review from 01zulfi April 21, 2025 10:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content: NodeJS Involves the NodeJS course Project Node Revamp Issues/PRs related to the Node Revamp project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New Lesson: Sessions
4 participants