예제 #1
0
        internal bool ValidateUser(UserModel userModel)
        {
            string        password = userModel.Password + userModel.UserName;
            HashAlgorithm mhash    = new SHA1CryptoServiceProvider();

            byte[] bytValue = System.Text.Encoding.UTF8.GetBytes(password);
            byte[] bytHash  = mhash.ComputeHash(bytValue);
            mhash.Clear();
            userModel.Password = Convert.ToBase64String(bytHash);

            bool validUser = false;

            List <DataParameter> parameters = new List <DataParameter>();

            parameters.Add(new DataParameter("UserName", userModel.UserName, "AND"));
            parameters.Add(new DataParameter("Password", userModel.Password, ""));

            DataSet data = DataAccess.GetSingleByMultipleParameter(new UserModel().DataProvider, "users", parameters);

            if (data.Tables["users"].Rows.Count != 0)
            {
                UserModel loadedUser = FillUser(data.Tables["users"].Rows[0]);

                validUser = true;

                ForumUserController controller = new ForumUserController();

                ForumUserModel forumUserModel = controller.GetForumUserByName(loadedUser.UserName);

                SetStateUser(loadedUser, forumUserModel);
            }

            return(validUser);
        }
예제 #2
0
        public bool IsExistingUser(UserModel user)
        {
            State state = new State();

            bool exitingUser = false;

            DataSet data = DataAccess.GetSingleByParameter(new UserModel().DataProvider, "users", new KeyValuePair <string, string>("UserName", user.UserName));

            if (data.Tables["users"].Rows.Count != 0)
            {
                UserModel loadedUser = FillUser(data.Tables["users"].Rows[0]);

                exitingUser = true;

                loadedUser.Password = "";

                ForumUserController forumUserController = new ForumUserController();
                ForumUserModel      forumUserModel      = forumUserController.GetForumUserByName(loadedUser.UserName);

                state.Cache().SetUser(loadedUser, forumUserModel);
            }

            return(exitingUser);
        }