aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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.
+
+