Example #1
0
        private void InvokeOnRemoveUser(User user)
        {
            var eventArgs = new UserEventArgs(user);

            if (_onRemoveUser != null)
                try
                {
                    _onRemoveUser(this, eventArgs);
                }catch(Exception e)
                {
                    DataBaseManager.Logger.Log(String.Format("InvokeOnRemoveUser fail - {0}", e.Message));
                }
        }
Example #2
0
        private void InvokeOnUserChangePassword(User user, string passwordPlainText)
        {
            var eventArgs = new UserEventArgs(user);

            if (_onUserChangePassword != null)
                try
                {
                    _onUserChangePassword(this, eventArgs);
                }
                catch (Exception e)
                {
                    DataBaseManager.Logger.Log(String.Format("InvokeOnUserChangePassword fail - {0}", e.Message));
                }
        }
Example #3
0
        private void InheritedEnrollParents(User user, Container container, RoleType roleType)
        {
            var current = container;

            while (current != null){
                if (!PermissionToEnroll(current, roleType, RoleBarrier.Bottom))
                    return;

                EnrollInherited(user, current, roleType);

                current = current.Parent;
            }
        }
Example #4
0
 public UserEventArgs(User user, string passwordPlainText)
     : this(user)
 {
     PasswordPlainText = passwordPlainText;
 }
Example #5
0
 public UserEventArgs(User user)
 {
     User = user;
 }
Example #6
0
        private void InheritedEnrollChilds(User user, Container container, RoleType roleType)
        {
            foreach (var child in container.Childs)
            {
                if (!PermissionToEnroll(child, roleType, RoleBarrier.Top))
                    continue;

                EnrollInherited(user, child, roleType);

                InheritedEnrollChilds(user, child, roleType);
            }
        }
Example #7
0
        private bool InheritedDisenroll(User user, Container container, RoleType roleType)
        {
            var enroll = _db.DbContext.Enrolls.Find(user.Name, container.Id, roleType.Name, container.Type.StructureId);

            if (enroll == null)
                return false;

            enroll.InheritedCount -= 1;

            if (enroll.InheritedCount == 0)
                if (enroll.Inherited)
                {
                    _db.DbContext.Enrolls.Remove(enroll);

                    InvokeOnDisenrollUser(enroll, container);
                }

            return true;
        }
Example #8
0
        private bool EnrollInherited(User user, Container container, RoleType roleType)
        {
            var enroll = _db.DbContext.Enrolls.Find(user.Name, container.Id, roleType.Name, container.Type.StructureId);

            if (enroll != null)
            {
                enroll.InheritedCount += 1;

                return true;
            }

            enroll = new Enroll()
            {
                User = user,
                Container = container,
                RoleType = roleType,
                Inherited = true,
                InheritedCount = 1
            };

            _db.DbContext.Enrolls.Add(enroll);

            InvokeOnEnrollUser(enroll);

            return true;
        }
Example #9
0
        public User Create(string name, string password, string email)
        {
            var user = new User
            {
                Name = name,
                Credential = AuthenticationManager.EncryptPassword(password),
                Email = email
            };
            _db.DbContext.Users.Add(user);
            _db.DbContext.SaveChanges();

            InvokeOnCreateUser(user, password);

            return user;
        }