aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorMarco Ziener <mziener@lavabit.com>2010-10-14 15:52:57 +0200
committerMarco Ziener <mziener@lavabit.com>2010-10-14 15:52:57 +0200
commitbe34a99dbb4e516d7592d6a19d0c662b6d81ab17 (patch)
tree4143872b7aa0cce0e7c14c71adfd892a490ef1da /server
parente25c2d52d30bc1c0c68612ff48a2cd889631f937 (diff)
downloaderlang-be34a99dbb4e516d7592d6a19d0c662b6d81ab17.tar.gz
erlang-be34a99dbb4e516d7592d6a19d0c662b6d81ab17.tar.xz
erlang-be34a99dbb4e516d7592d6a19d0c662b6d81ab17.zip
Blub
Diffstat (limited to 'server')
-rw-r--r--server/cldb.erl17
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.
+
+