我想专门定制Surf Platform Root-Scoped API用户对象。这意味着向用户对象添加新属性或方法以检查用户是否在header.inc.ftl
[in share] 中的某个组中,例如 `<#if user.isAdmin>
- 我该如何实施?
- Alfresco Root Scoped Objects可以用作 Surf Platform Root-Scoped 对象吗?
我不知道自定义冲浪平台根对象。谁能帮我???
我想专门定制Surf Platform Root-Scoped API用户对象。这意味着向用户对象添加新属性或方法以检查用户是否在header.inc.ftl
[in share] 中的某个组中,例如 `<#if user.isAdmin>
我不知道自定义冲浪平台根对象。谁能帮我???
Not quite sure what you are trying to accomplish, but the role security model is hardcoded in spring-surf/spring webscripts. There is guest, user and admin. If what you want is another analogous role you'll have to hack the spring-surf libaries, namely:
org/springframework/extensions/surf/mvc/PageView.java
org/springframework/extensions/webscripts/ScriptUser.java
org/springframework/extensions/webscripts/Description.java
org/springframework/extensions/webscripts/connector/User.java
This is what I had to do to implement user.isEmployee
. This approach allows you to literally treat your new role just as the others.
you can use
<authentication>employee</authentication>
in page descriptors or
<item type="link" permission="employee" id="people">/people-finder</item>
on the navigation.
Just checking whether the user is in a certain group in a certain webscript is a whole diffrent story and does not provide the same functionality.
If what you want is the latter, you should make a call to
/alfresco/service/api/groups/{shortName}
miss and works through the response.
Update: The item permission attribute requires a little more tweaking.
In header.get.js
, propagate the new role to it gets processed properly in header.inc.ftl
:
model.permissions =
{
guest: user.isGuest,
admin: user.isAdmin,
employee : user.isEmployee
};
你可以试试(在JavaScript中我管理过类似的东西):
user = Application.getCurrentUser(context);
String userName = user.getUserName();
user.isAdmin() >>> result return true if user logining is admin
或在 JSP 中:
#{NavigationBean.currentUser.admin == true}
抱歉,我现在注意到您在谈论 Surf Platform 根对象,但是您放在那里的链接对于 3.3 以上的 Alfresco 版本已弃用。你还在用这么老的东西?如果您设法使用 JavaScript API,您可以使用带有布尔 isAdmin() 的“人”根对象。