Removed obsolete calls, harmonized predefine response, added non admin user pages.
When access is denied, also provide when possible and wanted, the needed
permissions so that in the future, user will be able to ask for
permission easily.
Renamed previous user handlers as admin user handlers.
Added non admin user handler /user/{uid} .
Add new `send_...` response to `CMS_API.response_api`, and use them
instead of `create {...RESPONSE}.... ; execute`.
Fixed potential issue with storage mailer initialization if folder does
not exist.
Added utf_8_encoded helpers function on CMS_API interface.
Fixed a few unicode potential issues.
Removed a few obsolete calls.
This commit is contained in:
@@ -348,9 +348,9 @@ feature -- Form
|
||||
fs.extend (lab)
|
||||
string_sorter.sort (l_permissions)
|
||||
across l_permissions as ic loop
|
||||
create cb.make_with_value ("cms_permissions", ic.item)
|
||||
create cb.make_with_value ("cms_permissions", ic.item.to_string_32)
|
||||
cb.set_checked (across l_role_permissions as rp_ic some rp_ic.item.is_case_insensitive_equal (ic.item) end)
|
||||
cb.set_title (ic.item)
|
||||
cb.set_title (ic.item.to_string_32)
|
||||
fs.extend (cb)
|
||||
end
|
||||
end
|
||||
@@ -389,7 +389,7 @@ feature -- Form
|
||||
update_role (a_form_data: WSF_FORM_DATA; a_role: CMS_USER_ROLE)
|
||||
-- Update node `a_node' with form_data `a_form_data' for the given content type `a_content_type'.
|
||||
local
|
||||
l_perm: READABLE_STRING_8
|
||||
l_perm: READABLE_STRING_GENERAL
|
||||
do
|
||||
if attached a_form_data.string_item ("op") as f_op then
|
||||
if f_op.is_case_insensitive_equal_general ("Update role") then
|
||||
@@ -400,16 +400,16 @@ feature -- Form
|
||||
then
|
||||
if attached {WSF_STRING} a_form_data.item ("cms_permissions") as u_role then
|
||||
a_role.permissions.wipe_out
|
||||
a_role.add_permission (u_role.value)
|
||||
a_role.add_permission (api.utf_8_encoded (u_role.value)) -- TODO: utf-8 or require valid string 8?
|
||||
elseif attached {WSF_MULTIPLE_STRING} a_form_data.item ("cms_permissions") as u_permissions then
|
||||
a_role.permissions.wipe_out
|
||||
-- Enable checked permissions.
|
||||
across
|
||||
u_permissions as ic
|
||||
loop
|
||||
l_perm := ic.item.value.as_string_8
|
||||
l_perm := ic.item.value
|
||||
if not l_perm.is_whitespace then
|
||||
a_role.add_permission (l_perm)
|
||||
a_role.add_permission (api.utf_8_encoded (l_perm)) -- TODO: utf-8 or require valid string 8?
|
||||
end
|
||||
end
|
||||
else
|
||||
@@ -421,9 +421,9 @@ feature -- Form
|
||||
l_cms_perms.values as ic
|
||||
loop
|
||||
if attached {WSF_STRING} ic.item as p then
|
||||
l_perm := p.value.as_string_8
|
||||
l_perm := p.value
|
||||
if not l_perm.is_whitespace then
|
||||
a_role.add_permission (l_perm)
|
||||
a_role.add_permission (api.utf_8_encoded (l_perm))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -81,10 +81,8 @@ feature -- HTTP Methods
|
||||
l_uid: INTEGER_64
|
||||
edit_response: CMS_ROLE_FORM_RESPONSE
|
||||
view_response: CMS_ROLE_VIEW_RESPONSE
|
||||
r: CMS_RESPONSE
|
||||
do
|
||||
create {FORBIDDEN_ERROR_CMS_RESPONSE} r.make (req, res, api)
|
||||
if r.has_permission ("admin roles") then
|
||||
if api.has_permission ("admin roles") then
|
||||
if req.percent_encoded_path_info.ends_with_general ("/edit") then
|
||||
check valid_url: req.percent_encoded_path_info.starts_with_general (api.administration_path ("/role/")) end
|
||||
create edit_response.make (req, res, api)
|
||||
@@ -111,18 +109,15 @@ feature -- HTTP Methods
|
||||
end
|
||||
end
|
||||
else
|
||||
r.execute
|
||||
send_access_denied (req, res)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
do_post (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
local
|
||||
edit_response: CMS_ROLE_FORM_RESPONSE
|
||||
r: CMS_RESPONSE
|
||||
do
|
||||
create {FORBIDDEN_ERROR_CMS_RESPONSE} r.make (req, res, api)
|
||||
if r.has_permission ("admin roles") then
|
||||
if api.has_permission ("admin roles") then
|
||||
if req.percent_encoded_path_info.ends_with_general ("/edit") then
|
||||
create edit_response.make (req, res, api)
|
||||
edit_response.execute
|
||||
@@ -138,7 +133,7 @@ feature -- HTTP Methods
|
||||
edit_response.execute
|
||||
end
|
||||
else
|
||||
r.execute
|
||||
send_access_denied (req, res)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ feature -- Execution
|
||||
s.append ("<div class=%"info%"> ")
|
||||
s.append ("<h4>Role Information</h4>")
|
||||
s.append ("<p>Role:")
|
||||
s.append (a_role.name)
|
||||
s.append (html_encoded (a_role.name))
|
||||
s.append ("</p>")
|
||||
|
||||
s.append ("<h4>Permissions:</h4>")
|
||||
|
||||
Reference in New Issue
Block a user