Пример #1
0
        public void TestHashAndCheck_ShouldReject()
        {
            var    Hasher       = new HashUtil();
            string TestPassword = "******";
            string Hashed       = Hasher.HashPassword(TestPassword);

            Assert.False(Hasher.CheckPassword(Hashed, "SomeInvalidPass"));
        }
Пример #2
0
        public void TestHashAndCheck_ShouldAuth()
        {
            var    Hasher       = new HashUtil();
            string TestPassword = "******";
            string Hashed       = Hasher.HashPassword(TestPassword);

            Assert.True(Hasher.CheckPassword(Hashed, TestPassword));
        }
        public User LoginUser(Player client, string name, string passwort)
        {
            ISession session = NHibernateHelper.GetCurrentSession();

            using (ITransaction tx = session.BeginTransaction())
            {
                try
                {
                    UserRepository userRepository = new UserRepository(session, tx);
                    List <User>    userList       = userRepository.GetUserWithName(name);
                    if (userList == null || userList.Count == 0)
                    {
                        NAPI.Util.ConsoleOutput("Benutzer existiert nicht");
                        return(null);
                    }
                    else if (userList.Count > 1)
                    {
                        NAPI.Util.ConsoleOutput("Benutzer existiert mehrmals");
                        return(null);
                    }
                    User user = userList[0];
                    if (!HashUtil.CheckPassword(user, passwort))
                    {
                        NAPI.Util.ConsoleOutput("Passwort stimmt nicht überein");
                        client.SendChatMessage("Passwort stimmt nicht überein");
                        return(null);
                    }
                    if (user.WhitelistStatus == 0)
                    {
                        NAPI.Util.ConsoleOutput("Account ist nicht whitelisted");
                        client.SendChatMessage("Account ist nicht whitelisted");
                        return(null);
                    }
                    return(user);
                }
                catch (Exception e)
                {
                    NAPI.Util.ConsoleOutput(e.ToString());
                }
                finally
                {
                    NHibernateHelper.CloseSession();
                }
            }
            return(null);
        }