aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorMarco Ziener <mziener@lavabit.com>2010-10-13 15:27:56 +0200
committerMarco Ziener <mziener@lavabit.com>2010-10-13 15:27:56 +0200
commit4ba5338d3279cd75106aa96810b91e35e692a49f (patch)
tree2d5f3a2a37c43f1b0461689ac911f49c992b83cd /server
parent86442139036c7d1b8be83b60d43197a618ac93c6 (diff)
parentd1c3af4f92f169853262dcc7f6c58bdd287c21ca (diff)
downloaderlang-4ba5338d3279cd75106aa96810b91e35e692a49f.tar.gz
erlang-4ba5338d3279cd75106aa96810b91e35e692a49f.tar.xz
erlang-4ba5338d3279cd75106aa96810b91e35e692a49f.zip
Merge branch 'master' of ssh://git.animux.de/erlang
Diffstat (limited to 'server')
-rw-r--r--server/client.erl8
-rw-r--r--server/dispatcher.erl10
2 files changed, 12 insertions, 6 deletions
diff --git a/server/client.erl b/server/client.erl
index 72658b7..7139e67 100644
--- a/server/client.erl
+++ b/server/client.erl
@@ -1,5 +1,5 @@
-module(client).
--export([start/1, loop/1]).
+-export([start/1, loop/1, register/2, login/2]).
start(Client) ->
spawn(client, loop, Client).
@@ -13,3 +13,9 @@ loop(Client) ->
Client ! {error, unknown_command},
loop(Client)
end.
+
+register(Client, {Name, Password}) ->
+ dis ! {Client, {register, {Name, Password}}}.
+
+login(Client, {Name, Password}) ->
+ dis ! {Client, {login, {Name, Password}}}.
diff --git a/server/dispatcher.erl b/server/dispatcher.erl
index 86b2627..a296c78 100644
--- a/server/dispatcher.erl
+++ b/server/dispatcher.erl
@@ -8,18 +8,18 @@ init() ->
dict:new().
handle(_, {register, {User, Password}}, Dict) ->
- case dict:find(User) of
- {ok, _} ->
+ case dict:find(User, Dict) of
+ {ok, _}->
{{error, duplicated_user}, Dict};
- true ->
+ _ ->
{{ok, user_created}, dict:store(User, Password, Dict)}
end;
handle(From, {login, {User, Password}}, Dict) ->
- case dict:find(User) of
+ case dict:find(User, Dict) of
{ok, Password} ->
{{ok, {logged_in, client:start(From)}}, Dict};
- true ->
+ _ ->
{{error, user_or_password_invalid}, Dict}
end;