n2o Erlang framework email authentication -
i'm new erlang , n2o have experience in python web development. want create authentication email address (email - password) in application instead of using avz. i've created sign page code (other code n2o_sample). instead of putting user kvs
have {error, no_container}
-module(signup_page). -compile(export_all). -include_lib("n2o/include/wf.hrl"). -include_lib("n2o_sample/include/users.hrl"). title() -> [ <<"sign page">> ]. main() -> #dtl{file = "login", app = n2o_sample, bindings = [{title,title()},{body,body()}]}. body() -> [ #span{id=display}, #br{}, #span{body="email: "}, #textbox{id=user}, #br{}, #span{body="password: "}, #password{id=pass}, #br{}, #span{body="confirm password"}, #password{id=confirm}, #br{}, #button{id=signup, body="sign up", postback=signup,source=[user,pass,confirm]}]. event(signup) -> user = wf:q(user), password = wf:q(pass), confirm = wf:q(confirm), u = kvs:get(user, user, undefined), case u of {ok, undefined} -> case password of undefined -> wf:update(display, <<"no pass">>); confirm -> status = kvs:put(#user{id=user}), % -> {error, no_container} io:format("~w~n", [status]); b -> io:format("~w~n", [b]) end; -> io:format("~w~n", [a]), wf:update(display, <<"already registered!">>) end; event(_) -> [].
you right.
the question kvs configuring. make kvs working should several steps:
1. put kvs rebar.config
{kvs, ".*", {git, "git://github.com/synrc/kvs", {tag,"1.5.0"}}},
use frozen tag version, e.g. "1.5.0" latest stable.
2. configure kvs application in sys.config
{n2o, [{port,8000},{transition_port, 8000}]}, {kvs, [{dba,store_mnesia}, {schema, [kvs_user, kvs_acl, kvs_feed, kvs_subscription ]} ]},
i put in example n2o configuring see should placed.
3. just after first launch of "make console" should initialize db in erlang shell:
1> kvs:join().
this instantiate mnesia tables.
4. after in erlang shell please check of problem:
2> rr(kvs_user).
first load records kvs_user module. perform check:
3> kvs:put(#user{id="maxim@synrc.com"}).
Comments
Post a Comment