Ролевая модель и аудит Часть 1.
This commit is contained in:
@@ -95,7 +95,7 @@ update_banned_word(Word, Req) ->
|
||||
auth_admin(Req) ->
|
||||
case handler_auth:authenticate(Req) of
|
||||
{ok, AdminId, Req1} ->
|
||||
case is_admin(AdminId) of
|
||||
case admin_utils:is_admin(AdminId) of
|
||||
true -> {ok, AdminId, Req1};
|
||||
false -> {error, 403, <<"Admin access required">>, Req1}
|
||||
end;
|
||||
@@ -103,15 +103,6 @@ auth_admin(Req) ->
|
||||
{error, Code, Message, Req1}
|
||||
end.
|
||||
|
||||
is_admin(UserId) ->
|
||||
case core_user:get_by_id(UserId) of
|
||||
{ok, User} ->
|
||||
Role = User#user.role,
|
||||
Role =:= admin orelse Role =:= superadmin orelse
|
||||
Role =:= moderator orelse Role =:= support;
|
||||
_ -> false
|
||||
end.
|
||||
|
||||
banned_word_to_json(BW) ->
|
||||
#{
|
||||
id => BW#banned_word.id,
|
||||
|
||||
Reference in New Issue
Block a user