feat(api): optional auth for public search and studio week. Refs EventHub/EventHubFront#58
This commit is contained in:
@@ -115,13 +115,13 @@ calendar_update_schema() ->
|
||||
%%% Internal functions
|
||||
|
||||
get_calendar(Req) ->
|
||||
case handler_utils:auth_user(Req) of
|
||||
case handler_utils:auth_user_optional(Req) of
|
||||
{ok, UserId, Req1} ->
|
||||
CalendarId = cowboy_req:binding(id, Req1),
|
||||
case logic_calendar:get_calendar(UserId, CalendarId) of
|
||||
{ok, Calendar} ->
|
||||
Json0 = handler_utils:calendar_to_json(Calendar),
|
||||
Following = logic_calendar_follow:is_following(UserId, CalendarId),
|
||||
Following = UserId =/= <<>> andalso logic_calendar_follow:is_following(UserId, CalendarId),
|
||||
handler_utils:send_json(Req1, 200, Json0#{following => Following});
|
||||
{error, access_denied} ->
|
||||
handler_utils:send_error(Req1, 403, <<"Access denied">>);
|
||||
|
||||
Reference in New Issue
Block a user