public static bool IsRole(IdentityUserRole userRole, RoleId roleId) { if (userRole.RoleId == null) return false; var currRole = (RoleId) Enum.Parse(typeof(RoleId), userRole.RoleId); if (currRole == roleId) return true; return true; }
public static RoleLists GetMSNList(RoleId memberRole) { switch (memberRole) { case RoleId.Allow: return(RoleLists.Allow); case RoleId.Pending: return(RoleLists.Pending); case RoleId.Hide: return(RoleLists.Hide); } return(RoleLists.None); }
//当使用Authorize特性时,会调用改方法验证角色 public virtual bool IsInRole(string role) { try { if (string.IsNullOrWhiteSpace(role)) { return(true); } return(RoleId.Contains(Guid.Parse(role))); } catch (Exception) { return(true); } }
public async Task <IEnumerable <PermissionOverrideDto> > HandleAsync(GetChannelRolePermissionOverridesQuery query) { return(await _context.Channels .AsNoTracking() .Where(x => x.GroupId == GroupId.From(query.GroupId)) .Where(x => x.Id == ChannelId.From(query.ChannelId)) .SelectMany(x => x.RolePermissionOverrides) .Where(x => x.RoleId == RoleId.From(query.RoleId)) .Select( x => new PermissionOverrideDto { Permission = x.Permission.Name, Type = x.Type == OverrideType.Allow ? OverrideTypeDto.Allow : OverrideTypeDto.Deny } ).ToListAsync()); }
public static bool IsRole(IdentityUserRole userRole, RoleId roleId) { if (userRole.RoleId == null) { return(false); } var currRole = (RoleId)Enum.Parse(typeof(RoleId), userRole.RoleId); if (currRole == roleId) { return(true); } return(true); }
public bool Equals(RoleModulePermissionModel rmpm) { //Check whether the compared object is null. if (Object.ReferenceEquals(rmpm, null)) { return(false); } //Check whether the compared object references the same data. if (Object.ReferenceEquals(this, rmpm)) { return(true); } //Check whether the objects properties are equal. return(RoleId.Equals(rmpm.RoleId) && ModuleId.Equals(rmpm.ModuleId) && PermissionId.Equals(rmpm.PermissionId)); }
public override int GetHashCode() { int hash = 1; if (RoleId != 0L) { hash ^= RoleId.GetHashCode(); } if (Name.Length != 0) { hash ^= Name.GetHashCode(); } if (UserId != 0L) { hash ^= UserId.GetHashCode(); } if (ServerId != 0) { hash ^= ServerId.GetHashCode(); } if (ServerName.Length != 0) { hash ^= ServerName.GetHashCode(); } if (Type != 0) { hash ^= Type.GetHashCode(); } if (Level != 0) { hash ^= Level.GetHashCode(); } if (Sex != 0) { hash ^= Sex.GetHashCode(); } if (HeadImgId != 0) { hash ^= HeadImgId.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public void DeleteRole(UserId responsibleUserId, RoleId roleId) { _unitOfWork.WithAuthUserTransaction(tran => { var role = FindRole(roleId); long nrOfUsersWithRole = _authUserRepository.Count(new UsersWithRoleSpecification(roleId)); if (nrOfUsersWithRole > 0) { throw new ManualValidationException("You cannot delete roles with users assigned."); } _roleRepository.Delete(roleId); _unitOfWork.Raise(RoleDeleted.Factory(role, responsibleUserId)); tran.Commit(); }); }
public override int GetHashCode() { unchecked { var hashCode = (VaultUri != null ? VaultUri.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (int)AuthenticationType; hashCode = (hashCode * 397) ^ (RoleId != null ? RoleId.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (SecretId != null ? SecretId.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Username != null ? Username.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Password != null ? Password.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Token != null ? Token.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (int)SecretsEngine; hashCode = (hashCode * 397) ^ (SecretsEnginePath != null ? SecretsEnginePath.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (DataPath != null ? DataPath.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Namespace != null ? Namespace.GetHashCode() : 0); return(hashCode); } }
public void RemoveRole(UserId responsibleUserId, RoleId roleId, UserId userId) { _unitOfWork.WithAuthUserTransaction(tran => { var role = FindRole(roleId); var authUser = _authUserRepository.FindByIdOrNull(userId); if (authUser is null) { throw new ManualValidationException("User not found"); } _userRoleDomainService.RemoveRole(authUser, role); _authUserRepository.Save(authUser); _unitOfWork.Raise(UserLostRole.Factory(role, authUser, responsibleUserId)); tran.Commit(); }); }
public void AssignRole(UserId responsibleUserId, RoleId roleId, Username username) { _unitOfWork.WithAuthUserTransaction(tran => { var role = FindRole(roleId); var authUser = _authUserRepository.FindOrNull(new UsernameSpecification(username)); if (authUser is null) { throw new ManualValidationException("User not found"); } _userRoleDomainService.AssignRole(authUser, role); _authUserRepository.Save(authUser); _unitOfWork.Raise(UserGainedRole.Factory(role, authUser, responsibleUserId)); tran.Commit(); }); }
public override int GetHashCode() { int hash = 1; if (RoleId != 0) { hash ^= RoleId.GetHashCode(); } if (PitchOn != false) { hash ^= PitchOn.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public async Task <IEnumerable <PermissionDto> > HandleAsync(GetRolePermissionsQuery query) { var permissions = await _context.Groups.AsNoTracking() .Where(x => x.Id == GroupId.From(query.GroupId)) .SelectMany(x => x.Roles) .Where(x => x.Id == RoleId.From(query.RoleId)) .Select(x => x.Permissions) .ToListAsync(); if (permissions.Count == 0) { return(new List <PermissionDto>()); } var permission = permissions[0]; return(permission.ToListOfPermissions() .Select(x => new PermissionDto(x.Name, x.Value)) .ToList()); }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { // credit: http://stackoverflow.com/a/263416/677735 unchecked // Overflow is fine, just wrap { int hash = 41; // Suitable nullity checks hash = hash * 59 + RoleId.GetHashCode(); hash = hash * 59 + PermissionId.GetHashCode(); if (Id != null) { hash = hash * 59 + Id.GetHashCode(); } return(hash); } }
private void LoadData() { LoadComboBox(); // Verificar si el usuario tiene permisos asignados OperationResult objSecurityOperationResult1 = new OperationResult(); if (Mode == "New") { hfMode.Text = "New"; } else if (Mode == "Edit") { ddlRole.SelectedValue = RoleId.ToString(); ddlRole.Enabled = false; var filterExpression = string.Format("i_NodeId=={0}&&i_RoleId=={1}&&i_IsDeleted==0", NodeId, RoleId); int count1 = _objNodeBL.GetRoleNodeProfileCount(ref objSecurityOperationResult1, filterExpression); if (count1 == 0) { // Additional logic here. hfMode.Text = "New"; } else { hfMode.Text = "Edit"; // Cargar permisos Globales OperationResult objCommonOperationResultGlobal = new OperationResult(); var objRoleNodeProfile = _objNodeBL.GetRoleNodeProfile(ref objCommonOperationResultGlobal, NodeId, RoleId); if (objRoleNodeProfile != null) { // Marcar (CkeckBox) los permisos en el Tree Contextual foreach (var item in objRoleNodeProfile) { SearchNode(tvContextPermissions.Nodes, int.Parse(item.Id), true); } } } } }
public async Task <ClaimsIdentity> GenerateUserIdentityAsync(UserManager <ApplicationUser> manager) { // Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie); // Add custom user claims here userIdentity.AddClaim(new Claim(ClaimTypeCustomize.UserRole, RoleId.ToString())); userIdentity.AddClaim(new Claim(ClaimTypeCustomize.RoleName, RoleName ?? "")); userIdentity.AddClaim(new Claim(ClaimTypeCustomize.LastLoginDate, LastLoginDate != null ? LastLoginDate.ToString() : "")); userIdentity.AddClaim(new Claim(ClaimTypeCustomize.Email, Email != null ? Email.ToString() : "")); userIdentity.AddClaim(new Claim(ClaimTypeCustomize.LastName, LastName ?? "")); userIdentity.AddClaim(new Claim(ClaimTypeCustomize.FirstName, FirstName ?? "")); userIdentity.AddClaim(new Claim(ClaimTypeCustomize.FullName, FullName ?? "")); userIdentity.AddClaim(new Claim(ClaimTypeCustomize.InstitutionId, InstitutionId.ToString())); userIdentity.AddClaim(new Claim(ClaimTypeCustomize.InstitutionName, InstitutionName ?? "")); userIdentity.AddClaim(new Claim(ClaimTypeCustomize.DeptCode, DeptCode ?? "")); userIdentity.AddClaim(new Claim(ClaimTypeCustomize.DeptName, DeptName ?? "")); userIdentity.AddClaim(new Claim(ClaimTypeCustomize.AppKey, AppKey ?? "")); return(userIdentity); }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (Id != null) { hashCode = hashCode * 59 + Id.GetHashCode(); } if (Name != null) { hashCode = hashCode * 59 + Name.GetHashCode(); } if (ContractTypeName != null) { hashCode = hashCode * 59 + ContractTypeName.GetHashCode(); } if (RoleId != null) { hashCode = hashCode * 59 + RoleId.GetHashCode(); } if (RoleName != null) { hashCode = hashCode * 59 + RoleName.GetHashCode(); } if (RoleDescription != null) { hashCode = hashCode * 59 + RoleDescription.GetHashCode(); } if (HourlySalary != null) { hashCode = hashCode * 59 + HourlySalary.GetHashCode(); } if (MonthlySalary != null) { hashCode = hashCode * 59 + MonthlySalary.GetHashCode(); } return(hashCode); } }
/// <summary> /// Returns true if Authorization instances are equal /// </summary> /// <param name="other">Instance of Authorization to be compared</param> /// <returns>Boolean</returns> public bool Equals(Authorization other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Id == other.Id || Id != null && Id.Equals(other.Id) ) && ( ResourceId == other.ResourceId || ResourceId != null && ResourceId.Equals(other.ResourceId) ) && ( RoleId == other.RoleId || RoleId != null && RoleId.Equals(other.RoleId) ) && ( PolicyId == other.PolicyId || PolicyId != null && PolicyId.Equals(other.PolicyId) ) && ( ScopeMap == other.ScopeMap || ScopeMap != null && ScopeMap.Equals(other.ScopeMap) )); }
public override int GetHashCode() { int hash = 1; if (Id != 0) { hash ^= Id.GetHashCode(); } if (Content.Length != 0) { hash ^= Content.GetHashCode(); } if (RoleId != 0) { hash ^= RoleId.GetHashCode(); } hash ^= select_.GetHashCode(); if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public override int GetHashCode() { int hash = 1; if (RoleId != 0) { hash ^= RoleId.GetHashCode(); } if (PitchOn != false) { hash ^= PitchOn.GetHashCode(); } hash ^= choiceId_.GetHashCode(); if (ChoiceList.Length != 0) { hash ^= ChoiceList.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public int CompareTo(UserBO other) { if (ReferenceEquals(this, other)) { return(0); } if (ReferenceEquals(null, other)) { return(1); } var idComparison = Id.CompareTo(other.Id); if (idComparison != 0) { return(idComparison); } var usernameComparison = string.Compare(Username, other.Username, StringComparison.Ordinal); if (usernameComparison != 0) { return(usernameComparison); } var passwordComparison = string.Compare(Password, other.Password, StringComparison.Ordinal); if (passwordComparison != 0) { return(passwordComparison); } var roleIdComparison = RoleId.CompareTo(other.RoleId); if (roleIdComparison != 0) { return(roleIdComparison); } return(Comparer <RoleBO> .Default.Compare(Role, other.Role)); }
void When(AddedRole @event) { Id = new RoleId(@event.RoleId); _permissions = new List<RolePermission>(); _archived = false; }
protected bool Equals(DUserRole other) { return(UserId.Equals(other.UserId) && RoleId.Equals(other.RoleId)); }
public override string ToString() { return ($"RiftTempRole: {nameof(UserId)}: {UserId.ToString()}, {nameof(RoleId)}: {RoleId.ToString()}, {nameof(ExpirationTime)}: {ExpirationTime.Humanize()}"); }
public override int GetHashCode() { return(UserId.GetHashCode() * 37 + RoleId.GetHashCode()); }
public AuthFilter(RoleId role = RoleId.User) { this.role = role; }
public static string MapRoleName(RoleId role) { AP1Entities e = new AP1Entities(); RoleMapper result = e.Roles.Where(r => r.CategoryId == role.Category && r.BandaraId == role.Bandara && r.TerminalId == role.Terminal && r.SubTerminalId == role.SubTerminal && r.Role == role.Role).FirstOrDefault(); if (result == null) return GUEST; return result.Name; }
public void GivenIHaveVisitorRole() { _roleId = new RoleId("visitor"); }
public override int GetHashCode() { return((ActivityId.ToString() + "|" + RoleId.ToString()).GetHashCode()); }
public static string GetRoleName(RoleId roleId) { return(Enum.GetName(typeof(RoleId), roleId)); }
public static string GetRoleId(RoleId roleid) { var roleAsInt = (int) roleid; var roleIdStr = roleAsInt.ToString("D"); return roleIdStr; }
internal void RemoveMemberhip(ServiceName servicetype, string account, IMAddressInfoType type, RoleId memberrole) { lock (SyncObject) { SerializableDictionary<RoleId, SerializableDictionary<string, BaseMember>> ms = SelectTargetMemberships(servicetype); if (ms != null && ms.ContainsKey(memberrole)) { string hash = Contact.MakeHash(account, type); if (ms[memberrole].ContainsKey(hash)) { ms[memberrole].Remove(hash); } } } }
public static string GetRoleName(RoleId roleId) { return Enum.GetName(typeof(RoleId), roleId); }
internal void SetFriendshipStatus(RoleId fs, bool fireEvent) { if (friendshipStatus != fs) { RoleId oldFs = friendshipStatus; friendshipStatus = fs; if (fireEvent) { OnFriendshipStatusChanged(new FriendshipStatusChangedEventArgs(this, oldFs, fs)); } } }
// Behavior public Role(RoleId roleId, Name name) : this() { Apply( new AddedRole(roleId, name)); }
public virtual void Validate(ValidationResult result) { RoleId.ValidateRequired(result, nameof(RoleId)); UserId.ValidateRequired(result, nameof(UserId)); }
private bool HasMemberhip(ServiceName servicetype, string account, IMAddressInfoType type, RoleId memberrole) { SerializableDictionary<RoleId, SerializableDictionary<string, BaseMember>> ms = SelectTargetMemberships(servicetype); return (ms != null) && ms.ContainsKey(memberrole) && ms[memberrole].ContainsKey(Contact.MakeHash(account, type)); }
/// <summary> /// 删除 /// </summary> /// <param name="RoleId">角色ID</param> /// <returns></returns> public bool Delete(int CompanyId, params int[] RoleId) { dcDal = new EyouSoft.Data.EyouSoftTBL(this._db.ConnectionString); bool IsTrue = false; IEnumerable <EyouSoft.Data.SysRoleManage> SysRoleLists = (from item in dcDal.SysRoleManage where item.CompanyId == CompanyId && RoleId.Contains(item.Id) select item); dcDal.SysRoleManage.DeleteAllOnSubmit <EyouSoft.Data.SysRoleManage>(SysRoleLists); dcDal.SubmitChanges(); IsTrue = true; SysRoleLists = null; return(IsTrue); }
/// <summary> /// Get a basemember from membership list. /// </summary> /// <param name="servicetype"></param> /// <param name="account"></param> /// <param name="type"></param> /// <param name="memberrole"></param> /// <returns>If the member not exist, return null.</returns> public BaseMember SelectBaseMember(ServiceName servicetype, string account, IMAddressInfoType type, RoleId memberrole) { SerializableDictionary<RoleId, SerializableDictionary<string, BaseMember>> ms = SelectTargetMemberships(servicetype); if ((ms != null) && ms.ContainsKey(memberrole)) { string hash = Contact.MakeHash(account, type); if (ms[memberrole].ContainsKey(hash)) return ms[memberrole][hash]; } return null; }
public void GivenIHaveSysAdminRole() { _roleId = new RoleId("sysadmin"); }
/// <summary> /// Add a member to the underlying membership data structure. /// </summary> /// <param name="servicetype"></param> /// <param name="account"></param> /// <param name="type"></param> /// <param name="memberrole"></param> /// <param name="member"></param> internal void AddMemberhip(ServiceName servicetype, string account, IMAddressInfoType type, RoleId memberrole, BaseMember member) { lock (SyncObject) { SerializableDictionary<RoleId, SerializableDictionary<string, BaseMember>> ms = SelectTargetMemberships(servicetype); if (ms != null) { if (!ms.ContainsKey(memberrole)) ms.Add(memberrole, new SerializableDictionary<string, BaseMember>(0)); ms[memberrole][Contact.MakeHash(account, type)] = member; } } }