public void Add(User user)
 {
     if (this.UserWithUserName(user.TenantId, user.UserName) != null) {
         throw new InvalidOperationException("User is not unique.");
     }
     _session.Save(user);
 }
예제 #2
0
        public virtual void AssignUser(User user)
        {
            AssertionConcern.NotNull(user, "User must not be null.");
            AssertionConcern.Equals(this.TenantId, user.TenantId, "Wrong tenant for this user.");

            this.Group.AddUser(user);

            DomainEventPublisher.Instance.Publish(new UserAssignedToRole(this.TenantId, this.Name, user.UserName,
                user.Person.Name, user.Person.EmailAddress));
        }
 public bool IsUserInNestedGroup(Group group, User user)
 {
     foreach(GroupMember member in group.GroupMembers.Where(m=>m.IsGroup)) {
         Group nestedGroup = _groupRepository.GroupNamed(member.TenantId, member.Name);
         if(nestedGroup!=null) {
             bool isInNestedGroup = nestedGroup.IsMember(user, this);
             if(isInNestedGroup) {
                 return true;
             }
         }
     }
     return false;
 }
        public bool IsUserInRole(User user, string roleName)
        {
            AssertionConcern.NotNull(user, "User must not be null.");
            AssertionConcern.NotEmpty(roleName, "Role name must not be null.");

            bool authorized = false;
            if (user.IsEnabled) {
                Role role = _roleRepository.RoleNamed(user.TenantId, roleName);
                if (role != null) {
                    authorized = role.IsInRole(user, new GroupMemberService(_userRepository, _groupRepository));
                }
            }

            return authorized;
        }
예제 #5
0
 public virtual bool IsInRole(User user, GroupMemberService groupMemberService)
 {
     return this.Group.IsMember(user, groupMemberService);
 }
예제 #6
0
        public virtual void UnassignUser(User user)
        {
            AssertionConcern.NotNull(user, "User must not be null.");
            AssertionConcern.Equals(this.TenantId, user.TenantId, "Wrong tenant for this user.");

            this.Group.RemoveUser(user);

            DomainEventPublisher.Instance.Publish(new UserUnassignedFromRole(this.TenantId, this.Name, user.UserName));
        }
 public void Remove(User user)
 {
     _session.Delete(user);
 }
 public bool ConfirmUser(Group group, User user)
 {
     User confirmedUser = _userRepository.UserWithUserName(group.TenantId, user.UserName);
     return confirmedUser != null && confirmedUser.IsEnabled;
 }