Cleaned auth module by removing useless code.
Added CMS_USER_API.user_role_by_name (a_name: READABLE_STRING_GENERAL): detachable CMS_USER_ROLE Added enabled/disabled status in admin/install.
This commit is contained in:
@@ -137,6 +137,11 @@ feature -- Access: roles and permissions
|
||||
deferred
|
||||
end
|
||||
|
||||
user_role_by_name (a_name: READABLE_STRING_GENERAL): detachable CMS_USER_ROLE
|
||||
-- User role by name `a_id', if any.
|
||||
deferred
|
||||
end
|
||||
|
||||
user_roles_for (a_user: CMS_USER): LIST [CMS_USER_ROLE]
|
||||
-- User roles for user `a_user'.
|
||||
-- Note: anonymous and authenticated roles are not included.
|
||||
@@ -179,4 +184,7 @@ feature -- Change: User password recovery
|
||||
deferred
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
end
|
||||
|
||||
@@ -66,6 +66,10 @@ feature -- Access: roles and permissions
|
||||
do
|
||||
end
|
||||
|
||||
user_role_by_name (a_name: READABLE_STRING_GENERAL): detachable CMS_USER_ROLE
|
||||
do
|
||||
end
|
||||
|
||||
user_roles_for (a_user: CMS_USER): LIST [CMS_USER_ROLE]
|
||||
-- User roles for user `a_user'.
|
||||
-- Note: anonymous and authenticated roles are not included.
|
||||
@@ -108,4 +112,7 @@ feature -- Change: User password recovery
|
||||
do
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
end
|
||||
|
||||
@@ -357,6 +357,26 @@ feature -- Access: roles and permissions
|
||||
end
|
||||
end
|
||||
|
||||
user_role_by_name (a_name: READABLE_STRING_GENERAL): detachable CMS_USER_ROLE
|
||||
-- User role by name `a_name', if any.
|
||||
local
|
||||
l_parameters: STRING_TABLE [ANY]
|
||||
do
|
||||
error_handler.reset
|
||||
write_information_log (generator + ".user_role_by_name")
|
||||
create l_parameters.make (1)
|
||||
l_parameters.put (a_name, "name")
|
||||
sql_query (select_user_role_by_name, l_parameters)
|
||||
if sql_rows_count = 1 then
|
||||
Result := fetch_user_role
|
||||
if Result /= Void and not has_error then
|
||||
fill_user_role (Result)
|
||||
end
|
||||
else
|
||||
check no_more_than_one: sql_rows_count = 0 end
|
||||
end
|
||||
end
|
||||
|
||||
user_roles_for (a_user: CMS_USER): LIST [CMS_USER_ROLE]
|
||||
local
|
||||
l_parameters: STRING_TABLE [ANY]
|
||||
@@ -817,6 +837,9 @@ feature {NONE} -- Sql Queries: USER ROLE
|
||||
select_user_role_by_id: STRING = "SELECT rid, name FROM roles WHERE rid=:rid;"
|
||||
-- User role for role id :rid;
|
||||
|
||||
select_user_role_by_name: STRING = "SELECT rid, name FROM roles WHERE name=:name;"
|
||||
-- User role for role name :name;
|
||||
|
||||
sql_insert_user_role_permission: STRING = "INSERT INTO role_permissions (rid, permission, module) VALUES (:rid, :permission, :module);"
|
||||
-- SQL Insert a new permission :permission for user role :rid.
|
||||
|
||||
|
||||
@@ -66,7 +66,13 @@ feature -- HTTP Methods
|
||||
loop
|
||||
l_module := ic.item
|
||||
if api.is_module_installed (l_module) then
|
||||
s.append ("<li>" + l_module.name + " is already installed.</li>%N")
|
||||
s.append ("<li>")
|
||||
s.append (l_module.name)
|
||||
if l_module.is_enabled then
|
||||
s.append (" </strong>[enabled]</strong>")
|
||||
end
|
||||
s.append (" is already installed.")
|
||||
s.append ("</li>%N")
|
||||
else
|
||||
lst.force (l_module)
|
||||
end
|
||||
@@ -76,11 +82,19 @@ feature -- HTTP Methods
|
||||
lst as ic
|
||||
loop
|
||||
l_module := ic.item
|
||||
if api.is_module_installed (l_module) then
|
||||
s.append ("<li>" + l_module.name + " was successfully installed.</li>%N")
|
||||
else
|
||||
s.append ("<li>" + l_module.name + " could not be installed!</li>%N")
|
||||
s.append ("<li>")
|
||||
s.append (l_module.name)
|
||||
if l_module.is_enabled then
|
||||
s.append (" </strong>[enabled]</strong>")
|
||||
end
|
||||
|
||||
if api.is_module_installed (l_module) then
|
||||
s.append (" was successfully installed.")
|
||||
else
|
||||
s.append (" could not be installed!")
|
||||
s.append (" <span class=%"error%">[ERROR]</span>")
|
||||
end
|
||||
s.append ("</li>%N")
|
||||
end
|
||||
s.append ("</ul>")
|
||||
r.set_main_content (s)
|
||||
|
||||
@@ -123,6 +123,11 @@ feature -- User roles.
|
||||
Result := storage.user_role_by_id (a_id)
|
||||
end
|
||||
|
||||
user_role_by_name (a_name: READABLE_STRING_GENERAL): detachable CMS_USER_ROLE
|
||||
do
|
||||
Result := storage.user_role_by_name (a_name)
|
||||
end
|
||||
|
||||
feature -- Change User
|
||||
|
||||
new_user (a_user: CMS_USER)
|
||||
|
||||
Reference in New Issue
Block a user