Difference between revisions of "WebFund 2013F: Assignment 2"

From Soma-notes
Jump to navigation Jump to search
Line 30: Line 30:
For the following, run <tt>node puzzle.js</tt>, listed below and included [http:// here].  At the <tt>puzzle></tt> prompt, what are the value(s) of the following expressions?
For the following, run <tt>node puzzle.js</tt>, listed below and included [http:// here].  At the <tt>puzzle></tt> prompt, what are the value(s) of the following expressions?


Assume that the expressions are entered in to the interpreter ''as ordered''.  In other words, the earlier expressions may influence the later ones.  If you get an error, report the kind of error, e.g. "reference error" or "type error".
(Assume that the expressions are entered in to the interpreter ''as ordered''.  In other words, the earlier expressions may influence the later ones.  If you get an error, report the kind of error, e.g. "reference error" or "type error".)
 
# p
# p
# q
# q

Revision as of 15:33, 5 October 2013

This assignment is not yet finalized

Please submit your answers as a single text or PDF file uploaded to CULearn with "COMP 2406 Assignment 2", your name, student number, and the date as the first four lines of the file. No other formats will be accepted. Submitting in another format may result in your assignment not being graded and you receiving no marks for this assignment.

This assignment has ?? points.

Questions

Part A

The following questions are in reference to the session-demo sample node application covered in Tutorial 5.

  1. (2 points) What happens if you remove the line requiring the http module? The path module?
  2. (2 points) What is the secret used to help prevent attackers from creating their own fake session identifiers?
  3. (2 points) How can I change the port node listens on without changing the code?
  4. (2 points) The user "User" logs in to the application in two web browsers, A and B, simultaneously. "User" then logs out of browser A. After reloading /users in browser B, how many users are shown as being logged in? (Assume no other users.)
  5. (2 points) Does this application use client-side JavaScript? Explain briefly.
  6. (5 points) Modify the code so that it keeps track of how many times an individual user is logged in.
  7. (10 points) Modify the code so that sessions are authenticated. Specifically:
    • add a "Password" field and a "Register" button to /
    • When the register button is pressed:
      • If the user has not registered, store their username and password, return to /.
      • If the user has registered, generate an error at the top of / similar to that when accessing /users without being logged in. The error should be "Error: User has already registered."
    • When the login button is pressed:
      • If the user enters the correct password let them proceed to /users as before.
      • If the user enters an incorrect password or a username that isn't registered, return an error on / saying "Error: incorrect username/password". (Do not differentiate between an unregistered user and a registered user with an incorrect password.)

Part B

For the following, run node puzzle.js, listed below and included [http:// here]. At the puzzle> prompt, what are the value(s) of the following expressions?

(Assume that the expressions are entered in to the interpreter as ordered. In other words, the earlier expressions may influence the later ones. If you get an error, report the kind of error, e.g. "reference error" or "type error".)

  1. p
  2. q
  3. y
  4. f = q
  5. f("Anil")
  6. f.g("Anil")
  7. f.h("Anil")
  8. f.g("Annie")
  9. f.j("y = \"boing\"")
  10. y
  11. f.j("x = \"goodbye \"")
  12. f.g("Michael")
  13. f.h("I recognize you!")
  14. q.j("s.m = function(n,m,q) {x = n; a = m; b = q;}"); q.m("this", "is", "weird");
  15. f("Anil");

Part C

Conceptual questions


Code

puzzle.js