diff options
author | Marco Ziener <mziener@lavabit.com> | 2010-10-14 15:52:57 +0200 |
---|---|---|
committer | Marco Ziener <mziener@lavabit.com> | 2010-10-14 15:52:57 +0200 |
commit | be34a99dbb4e516d7592d6a19d0c662b6d81ab17 (patch) | |
tree | 4143872b7aa0cce0e7c14c71adfd892a490ef1da | |
parent | e25c2d52d30bc1c0c68612ff48a2cd889631f937 (diff) | |
download | erlang-be34a99dbb4e516d7592d6a19d0c662b6d81ab17.tar.gz erlang-be34a99dbb4e516d7592d6a19d0c662b6d81ab17.tar.xz erlang-be34a99dbb4e516d7592d6a19d0c662b6d81ab17.zip |
Blub
-rw-r--r-- | server/cldb.erl | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/server/cldb.erl b/server/cldb.erl index 9aad688..6f6f4d2 100644 --- a/server/cldb.erl +++ b/server/cldb.erl @@ -2,22 +2,31 @@ -module(cldb). -export([init/0]). --record(user, {name, passwd, votes}). +-record(user, {name, passwd, votes, rights}). init() -> mnesia:create_schema([node()]), mnesia:start(), - mnesia:create_table(track, [{attributes, record_info(fields, track)}]), + mnesia:create_table(user, [{attributes, record_info(fields, user)}]), io:format("Userdb up and running \n"). - ask(User, Pwd) -> F = fun() -> - mnesia:match_object({user, User, Pwd, _}), + mnesia:match_object({user, User, Pwd, '_'}) end, + mnesia:transaction(F). login(User, Pwd) -> {_, Reason} = ask(User, Pwd), Reason. + +register(User, Pwd, Root) -> + F = fun() -> + mnesia:write(#user{name = User, passwd = Pwd, votes = 5, rights = Root}) + end, + {_, Reason} = mnesia:transaction(F), + Reason. + + |