small medium large xlarge

23 Sep 2013, 08:11
craig ferry (14 posts)

Loving the book - keep up the great work.

In the last paragraph of p 47 of beta 2 pdf It states the following.

Now we can add our handler to the auth-routes definition. At the moment we will simply check if the entered passwords match and redirect to the home page. Otherwise we’ll render the page again.

 (defroutes auth-routes
 (GET "/register" [] (registration-page)) 
 (POST "/register" [id pass pass1]
  (if (= pass pass1) (redirect "/") (register id))))

Later on the POST route is despatched to a handle-registration function but at this intermediate stage there is no register function to pass it to.

I assumed that this is a typo and it purpose is just to re-render the registration-page function. However, the registration function currently takes no arguments so would need an optional argument adding. If the purpose of this is to keep the users id in the text field this will need propagating to the control helper function. Or maybe I have missed the point of the call to “register” in the code above.

Either way further clarification in the book would be a great help.

23 Sep 2013, 23:01
Dmitri Sotnikov (149 posts)

That’s a typo that made it in from the older draft. The (register id) function call should not be there. The code should be calling (registration-page) if the password check fails. Thanks for reporting it.