Use the auth_cookie function to extract cookies.

main
absc 2024-08-15 21:02:41 +00:00
parent dac21c4537
commit a18fa4989c
1 changed files with 3 additions and 5 deletions

View File

@ -94,8 +94,7 @@ forbidden(Req, State) ->
<<"POST">> ->
{false, Req, State};
_ ->
#{dudeauth := Auth, dudename := User} = cowboy_req:match_cookies([dudeauth,
dudename], Req),
{User, Auth} = dudeswave_auth:auth_cookies(Req),
case dudeswave_auth:authenticate(User, {cookie, Auth}) of
{error, service_unavailable} -> exit(service_unavailable);
@ -113,7 +112,7 @@ content_types_accepted(Req, State) ->
end.
resource_exists(Req, State) ->
#{dudename := User} = cowboy_req:match_cookies([dudename], Req),
{User, _} = dudeswave_auth:auth_cookies(Req),
case dudeswave_auth:details(User) of
[] ->
@ -136,8 +135,7 @@ is_conflict(Req, State) -> {true, Req, State}.
allow_missing_post(Req, State) -> {false, Req, State}.
delete_resource(Req, State) ->
#{dudename := User, dudeauth := Auth} = cowboy_req:match_cookies([dudename,
dudeauth], Req),
{User, Auth} = dudeswave_auth:auth_cookies(Req),
case dudeswave_auth:logout(User, Auth) of
ok ->