示例#1
0
        internal async Task Load()
        {
            UserPermissions = await _membershipRepository.LoadUserPermissions();

            if (UserPermissions == null)
            {
                return;
            }

            // All users should be able to see these parts of the app
            UserPermissions.Add(new Permission {
                ResourceName = "/api/settings"
            });
            UserPermissions.Add(new Permission {
                ResourceName = "/api/about"
            });

            // Load data required for other parts of the app
            foreach (var permission in UserPermissions)
            {
                await LoadData(permission);
            }

            OnLoadCompleted();
        }
示例#2
0
        public User(string firstName, string lastName, string email, string password, List <Guid> permissions)
        {
            //if (permissions == null || permissions.Count == 0)
            //{
            //    throw new Exception("User should have at least one permission");
            //}
            FirstName = firstName;
            LastName  = lastName;
            Email     = email;
            byte[] passwordHash;
            byte[] passwordSalt;

            Common.Identity.Authentication.CreatePasswordHash(password, out passwordHash, out passwordSalt);

            this.PasswordHash = passwordHash;
            this.PasswordSalt = passwordSalt;


            if (permissions != null)
            {
                permissions.ForEach(a =>
                {
                    if (UserPermissions == null)
                    {
                        UserPermissions = new List <UserPermission>();
                    }
                    UserPermissions.Add(new UserPermission(this.Id, a));
                });
            }
        }
示例#3
0
 private void EditPermissions(List <Guid> permissions, bool deleteExisting = false)
 {
     if (deleteExisting)
     {
         this.UserPermissions.Clear();
     }
     if (permissions != null)
     {
         permissions.ForEach(a =>
         {
             if (UserPermissions == null)
             {
                 UserPermissions = new List <UserPermission>();
             }
             UserPermissions.Add(new UserPermission(this.Id, a));
         });
     }
 }
示例#4
0
        public UserPermissions UserPermissions(UserRight userRight)
        {
            UserPermissions userPermissions = new UserPermissions(null);

            try
            {
                string query = $"select * from dsto_userpermission where yref_userRight = '{userRight.OID}' and Deleted=0";
                var    table = DbInfo.ExecuteSelectQuery(query);
                if (table.Rows.Count > 0)
                {
                    foreach (DataRow row in table.Rows)
                    {
                        UserPermission userPermission = userPermissions.Add();
                        InitUserPermission(userPermission, row);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(userPermissions);
        }
示例#5
0
        public void FromJson(JsonValue source)
        {
            var j = source as JsonObject;

            ID = j.GetIntOrDefault(nameof(ID));
            StructuralUnitID = j.GetIntOrDefault(nameof(StructuralUnitID));
            PersonID         = j.GetIntOrDefault(nameof(PersonID));
            AccessLevelID    = j.GetIntOrDefault(nameof(AccessLevelID));
            DomainName       = j.GetStringOrDefault(nameof(DomainName));
            Name             = j.GetStringOrDefault(nameof(Name));
            PasswordHash     = j.GetStringOrDefault(nameof(PasswordHash));
            SessionToken     = j.GetStringOrDefault(nameof(SessionToken));

            if (j.TryGetValue("UserLogins", out JsonArray a))
            {
                foreach (JsonObject obj in a)
                {
                    UserLogins.Add(new UserLogin(obj));
                }
            }

            if (j.TryGetValue("Roles", out a))
            {
                foreach (string role in a)
                {
                    Roles.Add(role);
                }
            }

            if (j.TryGetValue("UserPermissions", out a))
            {
                foreach (JsonObject obj in a)
                {
                    UserPermissions.Add(new Permission(obj));
                }
            }
        }
        public void LoadPermissions(string FacID)
        {
            var query = DataQuery.Create("Security", "ws_Permissions_List", new
            {
                FacID = FacID
            });

            query += DataQuery.Create("Security", "ws_UserPermissions_List", new
            {
                ID    = this.GetInformation("UserID"),
                FacID = FacID
            });

            var ds = this.Execute(query);

            if (ds == null)
            {
                QA.UI.ShowError(this.LastError);
                return;
            }
            Permissions.Clear();
            // ws_Permissions_List
            var table = ds.Tables(0);

            foreach (DataRow row in table.Rows)
            {
                Permissions.Add(row["Key"].ToString().ToUpper());
            }
            UserPermissions.Clear();
            // ws_UserPermissions_List
            table = ds.Tables(1);
            foreach (DataRow row in table.Rows)
            {
                UserPermissions.Add(row["Key"].ToString().ToUpper());
            }
        }
 public void AddUser(User user, AccessPermissionEnum accessPerm)
 {
     UserPermissions.Add(new UserPermission(user, accessPerm));
 }
 /// <summary>
 /// Adds a user to the current folder
 /// </summary>
 /// <param name="mailAddress"></param>
 /// <param name="accessPerm">User permission </param>
 public void AddUser(string mailAddress, AccessPermissionEnum accessPerm)
 {
     UserPermissions.Add((new UserPermission(mailAddress, accessPerm)));
 }
示例#9
0
        /// <summary>
        /// Populates the fields for multiple objects from the columns found in an open reader.
        /// </summary>
        ///
        /// <param name="rdr" type="IDataReader">An object that implements the IDataReader interface</param>
        ///
        /// <returns>Object of UserPermissions</returns>
        ///
        /// <remarks>
        ///
        /// <RevisionHistory>
        /// Author				Date			Description
        /// DLGenerator			7/5/2012 11:05:31 AM		Created function
        /// 
        /// </RevisionHistory>
        ///
        /// </remarks>
        ///
        internal static UserPermissions PopulateObjectsFromReaderWithCheckingReader(IDataReader rdr, DatabaseHelper oDatabaseHelper, string ConnectionString)
        {
            UserPermissions list = new UserPermissions();

            if (rdr.Read())
            {
                UserPermission obj = new UserPermission(ConnectionString);
                PopulateObjectFromReader(obj, rdr);
                list.Add(obj);
                while (rdr.Read())
                {
                    obj = new UserPermission(ConnectionString);
                    PopulateObjectFromReader(obj, rdr);
                    list.Add(obj);
                }
                oDatabaseHelper.Dispose();
                return list;
            }
            else
            {
                oDatabaseHelper.Dispose();
                return null;
            }
        }
示例#10
0
        /// <summary>
        /// Populates the fields for multiple objects from the columns found in an open reader.
        /// </summary>
        ///
        /// <param name="rdr" type="IDataReader">An object that implements the IDataReader interface</param>
        ///
        /// <returns>Object of UserPermissions</returns>
        ///
        /// <remarks>
        ///
        /// <RevisionHistory>
        /// Author				Date			Description
        /// DLGenerator			7/5/2012 11:05:31 AM		Created function
        /// 
        /// </RevisionHistory>
        ///
        /// </remarks>
        ///
        internal static UserPermissions PopulateObjectsFromReader(IDataReader rdr, string ConnectionString)
        {
            UserPermissions list = new UserPermissions();

            while (rdr.Read())
            {
                UserPermission obj = new UserPermission(ConnectionString);
                PopulateObjectFromReader(obj,rdr);
                list.Add(obj);
            }
            return list;
        }