-
Notifications
You must be signed in to change notification settings - Fork 3
Cookie の節の書き直し #860
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
Cookie の節の書き直し #860
Conversation
Deploying utcode-learn with
|
Latest commit: |
15e1d16
|
Status: | ✅ Deploy successful! |
Preview URL: | https://33f779b4.utcode-learn.pages.dev |
Branch Preview URL: | https://rewrite-cookie.utcode-learn.pages.dev |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR rewrites the Cookie section of the documentation to improve its structure and provide a more comprehensive guide to authentication in web applications. The changes focus on reorganizing content to better explain cookies in the context of authentication systems.
Key changes include:
- Complete restructuring of the Cookie documentation with new authentication-focused content
- Addition of new term definitions for HTTP status codes and method terminology updates
- Addition of comprehensive sample applications demonstrating cookie-based authentication
Reviewed Changes
Copilot reviewed 16 out of 29 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
src/components/Term/type-map.js | Adds mapping for HTTP status code term |
src/components/Term/definitions.js | Updates HTTP method name and adds status code definition |
docs/4-advanced/01-cookie/index.mdx | Complete rewrite focusing on authentication with cookies |
docs/4-advanced/01-cookie/_samples/ | New sample applications for cookie counter and authentication |
docs/3-web-servers/07-fetch-api-post/index.mdx | Updates status code reference to use new term |
.vscode/settings.json | Adds Prisma formatter configuration |
Files not reviewed (2)
- docs/4-advanced/01-cookie/_samples/cookie-counter/package-lock.json: Language not supported
- docs/4-advanced/01-cookie/_samples/simple-authentication/package-lock.json: Language not supported
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
docs/4-advanced/01-cookie/_samples/simple-authentication/main.mjs
Outdated
Show resolved
Hide resolved
docs/4-advanced/01-cookie/index.mdx
Outdated
app.get("/", (request, response) => { | ||
// Cookieの値は文字列なので数値に変換が必要 | ||
const count = parseInt(request.cookies.count) || 0; | ||
const count = Number.parseInt(request.cookies.count) || 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
変更前からそうなっているので申し訳ないのですが、このような論理和演算子や論理積演算子の使い方は、「React」の節ではじめて扱うので、この時点では未履修となっています。
このプログラムは、`age`変数が`18`以上である場合のみメッセージを表示します。これは、`&&`演算子の挙動を利用した手法です。これまで、`&&`演算子は両辺が`true`であれば`true`を返す演算子であるとしてきました。しかしながら、[`&&`演算子のより一般的な定義](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Operators/Logical_AND)は、**左辺が[<Term>truthy</Term>](https://developer.mozilla.org/ja/docs/Glossary/Truthy)であれば右辺の値を、そうでなければ左辺の値を返す演算子**です。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 17 out of 30 changed files in this pull request and generated 1 comment.
Files not reviewed (2)
- docs/4-advanced/01-cookie/_samples/cookie-counter/package-lock.json: Language not supported
- docs/4-advanced/01-cookie/_samples/simple-authentication/package-lock.json: Language not supported
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
docs/4-advanced/01-cookie/index.mdx
Outdated
|
||
`/login`は、IDとパスワードを含むJSON形式のPOSTリクエストを受け取り、データベースの`User`テーブルのデータと比較することで、認証情報が正しいかどうかを検証します。正しければ、[`crypto.randomUUID`関数](https://developer.mozilla.org/ja/docs/Web/API/Crypto/randomUUID)を用いてランダムな文字列を生成し、新しいレコードを`Session`テーブルに作成した上で、Cookieとしてクライアントに送信します。誤っていれば、直ちに認証失敗の<Term>ステータスコード</Term>を返して終了します。 | ||
|
||
新しいレコードを`Session`テーブルに作成し、その`sessionId`をCookieとしてクライアントに送信します。誤っていれば、直ちに認証失敗の<Term>ステータスコード</Term>を返して終了します。 |
Copilot
AI
Oct 5, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sentence appears to be duplicated content from the previous paragraph (line 114). The first part repeats information already explained, making the documentation redundant.
新しいレコードを`Session`テーブルに作成し、その`sessionId`をCookieとしてクライアントに送信します。誤っていれば、直ちに認証失敗の<Term>ステータスコード</Term>を返して終了します。 |
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ありがとうございます。
後は、ここだけだと思います。
docs/4-advanced/01-cookie/index.mdx
Outdated
`/login`は、IDとパスワードを含むJSON形式のPOSTリクエストを受け取り、データベースの`User`テーブルのデータと比較することで、認証情報が正しいかどうかを検証します。正しければ、[`crypto.randomUUID`関数](https://developer.mozilla.org/ja/docs/Web/API/Crypto/randomUUID)を用いてランダムな文字列を生成し、新しいレコードを`Session`テーブルに作成した上で、Cookieとしてクライアントに送信します。誤っていれば、直ちに認証失敗の<Term>ステータスコード</Term>を返して終了します。 | ||
|
||
新しいレコードを`Session`テーブルに作成し、その`sessionId`をCookieとしてクライアントに送信します。誤っていれば、直ちに認証失敗の<Term>ステータスコード</Term>を返して終了します。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
文章に重複が見られます。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
すみません・・・・
docs/4-advanced/01-cookie/index.mdx
Outdated
} | ||
``` | ||
|
||
`/login`は、IDとパスワードを含むJSON形式のPOSTリクエストを受け取り、データベースの`User`テーブルのデータと比較することで、認証情報が正しいかどうかを検証します。正しければ、[`crypto.randomUUID`関数](https://developer.mozilla.org/ja/docs/Web/API/Crypto/randomUUID)を用いてランダムな文字列を生成し、新しいレコードを`Session`テーブルに作成した上で、Cookieとしてクライアントに送信します。誤っていれば、直ちに認証失敗の<Term>ステータスコード</Term>を返して終了します。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ここでの「ランダムな文字列」とPrisma Schemaに書かれている「一意でランダムなID」が同じものを指しているということが少しわかりにくいのかなと思いました。
つまり、crypto.randomUUID
関数で生成されたランダムな文字列が、「一意」であるということが初学者には非自明ではないかと思いました。
「crypto.randomUUID
関数を用いて一意でランダムなIDを生成し」などでもよいのかなと。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
確かに!ありがとうございます🙇🙇🙇
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ありがとうございます!
No description provided.