Exemple #1
0
        public bool isUserValid()
        {
            UsersTableModel usersTableModel = new UsersTableModel();

            usersTableModel.getUser(this.brugerId);
            return(this.brugerId == usersTableModel.brugerId && new Hash().getHashedPassword(this.password, usersTableModel.salt) == usersTableModel.password);
        }
Exemple #2
0
        public void updateUser(UsersTableModel utm)
        {
            openConnection();
            string hash, salt;

            new Hash().getHashedPasswordAndSalt(utm.password, out salt, out hash);

            cmd.CommandText = string.Format(
                "Update users " +
                "set password='******', salt='{1}', email='{2}', prim='{3}', erAdmin='{4}' " +
                "where brugerId='{5}'",
                hash, salt, utm.email, utm.primChar, utm.erAdminChar, utm.brugerId);
            int cnt = cmd.ExecuteNonQuery();

            closeConnection();
        }
Exemple #3
0
        public void createUser(UsersTableModel utm)
        {
            openConnection();

            string hash, salt;

            new Hash().getHashedPasswordAndSalt(utm.password, out salt, out hash);

            cmd.CommandText = string.Format(
                "insert into users(brugerId, createTs, password, salt, email, prim, erAdmin) " +
                "values('{0}', current_timestamp,'{1}','{2}','{3}','{4}','{5}');",
                utm.brugerId, hash, salt, utm.email, utm.primChar, utm.erAdminChar);
            int cnt = cmd.ExecuteNonQuery();

            closeConnection();
        }
Exemple #4
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            UsersTableModel objAsUsersTableModel = obj as UsersTableModel;

            if (objAsUsersTableModel == null)
            {
                return(false);
            }
            else
            {
                return(brugerId == objAsUsersTableModel.brugerId);
            }

            ;
        }
Exemple #5
0
        public List <UsersTableModel> getUserList()
        {
            List <UsersTableModel> utms = new List <UsersTableModel>();

            openConnection();
            cmd.CommandText = string.Format("select brugerId, createTs, password, salt, email, prim, erAdmin from users");
            MySqlDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                UsersTableModel utm = new UsersTableModel();
                utm.brugerId    = reader.GetString("brugerId");
                utm.createTs    = reader.GetDateTime("createTs");
                utm.password    = reader.GetString("password");
                utm.salt        = reader.GetString("salt");
                utm.email       = reader.GetString("email");
                utm.primChar    = reader.GetChar("prim");
                utm.erAdminChar = reader.GetChar("erAdmin");
                utms.Add(utm);
            }
            closeConnection();
            return(utms);
        }
Exemple #6
0
 public void deleteUser(UsersTableModel utm)
 {
     deleteUser(utm.brugerId);
 }