Skip to content

Commit

Permalink
rev: revised assignment questions
Browse files Browse the repository at this point in the history
  • Loading branch information
aldenluthfi committed Sep 19, 2024
1 parent 9578169 commit 04f304d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
9 changes: 4 additions & 5 deletions assignments/individual/assignment-4.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@ Pada tugas ini, kamu akan mengimplementasikan konsep *authentication*, *session*
- [ ] Menghubungkan model `Product` dengan `User`.
- [ ] Menampilkan detail informasi pengguna yang sedang *logged in* seperti *username* dan menerapkan `cookies` seperti `last login` pada halaman utama aplikasi.
- [ ] Menjawab beberapa pertanyaan berikut pada `README.md` pada *root folder* (silakan modifikasi `README.md` yang telah kamu buat sebelumnya; tambahkan subjudul untuk setiap tugas).

- [ ] Apa itu Django `UserCreationForm`, dan jelaskan apa kelebihan dan kekurangannya?
- [ ] Apa perbedaan antara autentikasi dan otorisasi dalam konteks Django, dan mengapa keduanya penting?
- [ ] Apa itu *cookies* dalam konteks aplikasi web, dan bagaimana Django menggunakan *cookies* untuk mengelola data sesi pengguna?
- [ ] Apakah penggunaan *cookies* aman secara *default* dalam pengembangan web, atau apakah ada risiko potensial yang harus diwaspadai?
- [ ] Apa perbedaan antara `HttpResponseRedirect()` dan `redirect()`
- [ ] Jelaskan cara kerja penghubungan model `MoodEntry` dengan `User`!
- [ ] Apa perbedaan antara *authentication* dan *authorization*, apakah yang dilakukan saat pengguna login? Jelaskan bagaimana Django mengimplementasikan kedua konsep tersebut.
- [ ] Bagaimana Django mengingat pengguna yang telah login? Jelaskan kegunaan lain dari *cookies* dan apakah semua cookies aman digunakan?
- [ ] Jelaskan bagaimana cara kamu mengimplementasikan *checklist* di atas secara *step-by-step* (bukan hanya sekadar mengikuti tutorial).
- [ ] Melakukan `add`-`commit`-`push` ke GitHub.

Expand Down
1 change: 0 additions & 1 deletion docs/tutorial-3.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,6 @@ Kita sudah menambahkan formulir registrasi akun dan membuat mekanisme `register`

**Penjelasan Kode:**

- `authenticate(request, username=username, password=password)` digunakan untuk melakukan autentikasi pengguna berdasarkan username dan password yang diterima dari permintaan (_request_) yang dikirim oleh pengguna saat _login_. Jika kombinasi valid, maka objek `user` akan di-_return_. Jika tidak, maka akan mengembalikan `None`.
- `login(request, user)` berfungsi untuk melakukan login terlebih dahulu. Jika pengguna valid, fungsi ini akan membuat _session_ untuk pengguna yang berhasil login.

3. Buatlah berkas HTML baru dengan nama `login.html` pada direktori `main/templates`. Isi dari `login.html` dapat kamu isi dengan _template_ berikut.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ Checklists for this assignment are:
- [ ] Display *logged in* user details such as *username* and apply `cookies` like `last login` to the application's main page.
- [ ] Answer the following questions in `README.md` in the root folder. (Modify your `README.md` that you have already created; add a subtitle for each assignment).

- [ ] What is a `UserCreationForm`, explain its advantages and disadvantages?
- [ ] What is the difference between authentication and authorization in Django, why are both important?
- [ ] What are *cookies* in web development, and how do Django use *cookies* to manage user sessions?
- [ ] Are the use of *cookies* safe by *default* in web development, or are there risks that needs to be noted?
- [ ] What is the difference between `HttpResponseRedirect()` and `redirect()`?
- [ ] Explain how the `MoodEntry` model is linked with `User`!
- [ ] What is the difference between *authentication* and *authorization*, and what happens when a user logs in? Explain how Django implements these two concepts.
- [ ] How does Django remember logged-in users? Explain other uses of *cookies* and whether all cookies are safe to use.
- [ ] Explain how did you implement the checklist *step-by-step* (apart from following the tutorial).

- [ ] Perform `add`-`commit`-`push` to GitHub.

## Deadline
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,6 @@ Now that we’ve added the registration form and created the `register` mechanis

**Code Explanation:**

- `authenticate(request, username=username, password=password)` is used to authenticate the user based on the username and password received from the user's request when logging in. If the combination is valid, it returns a `user` object. Otherwise, it returns `None`.
- `login(request, user)` is used to log in the user. If the user is valid, this function creates a session for the logged-in user.

3. Create a new HTML file named `login.html` in the `main/templates` directory. Fill it with the following template:
Expand Down

0 comments on commit 04f304d

Please sign in to comment.