Corrected stuffs found through the dialyzer.

main
absc 2024-08-11 20:56:11 +00:00
parent 2b530fbe7e
commit 640ffe4d75
1 changed files with 11 additions and 9 deletions

View File

@ -181,7 +181,7 @@ forbidden(Req, State) ->
dudename], Req), dudename], Req),
{ok, Bucket} = maps:find(cookies, State), {ok, Bucket} = maps:find(cookies, State),
case dudeswave_auth:authenticate({cookie, User, Auth}, Bucket) of case dudeswave_auth:authenticate(User, Auth, Bucket) of
{error, service_unavailable} -> {error, service_unavailable} ->
Resp = json:encode(#{<<"error">> => <<"internal server error">>}), Resp = json:encode(#{<<"error">> => <<"internal server error">>}),
Req0 = cowboy_req:reply(500, #{}, Resp, Req), Req0 = cowboy_req:reply(500, #{}, Resp, Req),
@ -218,7 +218,7 @@ resource_exists(Req, State) ->
#{dudename := User} = cowboy_req:match_cookies([dudename], Req), #{dudename := User} = cowboy_req:match_cookies([dudename], Req),
{ok, Bucket} = maps:find(bucket, State), {ok, Bucket} = maps:find(bucket, State),
case dudeswave_auth:user_details(User, Bucket) of case dudeswave_auth:details(User, Bucket) of
[] -> [] ->
Resp = json:encode(#{<<"error">> => <<"user does not exists">>}), Resp = json:encode(#{<<"error">> => <<"user does not exists">>}),
Req0 = cowboy_req:reply(404, #{}, Resp, Req), Req0 = cowboy_req:reply(404, #{}, Resp, Req),
@ -271,25 +271,27 @@ create_user(Req, State) ->
{ok, Bucket} = maps:find(bucket, State), {ok, Bucket} = maps:find(bucket, State),
#{dudename := User} = cowboy_req:match_cookies([dudename], Req), #{dudename := User} = cowboy_req:match_cookies([dudename], Req),
#{<<"password">> := Pass, <<"email">> := Email} = json:decode(cowboy_req:body(req)), {ok, Data, Req0} = cowboy_req:read_body(Req),
#{<<"password">> := Pass, <<"email">> := Email} = json:decode(Data),
case dudeswave_auth:new_user(User, Pass, Email, Bucket) of case dudeswave_auth:new(User, Pass, Email, Bucket) of
ok -> ok ->
Resp = json:encode(#{<<"result">> => <<"created">>}), Resp = json:encode(#{<<"result">> => <<"created">>}),
Req0 = cowboy_req:reply(201, #{}, Resp, Req), Req1 = cowboy_req:reply(201, #{}, Resp, Req0),
{true, Req0, []}; {true, Req1, []};
{error, _} -> {error, _} ->
Resp = json:encode(#{<<"error">> => <<"internal server error">>}), Resp = json:encode(#{<<"error">> => <<"internal server error">>}),
Req0 = cowboy_req:reply(500, #{}, Resp, Req), Req1 = cowboy_req:reply(500, #{}, Resp, Req0),
{false, Req0, State} {false, Req1, State}
end. end.
modify_user(Req, State) -> modify_user(Req, State) ->
{ok, Bucket} = maps:find(bucket, State), {ok, Bucket} = maps:find(bucket, State),
#{dudename := User} = cowboy_req:match_cookies([dudename], Req), #{dudename := User} = cowboy_req:match_cookies([dudename], Req),
{ok, Data, Req0} = cowboy_req:read_body(Req),
#{<<"email">> := Email, <<"description">> := Desc, #{<<"email">> := Email, <<"description">> := Desc,
<<"name">> := Name} = json:decode(cowboy_req:body(req)), <<"name">> := Name} = json:decode(Data),
case dudeswave_auth:update(User, Name, Email, Desc, Bucket) of case dudeswave_auth:update(User, Name, Email, Desc, Bucket) of
ok -> ok ->