Hi Bill, Yes, you are quite right. We now have to deal in binaries.
You should just be able to put: proplists:get_value(<<"redirect">>, Req:post_params(), "/"), Regards, Graeme On 20 February 2016 at 06:35, Bill Norman <[email protected]> wrote: > Hello, > > I am currently going through the 'Evening with Chicago Boss tutorial. > > I am following instructions for handling user authentication and have > implemented this code fragment in the > controller/evening_user_controller.erl: > > > 1. login('POST', []) -> > 2. Name = Req:post_param("name"), > 3. case boss_db:find(ward_boss, [{name, Name}], [{limit,1}]) of > 4. [WardBoss] -> > 5. case WardBoss:check_password(Req:post_param("password")) of > 6. true -> > 7. {redirect, proplists:get_value("redirect", > 8. Req:post_params(), "/"), > WardBoss:login_cookies()}; > 9. false -> > 10. {ok, [{error, "Bad name/password combination"}]} > 11. end; > 12. [] -> > 13. {ok, [{error, "No Ward Boss named " ++ Name}]} > 14. end. > > My issue is that the value of the redirect (lines 7 & 8) calculates to the > default value "/" in proplists:get_value/3. > > The return value of Req:post_params() is: > [{<<"name">>,<<"Bathhouse John">>}, > {<<"password">>,<<"password">>}, > {<<"redirect">>,<<"http://localhost:8001/voter/list">>}] > > so querying this list with proplists:get_value("redirect", Req:post_params()) > returns undefined. > > I modified the code to: > binary_to_list(proplists:get_value(list_to_binary("redirect"), > Req:post_params())) > > This works but it is awfully ugly. > > Is there a helper method in Chicago Boss or a more elegant erlang conversion > term > I could use to handle the binary tuples returned by Req:get_params()? > > What has changed since this tutorial was written? Has the output of > Req:get_params() > changed? > > Thanks > > -- > You received this message because you are subscribed to the Google Groups > "ChicagoBoss" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > Visit this group at https://groups.google.com/group/chicagoboss. > To view this discussion on the web visit > https://groups.google.com/d/msgid/chicagoboss/83ae8c3e-2668-4745-9d11-4519af0c21ed%40googlegroups.com > <https://groups.google.com/d/msgid/chicagoboss/83ae8c3e-2668-4745-9d11-4519af0c21ed%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "ChicagoBoss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. Visit this group at https://groups.google.com/group/chicagoboss. To view this discussion on the web visit https://groups.google.com/d/msgid/chicagoboss/CAKF5fiB4TzJSyqg%3DyL%2BSO9RTg_i8hONJN4QHkSQJeKwH%2Bxu8YA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
