示例#1
0
        /// <summary>
        /// Takes a username and an un-hashed password from the WCF, and returns a the corrosponding user, if there is a user with that username and password in the Database. Otherwise, returns null.
        /// </summary>
        public User ValidateUser(String username, string unHashedPassword)
        {
            DBUser dbUser = new DBUser();
            User   user   = dbUser.GetByName(username);

            //Salt added to unHashedPassword
            if (user != null && user.Password != User.HashThisPassword(user.Salt + unHashedPassword))
            {
                user = null;
            }
            return(user);
        }
示例#2
0
        public void InsertUser()
        {
            User user   = new User("ThureKasperJesperHenrikOle1234", User.HashThisPassword("4321"));
            var  dbUser = new DBUser();

            //var userCtr = new UserCtr();

            //userCtr.InsertUser("ThureKasperJesperHenrikOle1234", user.Password);
            dbUser.InsertUser(user);
            User extractedUser = dbUser.GetByName(user.Username);

            //Assert.IsTrue(extractedUser.Password.Equals(user.Password));
            Assert.IsTrue(extractedUser.Username.Equals(user.Username));
        }
示例#3
0
        public int GetUserID(string username)
        {
            DBUser dbUser = new DBUser();

            try
            {
                User user = dbUser.GetByName(username);
                if (user == null)
                {
                    return(0);
                }
                return(user.Id);
            }
            catch (Exception e)
            {
                throw e;
            }
        }