找回密码
 注册成为天翎用户
查看: 1779|回复: 5

获取当前登陆用户的角色

[复制链接]
yangxin 发表于 2012-4-16 17:29:40 | 显示全部楼层 |阅读模式
本帖最后由 purple 于 2012-4-18 17:52 编辑

如何获取当前登陆用户的角色
irene 发表于 2012-4-16 17:50:40 | 显示全部楼层
您好,您可以参考这个帖子:http://www.teemlink.com/bbs/view ... hlight=%BD%C7%C9%AB
有问题我们再沟通
回复

使用道具 举报

purple 发表于 2012-4-16 17:53:17 | 显示全部楼层
回复

使用道具 举报

 楼主| yangxin 发表于 2012-6-14 09:14:55 | 显示全部楼层
问题已处理
回复

使用道具 举报

fys 发表于 2012-7-17 10:39:42 | 显示全部楼层
回复 3# purple

输出当前用户在当前程序中所有角色的名称:
var roles=user.getRoles();
var currentApplicationid =getApplication();
var rtn="";

for(var it = roles.iterator();roles!=null && it.hasNext();){
var role = it.next();
if(currentApplicationid.equals(role.getApplicationid())){               
                                rtn+=role.getName()+"|";
  }
}
rtn;


判断当前用户在当前程序中是否拥有某角色的权限:
var roles = user.getRoles();
var rtn=false;
var currentApplicationid =getApplication();
for(var it = roles.iterator();roles!=null && it.hasNext();)
{
var role = it.next();
if(currentApplicationid.equals(role.getApplicationid()))
{               
if(role.getName()=="行政助理" || role.getName()=="管理员")
{
    rtn=true;
}
}
}
rtn;
回复

使用道具 举报

purple 发表于 2012-7-17 17:16:33 | 显示全部楼层
回复 5# fys


    感谢fys的分享。现已将您的分享整理成精华帖,供其他用户参考。具体帖子链接:
1、http://www.teemlink.com/bbs/viewthread.php?tid=162757&extra=
2、http://www.teemlink.com/bbs/view ... &extra=page%3D1
回复

使用道具 举报

本版积分规则

手机版|天翎MyApps技术社区 ( 粤ICP备11093750号 )

GMT+8, 2026-8-13 23:51

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表