Skip to content

Conversation

mao-sz
Copy link
Contributor

@mao-sz mao-sz commented Nov 13, 2024

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

mao-sz added 17 commits November 6, 2024 00:53
'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
@mao-sz mao-sz force-pushed the node-revamp-sessions branch from c096d97 to 9a8148c Compare November 19, 2024 12:45
@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

mao-sz 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)
@mao-sz mao-sz requested a review from 01zulfi March 18, 2025 15:53
mao-sz added 2 commits March 24, 2025 16:44
Prefixes only necessary if
TheOdinProject#28372 gets merged.
Until then, they are not necessary.
@mao-sz mao-sz 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.

@mao-sz mao-sz changed the title New lesson: Session-based authentication New lesson: Sessions Apr 17, 2025
Quotes changed to double for lesson consistency
@mao-sz mao-sz force-pushed the node-revamp-sessions branch from 635e27a to 165df10 Compare April 17, 2025 22:40
@mao-sz mao-sz requested a review from 01zulfi April 21, 2025 10:50
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.

@MaoShizhong this is lookin great, can't wait for it to be released 🔥

"Session management" used in later lessons and linked resources to
describe the more general concept of persisting user interaction data
between requests, even when stateful sessions are not used.
@mao-sz
Copy link
Contributor Author

mao-sz commented Aug 6, 2025

Added a little terminology clarification note box now that later lessons have been written. The term "session management" as a more general concept (not specifically stateful sessions) is used in later lessons as well as linked resources, so it'd probably be sensible to clarify that terminology at the start to reduce confusion later on.

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