Рефакторинг обработчиков. Часть 3 #21
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
-module(admin_utils).
|
||||
-include("records.hrl").
|
||||
|
||||
-export([is_admin/1, check_role/2, get_permissions/1]).
|
||||
-export([is_admin/1, check_role/2, get_permissions/1, is_superadmin/1]).
|
||||
-export([client_ip/1]).
|
||||
|
||||
is_admin(UserId) ->
|
||||
@@ -10,6 +10,12 @@ is_admin(UserId) ->
|
||||
_ -> false
|
||||
end.
|
||||
|
||||
is_superadmin(AdminId) ->
|
||||
case core_admin:get_by_id(AdminId) of
|
||||
{ok, #admin{role = superadmin}} -> true;
|
||||
_ -> false
|
||||
end.
|
||||
|
||||
%% Проверка конкретной роли (или одной из списка ролей)
|
||||
-spec check_role(UserId :: binary(), RequiredRole :: atom() | [atom()]) -> boolean().
|
||||
check_role(UserId, RequiredRoles) when is_list(RequiredRoles) ->
|
||||
|
||||
Reference in New Issue
Block a user