Added CMS_WEBAPI_HANDLER.new_permissions_access_denied_error_response (..) to provide the required permissions.

This commit is contained in:
Jocelyn Fiat
2017-10-17 13:45:32 +02:00
parent be258c73e9
commit 60fbba5a70
2 changed files with 25 additions and 1 deletions

View File

@@ -105,7 +105,7 @@ feature -- Execution
rep := new_access_denied_error_response ("There were issue with your application, invalid or missing values.", req, res)
end
else
rep := new_access_denied_error_response ("You can also contact the webmaster to ask for an account.", req, res)
rep := new_permissions_access_denied_error_response (<<"account register">>, "You can also contact the webmaster to ask for an account.", req, res)
end
rep.execute
end

View File

@@ -60,6 +60,30 @@ feature -- Factory
Result.set_status_code ({HTTP_STATUS_CODE}.not_found)
end
new_permissions_access_denied_error_response (perms: ITERABLE [READABLE_STRING_GENERAL]; a_mesg: detachable READABLE_STRING_GENERAL; req: WSF_REQUEST; res: WSF_RESPONSE): like new_response
local
m: STRING_32
n: INTEGER
do
if a_mesg /= Void then
create m.make_from_string_general (a_mesg)
m.append_character ('%N')
else
create m.make (20)
end
m.append_string_general ("Permissions: ")
n := m.count
across
perms as ic
loop
if m.count > n then
m.append (",")
end
m.append_string_general (ic.item)
end
Result := new_access_denied_error_response (m, req, res)
end
new_access_denied_error_response (m: detachable READABLE_STRING_GENERAL; req: WSF_REQUEST; res: WSF_RESPONSE): like new_response
do
if m = Void then