Exemplo n.º 1
0
 public ApiResponse <SessionUser> Login(string userName, string passWord, int sysId, string ip)
 {
     Core.Model.BUser user = ValidateLogonUser(userName, passWord);
     if (user != null)
     {
         Core.Model.BRole role = GetRoleByUserId(user.USR_ID);
         if (role == null)
         {
             return(new ApiResponse <SessionUser> {
                 Success = false, Message = "当前登陆账户未分配角色权限!"
             });
         }
         //判断当前角色的权限数量
         List <Core.Model.BPermission> pmses = GetPermissionsBySysId(role.ROL_ID, sysId);
         if (pmses.Count() == 0)
         {
             return(new ApiResponse <SessionUser> {
                 Success = false, Message = "您无权登录本系统,请联系系统管理员!"
             });
         }
         LogOn(user.USR_ID, userName, ip);
         return(new ApiResponse <SessionUser>(true, "", new SessionUser()
         {
             UserId = user.USR_ID, LoginName = userName, UserRole = new UserRole()
             {
                 ID = role.ROL_ID, Name = role.ROL_DESC, Permissions = pmses
             }
         }));
     }
     return(new ApiResponse <SessionUser> {
         Success = false, Message = "用户名或密码错误,或当前用户为无效状态!"
     });
 }
Exemplo n.º 2
0
        public SessionUser GetUserData(long userid, int sysId)
        {
            BUser user = _usr.Get(Convert.ToInt32(userid));

            Core.Model.BRole role = GetRoleByUserId(user.USR_ID);
            List <Core.Model.BPermission> pmses = GetPermissionsBySysId(role.ROL_ID, sysId);

            return(new SessionUser()
            {
                UserId = user.USR_ID, LoginName = user.USR_LOGINNAME, UserRole = new UserRole()
                {
                    ID = role.ROL_ID, Name = role.ROL_DESC, Permissions = pmses
                }
            });
        }