Implemented CMS storage for user and nodes.
Implemented role and permission storage.
Introduced the CMS_PARTIAL_NODE and CMS_PARTIAL_USER.
Added support for node storage extension
- storage of data specific to each node content type,
- in addition to the core CMS_NODE)
- For now, only implemented for SQL storage.
Note: in current version, CMS_PAGE support is hard coded in the core,
(as opposed to be only supported by the node module.)
Commented/removed for now, the Web API code to update node summary, title, via REST request.
This commit is contained in:
@@ -17,6 +17,12 @@ create
|
||||
|
||||
feature -- Access
|
||||
|
||||
user_by_id (a_id: like {CMS_USER}.id): detachable CMS_USER
|
||||
-- User by id `a_id', if any.
|
||||
do
|
||||
Result := storage.user_by_id (a_id)
|
||||
end
|
||||
|
||||
user_by_name (a_username: READABLE_STRING_32): detachable CMS_USER
|
||||
-- User by name `a_user_name', if any.
|
||||
do
|
||||
@@ -31,6 +37,65 @@ feature -- Status report
|
||||
Result := storage.is_valid_credential (a_auth_login, a_auth_password)
|
||||
end
|
||||
|
||||
user_has_permission (a_user: detachable CMS_USER; a_permission: detachable READABLE_STRING_GENERAL): BOOLEAN
|
||||
-- Anonymous or user `a_user' has permission for `a_permission'?
|
||||
--| `a_permission' could be for instance "create page".
|
||||
do
|
||||
if a_permission = Void then
|
||||
Result := True
|
||||
elseif a_user = Void then
|
||||
Result := user_role_has_permission (anonymous_user_role, a_permission)
|
||||
else
|
||||
Result := user_role_has_permission (authenticated_user_role, a_permission)
|
||||
if not Result then
|
||||
Result := across user_roles (a_user) as ic some user_role_has_permission (ic.item, a_permission) end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
user_roles (a_user: CMS_USER): LIST [CMS_USER_ROLE]
|
||||
local
|
||||
l_roles: detachable LIST [CMS_USER_ROLE]
|
||||
do
|
||||
l_roles := a_user.roles
|
||||
if l_roles = Void then
|
||||
-- Fill user with its roles.
|
||||
create {ARRAYED_LIST [CMS_USER_ROLE]} l_roles.make (0)
|
||||
l_roles := storage.user_roles_for (a_user)
|
||||
end
|
||||
Result := l_roles
|
||||
end
|
||||
|
||||
feature -- User roles.
|
||||
|
||||
anonymous_user_role: CMS_USER_ROLE
|
||||
do
|
||||
if attached user_role_by_id (1) as l_anonymous then
|
||||
Result := l_anonymous
|
||||
else
|
||||
create Result.make ("anonymous")
|
||||
end
|
||||
end
|
||||
|
||||
authenticated_user_role: CMS_USER_ROLE
|
||||
do
|
||||
if attached user_role_by_id (2) as l_authenticated then
|
||||
Result := l_authenticated
|
||||
else
|
||||
create Result.make ("authenticated")
|
||||
end
|
||||
end
|
||||
|
||||
user_role_has_permission (a_role: CMS_USER_ROLE; a_permission: READABLE_STRING_GENERAL): BOOLEAN
|
||||
do
|
||||
Result := a_role.has_permission (a_permission)
|
||||
end
|
||||
|
||||
user_role_by_id (a_id: like {CMS_USER_ROLE}.id): detachable CMS_USER_ROLE
|
||||
do
|
||||
Result := storage.user_role_by_id (a_id)
|
||||
end
|
||||
|
||||
feature -- Change User
|
||||
|
||||
new_user (a_user: CMS_USER)
|
||||
|
||||
Reference in New Issue
Block a user