Added CMS_MODULE.permissions to allow module to declare the potential permissions. Added support for CMS_LINK.is_forbidden, in relation with CMS_LOCAL_LINK.permission_arguments. Split link "username (Logout)" into 2 links "username" and "logout". Fixed/Changed the way auth modules alter the logout link based on "(Logout)" title, by safer solution based on `location' of the link. Fixed usage of WSF_REQUEST.path_info by using percent_encoded_path_info which is not non unicode path info to be used most of the time. Merged CMS_REPONSE.variables and CMS_REPONSE.values . When possible, prefer usage of CMS_RESPONSE.user instead of CMS_REQUEST_UTIL.current_user (WSF_REQUEST) whenever it is possible. When possible, prefer usage of CMS_RESPONSE.location, rather than usage of WSF_REQUEST.(percent_encoded_)path_info . Code cleaning.
78 lines
2.1 KiB
Plaintext
78 lines
2.1 KiB
Plaintext
note
|
|
description: "Set of helper features related to CMS Request needs."
|
|
date: "$Date: 2015-02-13 13:08:13 +0100 (ven., 13 févr. 2015) $"
|
|
revision: "$Revision: 96616 $"
|
|
|
|
deferred class
|
|
CMS_REQUEST_UTIL
|
|
|
|
inherit
|
|
CMS_ENCODERS
|
|
|
|
REFACTORING_HELPER
|
|
|
|
feature -- User
|
|
|
|
current_user_name (req: WSF_REQUEST): detachable READABLE_STRING_32
|
|
-- Current user name or Void in case of Guest users.
|
|
note
|
|
EIS: "src=eiffel:?class=AUTHENTICATION_FILTER&feature=execute"
|
|
do
|
|
if attached {CMS_USER} current_user (req) as l_user then
|
|
Result := l_user.name
|
|
end
|
|
end
|
|
|
|
current_user (req: WSF_REQUEST): detachable CMS_USER
|
|
-- Current user or Void in case of Guest user.
|
|
-- note: if a CMS_RESPONSE is available, always prefer {CMS_RESPONSE}.user if relevant.
|
|
note
|
|
EIS: "eiffel:?class=AUTHENTICATION_FILTER&feature=execute"
|
|
do
|
|
if attached {CMS_USER} req.execution_variable (current_user_execution_variable_name) as l_user then
|
|
Result := l_user
|
|
end
|
|
end
|
|
|
|
feature -- Change
|
|
|
|
set_current_user (req: WSF_REQUEST; a_user: detachable CMS_USER)
|
|
-- Set `a_user' as `current_user'.
|
|
do
|
|
if a_user = Void then
|
|
req.unset_execution_variable (current_user_execution_variable_name)
|
|
else
|
|
req.set_execution_variable (current_user_execution_variable_name, a_user)
|
|
end
|
|
ensure
|
|
user_set: current_user (req) ~ a_user
|
|
end
|
|
|
|
unset_current_user (req: WSF_REQUEST)
|
|
-- Unset current user.
|
|
do
|
|
req.unset_execution_variable (current_user_execution_variable_name)
|
|
ensure
|
|
user_unset: current_user (req) = Void
|
|
end
|
|
|
|
feature {NONE} -- Implementation: current user
|
|
|
|
current_user_execution_variable_name: STRING = "_cms_active_user_"
|
|
-- Execution variable name used to keep current user data.
|
|
|
|
feature -- Media Type
|
|
|
|
current_media_type (req: WSF_REQUEST): detachable READABLE_STRING_32
|
|
-- Current media type or Void if it's not acceptable.
|
|
do
|
|
if attached {STRING} req.execution_variable ("media_type") as l_type then
|
|
Result := l_type
|
|
end
|
|
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
|