Example #1
0
        public static void SetConnector(IDataConnector connector, bool throwWhenSet = true)
        {
            lock (_sync)
            {
                if (_connector != null && throwWhenSet)
                {
                    throw new InvalidOperationException(String.Format("Attempted to load '{0}' when a '{1}' was already loaded", connector.ToString(), _connector.ToString()));
                }
                _connector = connector;
            }

            AuthenticatedUsers.Initialise();
        }
Example #2
0
 public static bool UpdateUser(string username, string password)
 {
     using (var bl = Storage.GetBuilder(SQLSafeName))
     {
         var hs = AuthenticatedUsers.Hash(username, password);
         bl.Update(UserTable.TableName, new DataParameter[]
         {
             new DataParameter(UserTable.ColumnNames.Password, hs)
         },
                   new WhereFilter(UserTable.ColumnNames.Username, username)
                   );
         return(Storage.ExecuteNonQuery(bl) > 0);
     }
 }
Example #3
0
 public static bool CreateUser(string username, string password, bool op = false)
 {
     using (var bl = Storage.GetBuilder(SQLSafeName))
     {
         var hs = AuthenticatedUsers.Hash(username, password);
         bl.InsertInto(UserTable.TableName, new DataParameter[]
         {
             new DataParameter(UserTable.ColumnNames.Username, username),
             new DataParameter(UserTable.ColumnNames.Password, hs),
             new DataParameter(UserTable.ColumnNames.Operator, op),
             new DataParameter(UserTable.ColumnNames.DateAdded, DateTime.Now)
         });
         return(Storage.ExecuteNonQuery(bl) > 0);
     }
 }
Example #4
0
        public bool ComparePassword(string username, string password)
        {
            var hs = AuthenticatedUsers.Hash(username, password);

            return(hs.Equals(Password));
        }