Ролевая модель и аудит Часть 1.

This commit is contained in:
2026-04-28 19:12:02 +03:00
parent 7ea4efd7d9
commit b2cea7896d
32 changed files with 369 additions and 320 deletions

View File

@@ -17,7 +17,7 @@ handle(Req, _Opts) ->
list_tickets(Req) ->
case handler_auth:authenticate(Req) of
{ok, UserId, Req1} ->
case is_admin(UserId) of
case admin_utils:is_admin(UserId) of
true ->
Tickets = core_ticket:list_all(),
send_json(Req1, 200, [ticket_to_json(T) || T <- Tickets]);
@@ -51,13 +51,6 @@ create_ticket(Req) ->
send_error(Req1, Code, Message)
end.
is_admin(UserId) ->
case core_user:get_by_id(UserId) of
{ok, User} ->
lists:member(User#user.role, [admin, superadmin, moderator, support]);
_ -> false
end.
ticket_to_json(T) ->
#{
id => T#ticket.id,