Ролевая модель и аудит Часть 1.
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user