Use macros for the cookie names.
parent
812b182499
commit
861f3e0258
|
@ -263,8 +263,8 @@ Spec:
|
|||
Cookie :: binary().
|
||||
|
||||
auth_cookies(Req) ->
|
||||
#{dudeauth := Cookie, dudename := User} = cowboy_req:match_cookies([dudeauth,
|
||||
dudename], Req),
|
||||
#{?DUDEAUTH := Cookie, ?DUDENAME := User} = cowboy_req:match_cookies([?DUDEAUTH,
|
||||
?DUDENAME], Req),
|
||||
|
||||
{User, Cookie}.
|
||||
|
||||
|
@ -287,9 +287,9 @@ completely invalidated.
|
|||
Req0 :: cowboy_req:req().
|
||||
|
||||
invalidate_cookies(Req) ->
|
||||
Req0 = cowboy_req:set_resp_cookie(<<"dudeauth">>, <<"">>, Req,
|
||||
Req0 = cowboy_req:set_resp_cookie(<<"?DUDEAUTH">>, <<"">>, Req,
|
||||
#{max_age => 0}),
|
||||
Req1 = cowboy_req:set_resp_cookie(<<"dudename">>, <<"">>, Req0,
|
||||
Req1 = cowboy_req:set_resp_cookie(<<"?DUDENAME">>, <<"">>, Req0,
|
||||
#{max_age => 0}),
|
||||
|
||||
Req1.
|
||||
|
@ -318,9 +318,9 @@ A new request object `Req0`is returned, with the user and auth cookies set.
|
|||
Req0 :: cowboy_req:req().
|
||||
|
||||
set_auth_cookies(Req, User, Cookie, Validity) ->
|
||||
Req0 = cowboy_req:set_resp_cookie(<<"dudeauth">>, Cookie, Req,
|
||||
Req0 = cowboy_req:set_resp_cookie(<<"?DUDEAUTH">>, Cookie, Req,
|
||||
#{max_age => Validity}),
|
||||
Req1 = cowboy_req:set_resp_cookie(<<"dudename">>, User, Req0,
|
||||
Req1 = cowboy_req:set_resp_cookie(<<"?DUDENAME">>, User, Req0,
|
||||
#{max_age => Validity}),
|
||||
|
||||
Req1.
|
||||
|
|
Loading…
Reference in New Issue