Exemple #1
0
        private System.Security.Claims.ClaimsIdentity CreateIdentity(AuthorityUserInfo user, string authenticationType,AuthorityUserInObjectInfo userRoleInfo)
        {
            string uid = "", roleid = "", orgid = "";

            if (userRoleInfo==null)
            {
                uid = user.Id.ToString();
                roleid = user.RoleId.ToString();
                orgid = user.OrgId.ToString();
            }
            else
            {
                uid = userRoleInfo.UserId.ToString();
                roleid = userRoleInfo.ObjectId.ToString();
                orgid = userRoleInfo.OrgId.ToString();
            }
           
            var identity = new ClaimsIdentity(authenticationType, YLClaimTypes.UserNameClaimType, YLClaimTypes.RoleClaimType);

            identity.AddClaim(new Claim(YLClaimTypes.UserIdClaimType, uid, "http://www.w3.org/2001/XMLSchema#string"));
            identity.AddClaim(new Claim(YLClaimTypes.OrgIdClaimType, orgid, "http://www.w3.org/2001/XMLSchema#string"));
            identity.AddClaim(new Claim(YLClaimTypes.RoleClaimType, roleid, "http://www.w3.org/2001/XMLSchema#string"));
            //identity.AddClaim(new Claim(AbpClaimTypes.TenantId, user.TenantId.ToString(), "http://www.w3.org/2001/XMLSchema#string"));
            return identity;
        }
 /// <summary>
 /// Check whether a user is granted for a permission.
 /// </summary>
 /// <param name="user">User</param>
 /// <param name="permission">Permission</param>
 public virtual async Task<bool> IsGrantedAsync(AuthorityUserInfo user, Permission permission)
 {
    
     return false;
 }
Exemple #3
0
        private System.Security.Claims.ClaimsIdentity CreateIdentity(AuthorityUserInfo user, string authenticationType)
        {
            //var roleids = user.UserRoles.Select(x=>x.RoleCode).JoinAsString(",");
            var identity = new ClaimsIdentity(authenticationType, YLClaimTypes.UserNameClaimType, YLClaimTypes.RoleClaimType);

            identity.AddClaim(new Claim(YLClaimTypes.UserIdClaimType, user.Id.ToString(), "http://www.w3.org/2001/XMLSchema#string"));
            identity.AddClaim(new Claim(YLClaimTypes.UserNameClaimType, user.UserName, "http://www.w3.org/2001/XMLSchema#string"));
            identity.AddClaim(new Claim(YLClaimTypes.RoleClaimType, user.RoleId.ToString(), "http://www.w3.org/2001/XMLSchema#string"));
            //identity.AddClaim(new Claim(AbpClaimTypes.TenantId, user.TenantId.ToString(), "http://www.w3.org/2001/XMLSchema#string"));
            return identity;
        }
        private  LoginResultDto CreateLoginResult(AuthorityUserInfo user)
        {
            if (!user.IsEnable)
            {
                return new LoginResultDto(LoginResultType.UserIsNotActive);
            }

         
            user.LastVisit = Clock.Now;

           // await Store.UpdateAsync(user);修改用户表

           // await _unitOfWorkManager.Current.SaveChangesAsync();
            UserListDto users = user.MapTo<UserListDto>();
            return new LoginResultDto(users, CreateIdentity(users, DefaultAuthenticationTypes.ApplicationCookie));
           
        }