Перенести все админские эндпоинты на порт 8445 и добавить отдельную авторизацию для админов. Часть 2. Final #3

This commit is contained in:
2026-04-28 12:42:10 +03:00
parent 4ed6a961ab
commit 7ea4efd7d9
38 changed files with 1252 additions and 1124 deletions
+3 -3
View File
@@ -2,7 +2,7 @@
-behaviour(cowboy_handler).
-export([init/2]).
-include("records.hrl"). %% ← обязательно для #user{} и #report{}
-include("records.hrl").
init(Req, _Opts) ->
case cowboy_req:method(Req) of
@@ -16,7 +16,7 @@ list_reports(Req) ->
{ok, AdminId, Req1} ->
case is_admin(AdminId) of
true ->
Reports = core_report:list_reports(),
{ok, Reports} = core_report:list_all(),
send_json(Req1, 200, [report_to_json(R) || R <- Reports]);
false ->
send_error(Req1, 403, <<"Admin access required">>)
@@ -34,7 +34,7 @@ update_report(Req) ->
{ok, Body, Req2} = cowboy_req:read_body(Req1),
try jsx:decode(Body, [return_maps]) of
#{<<"status">> := NewStatus} ->
case core_report:update_status(ReportId, NewStatus) of
case core_report:update_status(ReportId, NewStatus, AdminId) of
{ok, Report} ->
send_json(Req2, 200, report_to_json(Report));
{error, not_found} ->