Corrected authenticate function calls.

main
absc 2024-08-15 20:37:08 +00:00
parent 73d98ed56f
commit 29cb046e3d
1 changed files with 2 additions and 2 deletions

View File

@ -97,7 +97,7 @@ forbidden(Req, State) ->
#{dudeauth := Auth, dudename := User} = cowboy_req:match_cookies([dudeauth, #{dudeauth := Auth, dudename := User} = cowboy_req:match_cookies([dudeauth,
dudename], Req), dudename], Req),
case dudeswave_auth:authenticate(User, Auth) of case dudeswave_auth:authenticate(User, {cookie, Auth}) of
{error, service_unavailable} -> exit(service_unavailable); {error, service_unavailable} -> exit(service_unavailable);
true -> {false, Req, State}; true -> {false, Req, State};
false -> {true, Req, State} false -> {true, Req, State}
@ -159,7 +159,7 @@ login(Req, State) ->
{ok, Data, Req0} = cowboy_req:read_body(Req), {ok, Data, Req0} = cowboy_req:read_body(Req),
#{<<"user">> := User, <<"password">> := Pass} = json:decode(Data), #{<<"user">> := User, <<"password">> := Pass} = json:decode(Data),
case dudeswave_auth:authenticate(User, Pass) of case dudeswave_auth:authenticate(User, {password, Pass}) of
{true, Cookie, Validity} -> {true, Cookie, Validity} ->
Req1 = cowboy_req:set_resp_cookie(<<"dudeauth">>, Cookie, Req0, Req1 = cowboy_req:set_resp_cookie(<<"dudeauth">>, Cookie, Req0,
#{max_age => Validity}), #{max_age => Validity}),