Updated che back-end to use the new multi-host calls.
The listeners update will come later.main
parent
b1c4ab8e16
commit
ea339a1024
|
@ -24,8 +24,8 @@
|
|||
-export([init/1, handle_call/3, handle_cast/2, terminate/2]).
|
||||
|
||||
% Public API exports
|
||||
-export([auth/3, logout/2, user_details/1, new_user/3,
|
||||
update_user/4, delete_user/1]).
|
||||
-export([auth/4, logout/3, user_details/2, new_user/4,
|
||||
update_user/5, delete_user/2]).
|
||||
|
||||
%
|
||||
% Startup functions
|
||||
|
@ -47,33 +47,33 @@ init([]) ->
|
|||
% Users management
|
||||
%
|
||||
|
||||
auth(cookie, User, Cookie) ->
|
||||
gen_server:call({local, ?MODULE}, {cookie, User, Cookie});
|
||||
auth(cookie, User, Host, Cookie) ->
|
||||
gen_server:call({local, ?MODULE}, {cookie, User, Host, Cookie});
|
||||
|
||||
auth(password, User, Password) ->
|
||||
gen_server:call({local, ?MODULE}, {password, User, Password}).
|
||||
auth(password, User, Host, Password) ->
|
||||
gen_server:call({local, ?MODULE}, {password, User, Host, Password}).
|
||||
|
||||
logout(User, Cookie) ->
|
||||
gen_server:call({local, ?MODULE}, {logout, User, Cookie}).
|
||||
logout(User, Host, Cookie) ->
|
||||
gen_server:call({local, ?MODULE}, {logout, User, Host, Cookie}).
|
||||
|
||||
user_details(User) ->
|
||||
gen_server:call({local, ?MODULE}, {user_details, User}).
|
||||
user_details(User, Host) ->
|
||||
gen_server:call({local, ?MODULE}, {user_details, User, Host}).
|
||||
|
||||
new_user(User, Password, Email) ->
|
||||
gen_server:call({local, ?MODULE}, {new_user, User, Password, Email}).
|
||||
new_user(User, Host, Password, Email) ->
|
||||
gen_server:call({local, ?MODULE}, {new_user, User, Host, Password, Email}).
|
||||
|
||||
update_user(User, Name, Email, Desc) ->
|
||||
gen_server:call({local, ?MODULE}, {update_user, User, Name, Email, Desc}).
|
||||
update_user(User, Host, Name, Email, Desc) ->
|
||||
gen_server:call({local, ?MODULE}, {update_user, User, Host, Name, Email, Desc}).
|
||||
|
||||
delete_user(User) ->
|
||||
gen_server:call({local, ?MODULE}, {delete_user, User}).
|
||||
delete_user(User, Host) ->
|
||||
gen_server:call({local, ?MODULE}, {delete_user, User, Host}).
|
||||
|
||||
%
|
||||
% Callbacks
|
||||
%
|
||||
|
||||
handle_call({cookie, User, Cookie}, _From, State) ->
|
||||
case dudeswave_users:authenticate(cookie, User, Cookie) of
|
||||
handle_call({cookie, User, Host, Cookie}, _From, State) ->
|
||||
case dudeswave_users:authenticate(cookie, User, Host, Cookie) of
|
||||
true ->
|
||||
{reply, true, State};
|
||||
false ->
|
||||
|
@ -82,8 +82,8 @@ handle_call({cookie, User, Cookie}, _From, State) ->
|
|||
{reply, {error, Reason}, State}
|
||||
end;
|
||||
|
||||
handle_call({password, User, Password}, _From, State) ->
|
||||
case dudeswave_users:authenticate(password, User, Password) of
|
||||
handle_call({password, User, Host, Password}, _From, State) ->
|
||||
case dudeswave_users:authenticate(password, User, Host, Password) of
|
||||
{true, Cookie, Validity} ->
|
||||
{reply, {true, Cookie, Validity}, State};
|
||||
false ->
|
||||
|
@ -92,33 +92,33 @@ handle_call({password, User, Password}, _From, State) ->
|
|||
{reply, {error, Reason}, State}
|
||||
end;
|
||||
|
||||
handle_call({logout, User, Cookie}, _From, State) ->
|
||||
case dudeswave_users:logout(User, Cookie) of
|
||||
handle_call({logout, User, Host, Cookie}, _From, State) ->
|
||||
case dudeswave_users:logout(User, Host, Cookie) of
|
||||
ok -> {reply, ok, State};
|
||||
{error, Reason} -> {reply, {error, Reason}, State}
|
||||
end;
|
||||
|
||||
handle_call({user_details, User}, _From, State) ->
|
||||
case dudeswave_users:details(User) of
|
||||
handle_call({user_details, User, Host}, _From, State) ->
|
||||
case dudeswave_users:details(User, Host) of
|
||||
{error, not_found} -> {reply, not_found, State};
|
||||
{error, Reason} -> {reply, {error, Reason}, State};
|
||||
Val -> {reply, Val, State}
|
||||
end;
|
||||
|
||||
handle_call({new_user, User, Password, Email}, _From, State) ->
|
||||
case dudeswave_users:new(User, Password, Email) of
|
||||
handle_call({new_user, User, Host, Password, Email}, _From, State) ->
|
||||
case dudeswave_users:new(User, Host, Password, Email) of
|
||||
ok -> {reply, ok, State};
|
||||
{error, Reason} -> {reply, {error, Reason}, State}
|
||||
end;
|
||||
|
||||
handle_call({update_user, User, Name, Email, Desc}, _From, State) ->
|
||||
case dudeswave_users:update(User, Name, Email, Desc) of
|
||||
handle_call({update_user, User, Host, Name, Email, Desc}, _From, State) ->
|
||||
case dudeswave_users:update(User, Host, Name, Email, Desc) of
|
||||
ok -> {reply, ok, State};
|
||||
{error, Reason} -> {reply, {error, Reason}, State}
|
||||
end;
|
||||
|
||||
handle_call({delete_user, User}, _From, State) ->
|
||||
case dudeswave_users:delete(User) of
|
||||
handle_call({delete_user, User, Host}, _From, State) ->
|
||||
case dudeswave_users:delete(User, Host) of
|
||||
ok -> {reply, ok, State};
|
||||
{error, Reason} -> {reply, {error, Reason}, State}
|
||||
end.
|
||||
|
|
Loading…
Reference in New Issue